Merge remote-tracking branch 'remotes/yongbok/tags/mips-20170803' into staging
MIPS patches 2017-08-03
Changes:
KVM T&E segment support for TCG
malta: leave space for the bootmap after the initrd
Apply CP0.PageMask before writing into TLB entry
Fix fallout from indirect branch optimisation
# gpg: Signature made Thu 03 Aug 2017 15:32:59 BST
# gpg: using RSA key 0x2238EB86D5F797C2
# gpg: Good signature from "Yongbok Kim <yongbok.kim@imgtec.com>"
# gpg: WARNING: This key is not certified with sufficiently trusted signatures!
# gpg: It is not certain that the signature belongs to the owner.
# Primary key fingerprint: 8600 4CF5 3415 A5D9 4CFA 2B5C 2238 EB86 D5F7 97C2
* remotes/yongbok/tags/mips-20170803:
target/mips: Fix RDHWR CC with icount
target/mips: Drop redundant gen_io_start/stop()
target/mips: Use BS_EXCP where interrupts are expected
target-mips: apply CP0.PageMask before writing into TLB entry
mips: Add KVM T&E segment support for TCG
mips: Improve segment defs for KVM T&E guests
mips/malta: leave space for the bootmap after the initrd
target-mips: Don't stop on [d]mtc0 DESAVE/KScratch
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
diff --git a/configure b/configure
index 987f59b..dd73cce 100755
--- a/configure
+++ b/configure
@@ -306,6 +306,7 @@
vhost_net="no"
vhost_scsi="no"
vhost_vsock="no"
+vhost_user=""
kvm="no"
hax="no"
rdma=""
@@ -1282,6 +1283,14 @@
;;
--enable-vxhs) vxhs="yes"
;;
+ --disable-vhost-user) vhost_user="no"
+ ;;
+ --enable-vhost-user)
+ vhost_user="yes"
+ if test "$mingw32" = "yes"; then
+ error_exit "vhost-user isn't available on win32"
+ fi
+ ;;
*)
echo "ERROR: unknown option $opt"
echo "Try '$0 --help' for more information"
@@ -1290,6 +1299,14 @@
esac
done
+if test "$vhost_user" = ""; then
+ if test "$mingw32" = "yes"; then
+ vhost_user="no"
+ else
+ vhost_user="yes"
+ fi
+fi
+
case "$cpu" in
ppc)
CPU_CFLAGS="-m32"
@@ -1518,6 +1535,7 @@
tools build qemu-io, qemu-nbd and qemu-image tools
vxhs Veritas HyperScale vDisk backend support
crypto-afalg Linux AF_ALG crypto backend driver
+ vhost-user vhost-user support
NOTE: The object files are built at the place where configure is launched
EOF
@@ -5348,6 +5366,7 @@
echo "vhost-net support $vhost_net"
echo "vhost-scsi support $vhost_scsi"
echo "vhost-vsock support $vhost_vsock"
+echo "vhost-user support $vhost_user"
echo "Trace backends $trace_backends"
if have_backend "simple"; then
echo "Trace output file $trace_file-<pid>"
@@ -5757,12 +5776,15 @@
if test "$vhost_scsi" = "yes" ; then
echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
fi
-if test "$vhost_net" = "yes" ; then
+if test "$vhost_net" = "yes" -a "$vhost_user" = "yes"; then
echo "CONFIG_VHOST_NET_USED=y" >> $config_host_mak
fi
if test "$vhost_vsock" = "yes" ; then
echo "CONFIG_VHOST_VSOCK=y" >> $config_host_mak
fi
+if test "$vhost_user" = "yes" ; then
+ echo "CONFIG_VHOST_USER=y" >> $config_host_mak
+fi
if test "$blobs" = "yes" ; then
echo "INSTALL_BLOBS=yes" >> $config_host_mak
fi
@@ -6358,7 +6380,9 @@
echo "CONFIG_KVM=y" >> $config_target_mak
if test "$vhost_net" = "yes" ; then
echo "CONFIG_VHOST_NET=y" >> $config_target_mak
- echo "CONFIG_VHOST_NET_TEST_$target_name=y" >> $config_host_mak
+ if test "$vhost_user" = "yes" ; then
+ echo "CONFIG_VHOST_USER_NET_TEST_$target_name=y" >> $config_host_mak
+ fi
fi
fi
if supported_hax_target $target; then
diff --git a/default-configs/pci.mak b/default-configs/pci.mak
index acaa703..a758630 100644
--- a/default-configs/pci.mak
+++ b/default-configs/pci.mak
@@ -43,4 +43,4 @@
CONFIG_VGA_PCI=y
CONFIG_IVSHMEM_DEVICE=$(CONFIG_IVSHMEM)
CONFIG_ROCKER=y
-CONFIG_VHOST_USER_SCSI=$(CONFIG_LINUX)
+CONFIG_VHOST_USER_SCSI=$(and $(CONFIG_VHOST_USER),$(CONFIG_LINUX))
diff --git a/default-configs/s390x-softmmu.mak b/default-configs/s390x-softmmu.mak
index b227a36..51191b7 100644
--- a/default-configs/s390x-softmmu.mak
+++ b/default-configs/s390x-softmmu.mak
@@ -1,6 +1,6 @@
CONFIG_PCI=y
CONFIG_VIRTIO_PCI=y
-CONFIG_VHOST_USER_SCSI=$(CONFIG_LINUX)
+CONFIG_VHOST_USER_SCSI=$(and $(CONFIG_VHOST_USER),$(CONFIG_LINUX))
CONFIG_VIRTIO=y
CONFIG_SCLPCONSOLE=y
CONFIG_TERMINAL3270=y
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index 5d14bd6..8b0d6b6 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -2135,7 +2135,7 @@
};
#endif
-#ifdef CONFIG_LINUX
+#if defined(CONFIG_VHOST_USER) && defined(CONFIG_LINUX)
/* vhost-user-scsi-pci */
static Property vhost_user_scsi_pci_properties[] = {
DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors,
@@ -2665,7 +2665,7 @@
#ifdef CONFIG_VHOST_SCSI
type_register_static(&vhost_scsi_pci_info);
#endif
-#ifdef CONFIG_LINUX
+#if defined(CONFIG_VHOST_USER) && defined(CONFIG_LINUX)
type_register_static(&vhost_user_scsi_pci_info);
#endif
#ifdef CONFIG_VHOST_VSOCK
diff --git a/net/slirp.c b/net/slirp.c
index 9fbc949..01ed21c 100644
--- a/net/slirp.c
+++ b/net/slirp.c
@@ -91,15 +91,15 @@
QTAILQ_HEAD_INITIALIZER(slirp_stacks);
static int slirp_hostfwd(SlirpState *s, const char *redir_str,
- int legacy_format);
+ int legacy_format, Error **errp);
static int slirp_guestfwd(SlirpState *s, const char *config_str,
- int legacy_format);
+ int legacy_format, Error **errp);
#ifndef _WIN32
static const char *legacy_smb_export;
static int slirp_smb(SlirpState *s, const char *exported_dir,
- struct in_addr vserver_addr);
+ struct in_addr vserver_addr, Error **errp);
static void slirp_smb_cleanup(SlirpState *s);
#else
static inline void slirp_smb_cleanup(SlirpState *s) { }
@@ -155,7 +155,7 @@
const char *bootfile, const char *vdhcp_start,
const char *vnameserver, const char *vnameserver6,
const char *smb_export, const char *vsmbserver,
- const char **dnssearch)
+ const char **dnssearch, Error **errp)
{
/* default settings according to historic slirp */
struct in_addr net = { .s_addr = htonl(0x0a000200) }; /* 10.0.2.0 */
@@ -178,15 +178,18 @@
struct slirp_config_str *config;
if (!ipv4 && (vnetwork || vhost || vnameserver)) {
+ error_setg(errp, "IPv4 disabled but netmask/host/dns provided");
return -1;
}
if (!ipv6 && (vprefix6 || vhost6 || vnameserver6)) {
+ error_setg(errp, "IPv6 disabled but prefix/host6/dns6 provided");
return -1;
}
if (!ipv4 && !ipv6) {
/* It doesn't make sense to disable both */
+ error_setg(errp, "IPv4 and IPv6 disabled");
return -1;
}
@@ -200,6 +203,7 @@
if (vnetwork) {
if (get_str_sep(buf, sizeof(buf), &vnetwork, '/') < 0) {
if (!inet_aton(vnetwork, &net)) {
+ error_setg(errp, "Failed to parse netmask");
return -1;
}
addr = ntohl(net.s_addr);
@@ -220,14 +224,19 @@
}
} else {
if (!inet_aton(buf, &net)) {
+ error_setg(errp, "Failed to parse netmask");
return -1;
}
shift = strtol(vnetwork, &end, 10);
if (*end != '\0') {
if (!inet_aton(vnetwork, &mask)) {
+ error_setg(errp,
+ "Failed to parse netmask (trailing chars)");
return -1;
}
} else if (shift < 4 || shift > 32) {
+ error_setg(errp,
+ "Invalid netmask provided (must be in range 4-32)");
return -1;
} else {
mask.s_addr = htonl(0xffffffff << (32 - shift));
@@ -240,30 +249,43 @@
}
if (vhost && !inet_aton(vhost, &host)) {
+ error_setg(errp, "Failed to parse host");
return -1;
}
if ((host.s_addr & mask.s_addr) != net.s_addr) {
+ error_setg(errp, "Host doesn't belong to network");
return -1;
}
if (vnameserver && !inet_aton(vnameserver, &dns)) {
+ error_setg(errp, "Failed to parse DNS");
return -1;
}
- if ((dns.s_addr & mask.s_addr) != net.s_addr ||
- dns.s_addr == host.s_addr) {
+ if ((dns.s_addr & mask.s_addr) != net.s_addr) {
+ error_setg(errp, "DNS doesn't belong to network");
+ return -1;
+ }
+ if (dns.s_addr == host.s_addr) {
+ error_setg(errp, "DNS must be different from host");
return -1;
}
if (vdhcp_start && !inet_aton(vdhcp_start, &dhcp)) {
+ error_setg(errp, "Failed to parse DHCP start address");
return -1;
}
- if ((dhcp.s_addr & mask.s_addr) != net.s_addr ||
- dhcp.s_addr == host.s_addr || dhcp.s_addr == dns.s_addr) {
+ if ((dhcp.s_addr & mask.s_addr) != net.s_addr) {
+ error_setg(errp, "DHCP doesn't belong to network");
+ return -1;
+ }
+ if (dhcp.s_addr == host.s_addr || dhcp.s_addr == dns.s_addr) {
+ error_setg(errp, "DNS must be different from host and DNS");
return -1;
}
#ifndef _WIN32
if (vsmbserver && !inet_aton(vsmbserver, &smbsrv)) {
+ error_setg(errp, "Failed to parse SMB address");
return -1;
}
#endif
@@ -272,6 +294,7 @@
/* No inet_pton helper before Vista... */
if (vprefix6) {
/* Unsupported */
+ error_setg(errp, "IPv6 prefix not supported");
return -1;
}
memset(&ip6_prefix, 0, sizeof(ip6_prefix));
@@ -282,6 +305,7 @@
vprefix6 = "fec0::";
}
if (!inet_pton(AF_INET6, vprefix6, &ip6_prefix)) {
+ error_setg(errp, "Failed to parse IPv6 prefix");
return -1;
}
#endif
@@ -290,17 +314,22 @@
vprefix6_len = 64;
}
if (vprefix6_len < 0 || vprefix6_len > 126) {
+ error_setg(errp,
+ "Invalid prefix provided (prefix len must be in range 0-126");
return -1;
}
if (vhost6) {
#if defined(_WIN32) && (_WIN32_WINNT < 0x0600)
+ error_setg(errp, "IPv6 host not supported");
return -1;
#else
if (!inet_pton(AF_INET6, vhost6, &ip6_host)) {
+ error_setg(errp, "Failed to parse IPv6 host");
return -1;
}
if (!in6_equal_net(&ip6_prefix, &ip6_host, vprefix6_len)) {
+ error_setg(errp, "IPv6 Host doesn't belong to network");
return -1;
}
#endif
@@ -311,12 +340,15 @@
if (vnameserver6) {
#if defined(_WIN32) && (_WIN32_WINNT < 0x0600)
+ error_setg(errp, "IPv6 DNS not supported");
return -1;
#else
if (!inet_pton(AF_INET6, vnameserver6, &ip6_dns)) {
+ error_setg(errp, "Failed to parse IPv6 DNS");
return -1;
}
if (!in6_equal_net(&ip6_prefix, &ip6_dns, vprefix6_len)) {
+ error_setg(errp, "IPv6 DNS doesn't belong to network");
return -1;
}
#endif
@@ -343,12 +375,14 @@
for (config = slirp_configs; config; config = config->next) {
if (config->flags & SLIRP_CFG_HOSTFWD) {
if (slirp_hostfwd(s, config->str,
- config->flags & SLIRP_CFG_LEGACY) < 0)
+ config->flags & SLIRP_CFG_LEGACY, errp) < 0) {
goto error;
+ }
} else {
if (slirp_guestfwd(s, config->str,
- config->flags & SLIRP_CFG_LEGACY) < 0)
+ config->flags & SLIRP_CFG_LEGACY, errp) < 0) {
goto error;
+ }
}
}
#ifndef _WIN32
@@ -356,8 +390,9 @@
smb_export = legacy_smb_export;
}
if (smb_export) {
- if (slirp_smb(s, smb_export, smbsrv) < 0)
+ if (slirp_smb(s, smb_export, smbsrv, errp) < 0) {
goto error;
+ }
}
#endif
@@ -452,7 +487,7 @@
}
static int slirp_hostfwd(SlirpState *s, const char *redir_str,
- int legacy_format)
+ int legacy_format, Error **errp)
{
struct in_addr host_addr = { .s_addr = INADDR_ANY };
struct in_addr guest_addr = { .s_addr = 0 };
@@ -505,14 +540,14 @@
if (slirp_add_hostfwd(s->slirp, is_udp, host_addr, host_port, guest_addr,
guest_port) < 0) {
- error_report("could not set up host forwarding rule '%s'",
- redir_str);
+ error_setg(errp, "Could not set up host forwarding rule '%s'",
+ redir_str);
return -1;
}
return 0;
fail_syntax:
- error_report("invalid host forwarding rule '%s'", redir_str);
+ error_setg(errp, "Invalid host forwarding rule '%s'", redir_str);
return -1;
}
@@ -532,7 +567,10 @@
redir_str = arg1;
}
if (s) {
- slirp_hostfwd(s, redir_str, 0);
+ Error *err = NULL;
+ if (slirp_hostfwd(s, redir_str, 0, &err) < 0) {
+ error_report_err(err);
+ }
}
}
@@ -540,6 +578,8 @@
int net_slirp_redir(const char *redir_str)
{
struct slirp_config_str *config;
+ Error *err = NULL;
+ int res;
if (QTAILQ_EMPTY(&slirp_stacks)) {
config = g_malloc(sizeof(*config));
@@ -550,7 +590,11 @@
return 0;
}
- return slirp_hostfwd(QTAILQ_FIRST(&slirp_stacks), redir_str, 1);
+ res = slirp_hostfwd(QTAILQ_FIRST(&slirp_stacks), redir_str, 1, &err);
+ if (res < 0) {
+ error_report_err(err);
+ }
+ return res;
}
#ifndef _WIN32
@@ -576,7 +620,7 @@
}
static int slirp_smb(SlirpState* s, const char *exported_dir,
- struct in_addr vserver_addr)
+ struct in_addr vserver_addr, Error **errp)
{
char *smb_conf;
char *smb_cmdline;
@@ -585,25 +629,25 @@
passwd = getpwuid(geteuid());
if (!passwd) {
- error_report("failed to retrieve user name");
+ error_setg(errp, "Failed to retrieve user name");
return -1;
}
if (access(CONFIG_SMBD_COMMAND, F_OK)) {
- error_report("could not find '%s', please install it",
- CONFIG_SMBD_COMMAND);
+ error_setg(errp, "Could not find '%s', please install it",
+ CONFIG_SMBD_COMMAND);
return -1;
}
if (access(exported_dir, R_OK | X_OK)) {
- error_report("error accessing shared directory '%s': %s",
- exported_dir, strerror(errno));
+ error_setg(errp, "Error accessing shared directory '%s': %s",
+ exported_dir, strerror(errno));
return -1;
}
s->smb_dir = g_dir_make_tmp("qemu-smb.XXXXXX", NULL);
if (!s->smb_dir) {
- error_report("could not create samba server dir");
+ error_setg(errp, "Could not create samba server dir");
return -1;
}
smb_conf = g_strdup_printf("%s/%s", s->smb_dir, "smb.conf");
@@ -611,8 +655,9 @@
f = fopen(smb_conf, "w");
if (!f) {
slirp_smb_cleanup(s);
- error_report("could not create samba server configuration file '%s'",
- smb_conf);
+ error_setg(errp,
+ "Could not create samba server configuration file '%s'",
+ smb_conf);
g_free(smb_conf);
return -1;
}
@@ -660,7 +705,7 @@
slirp_add_exec(s->slirp, 0, smb_cmdline, &vserver_addr, 445) < 0) {
slirp_smb_cleanup(s);
g_free(smb_cmdline);
- error_report("conflicting/invalid smbserver address");
+ error_setg(errp, "Conflicting/invalid smbserver address");
return -1;
}
g_free(smb_cmdline);
@@ -678,8 +723,13 @@
}
legacy_smb_export = exported_dir;
if (!QTAILQ_EMPTY(&slirp_stacks)) {
- return slirp_smb(QTAILQ_FIRST(&slirp_stacks), exported_dir,
- vserver_addr);
+ Error *err = NULL;
+ int res = slirp_smb(QTAILQ_FIRST(&slirp_stacks), exported_dir,
+ vserver_addr, &err);
+ if (res < 0) {
+ error_report_err(err);
+ }
+ return res;
}
return 0;
}
@@ -706,7 +756,7 @@
}
static int slirp_guestfwd(SlirpState *s, const char *config_str,
- int legacy_format)
+ int legacy_format, Error **errp)
{
struct in_addr server = { .s_addr = 0 };
struct GuestFwd *fwd;
@@ -746,8 +796,8 @@
if ((strlen(p) > 4) && !strncmp(p, "cmd:", 4)) {
if (slirp_add_exec(s->slirp, 0, &p[4], &server, port) < 0) {
- error_report("conflicting/invalid host:port in guest forwarding "
- "rule '%s'", config_str);
+ error_setg(errp, "Conflicting/invalid host:port in guest "
+ "forwarding rule '%s'", config_str);
return -1;
}
} else {
@@ -755,21 +805,22 @@
Chardev *chr = qemu_chr_new(buf, p);
if (!chr) {
- error_report("could not open guest forwarding device '%s'", buf);
+ error_setg(errp, "Could not open guest forwarding device '%s'",
+ buf);
return -1;
}
fwd = g_new(struct GuestFwd, 1);
qemu_chr_fe_init(&fwd->hd, chr, &err);
if (err) {
- error_report_err(err);
+ error_propagate(errp, err);
g_free(fwd);
return -1;
}
if (slirp_add_exec(s->slirp, 3, &fwd->hd, &server, port) < 0) {
- error_report("conflicting/invalid host:port in guest forwarding "
- "rule '%s'", config_str);
+ error_setg(errp, "Conflicting/invalid host:port in guest "
+ "forwarding rule '%s'", config_str);
g_free(fwd);
return -1;
}
@@ -783,7 +834,7 @@
return 0;
fail_syntax:
- error_report("invalid guest forwarding rule '%s'", config_str);
+ error_setg(errp, "Invalid guest forwarding rule '%s'", config_str);
return -1;
}
@@ -845,7 +896,6 @@
int net_init_slirp(const Netdev *netdev, const char *name,
NetClientState *peer, Error **errp)
{
- /* FIXME error_setg(errp, ...) on failure */
struct slirp_config_str *config;
char *vnet;
int ret;
@@ -882,7 +932,7 @@
user->ipv6_host, user->hostname, user->tftp,
user->bootfile, user->dhcpstart,
user->dns, user->ipv6_dns, user->smb,
- user->smbserver, dnssearch);
+ user->smbserver, dnssearch, errp);
while (slirp_configs) {
config = slirp_configs;
@@ -919,7 +969,11 @@
slirp_configs = config;
*ret = 0;
} else {
- *ret = slirp_guestfwd(QTAILQ_FIRST(&slirp_stacks), optarg, 1);
+ Error *err = NULL;
+ *ret = slirp_guestfwd(QTAILQ_FIRST(&slirp_stacks), optarg, 1, &err);
+ if (*ret < 0) {
+ error_report_err(err);
+ }
}
return 1;
diff --git a/slirp/bootp.c b/slirp/bootp.c
index 5a4646c..5dd1a41 100644
--- a/slirp/bootp.c
+++ b/slirp/bootp.c
@@ -123,6 +123,9 @@
if (p >= p_end)
break;
len = *p++;
+ if (p + len > p_end) {
+ break;
+ }
DPRINTF("dhcp: tag=%d len=%d\n", tag, len);
switch(tag) {
diff --git a/tests/Makefile.include b/tests/Makefile.include
index 59e536b..eb4895f 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -255,9 +255,9 @@
check-qtest-i386-y += tests/q35-test$(EXESUF)
check-qtest-i386-y += tests/vmgenid-test$(EXESUF)
gcov-files-i386-y += hw/pci-host/q35.c
-check-qtest-i386-$(CONFIG_VHOST_NET_TEST_i386) += tests/vhost-user-test$(EXESUF)
-ifeq ($(CONFIG_VHOST_NET_TEST_i386),)
-check-qtest-x86_64-$(CONFIG_VHOST_NET_TEST_x86_64) += tests/vhost-user-test$(EXESUF)
+check-qtest-i386-$(CONFIG_VHOST_USER_NET_TEST_i386) += tests/vhost-user-test$(EXESUF)
+ifeq ($(CONFIG_VHOST_USER_NET_TEST_i386),)
+check-qtest-x86_64-$(CONFIG_VHOST_USER_NET_TEST_x86_64) += tests/vhost-user-test$(EXESUF)
endif
check-qtest-i386-$(CONFIG_SLIRP) += tests/test-netfilter$(EXESUF)
check-qtest-i386-y += tests/test-filter-mirror$(EXESUF)