From nobody Tue Nov 4 19:01:34 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530897450311481.4342162589902; Fri, 6 Jul 2018 10:17:30 -0700 (PDT) Received: from localhost ([::1]:59008 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fbUML-0002Uc-AX for importer@patchew.org; Fri, 06 Jul 2018 13:17:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51047) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fbUK4-0001D4-66 for qemu-devel@nongnu.org; Fri, 06 Jul 2018 13:15:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fbUJz-0000kr-UN for qemu-devel@nongnu.org; Fri, 06 Jul 2018 13:15:08 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:44932) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fbUJz-0000kN-G3 for qemu-devel@nongnu.org; Fri, 06 Jul 2018 13:15:03 -0400 Received: by mail-wr1-x444.google.com with SMTP id r16-v6so4873020wrt.11 for ; Fri, 06 Jul 2018 10:15:03 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id h40-v6sm13784683wrf.40.2018.07.06.10.15.01 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Jul 2018 10:15:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=CrX2pNcywD0kHcAnRUdC4yRQEJhoMKEI9aBJorcN8CM=; b=iEi9p7nD7iKoGCSojXszcDB7JR0ABc209vJo/39WR1LqKFTo38ucgHLJCT5elE8T9A 49pZp+dm8+xmc4EYwljyX/Yk4Li8Sy9jyshaZoppibCIF51aOKcrs078CMZyPR937B8O sAB7eTfaCbXO0sGnN+AxCSW4Sd4S6698vrlZo6Hz0EKGMUIG19EpEOhHG0DfQb6V+2VI jUk/3bzmE18om0VQzkaOBkKjvigqGBZnQUAKv9MPNCwctV0SLzkbaOgR0kfJxPXmTyRW Irp7d5BypToNtTcRMiCoeRnnLOZLEQ+s58rEvJvLMy5tgpnqhQ4eF0cCHNde2mm9ho3R Kmwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=CrX2pNcywD0kHcAnRUdC4yRQEJhoMKEI9aBJorcN8CM=; b=Ha2goKGCKhdosoG4eOznnkMZYHoK7M0I1COUlPnQGHd3hYGvTodQwM83aWkrDSZqhm qUHQ4XGgEhB+cIrtNSZskg765ihzGauIDBKg8l/gVaZq4CIWaPWZkPaIC120xDKEGZxs Q1opLgX1yP7zz/T2I0AZ/DUooYj9VVrmSnVvkAw5T8KBjCdALG6uKqV3rV31dpGOubp8 N6b+cDuv1nUycAZjw76s7wIKJ7/m3rVBtJNxYC/2RqkysL/WANJ7w2FBQOslXKJDCLqp 7oxd4LCmmEal5qj2nzxxZLjS6TE1L6Z9QZmH0B4u6VAWf5Ibd7RVbhLcr1vZ529gVCFQ dB6A== X-Gm-Message-State: APt69E1yWLJ25MawdQsFPsW5NLgO8ocsD1LrycNBizyx6LezJQ6kas7L hmsceTwPJ11/PBH+dKZEsDp5iuHe X-Google-Smtp-Source: AAOMgpdhVlSCDDBh5DdchGyAtccb9aKjIsXQGwDbvg3HbsGIi7jdw/xB7PCK9mh+DOgJyfDHhr6TtA== X-Received: by 2002:adf:9025:: with SMTP id h34-v6mr8816562wrh.123.1530897302264; Fri, 06 Jul 2018 10:15:02 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 6 Jul 2018 19:14:21 +0200 Message-Id: <1530897268-22932-2-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530897268-22932-1-git-send-email-pbonzini@redhat.com> References: <1530897268-22932-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::444 Subject: [Qemu-devel] [PULL 1/8] pr-helper: avoid error on PR IN command with zero request size X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" After reading a PR IN command with zero request size in prh_read_request, the resp->result field will be uninitialized and the resp.sz field will be also uninitialized when returning to prh_co_entry. If resp->result =3D=3D GOOD (from a previous successful reply or just luck), then the assert in prh_write_response might not be triggered and uninitialized response will be sent. The fix is to remove the whole handling of sz =3D=3D 0 in prh_co_entry. Those errors apply only to PR OUT commands and it's perfectly okay to catch them later in do_pr_out and multipath_pr_out; the check for too-short parameters in fact doesn't apply in the easy SG_IO case, as it can be left to the target firmware even. The result is that prh_read_request does not fail requests anymore and prh_co_entry becomes simpler. Reported-by: Dima Stepanov Signed-off-by: Paolo Bonzini --- scsi/qemu-pr-helper.c | 63 ++++++++++++++++++++++++-----------------------= ---- 1 file changed, 30 insertions(+), 33 deletions(-) diff --git a/scsi/qemu-pr-helper.c b/scsi/qemu-pr-helper.c index 0218d65..c89a446 100644 --- a/scsi/qemu-pr-helper.c +++ b/scsi/qemu-pr-helper.c @@ -455,6 +455,14 @@ static int multipath_pr_out(int fd, const uint8_t *cdb= , uint8_t *sense, char transportids[PR_HELPER_DATA_SIZE]; int r; =20 + if (sz < PR_OUT_FIXED_PARAM_SIZE) { + /* Illegal request, Parameter list length error. This isn't fatal; + * we have read the data, send an error without closing the socket. + */ + scsi_build_sense(sense, SENSE_CODE(INVALID_PARAM_LEN)); + return CHECK_CONDITION; + } + switch (rq_servact) { case MPATH_PROUT_REG_SA: case MPATH_PROUT_RES_SA: @@ -574,6 +582,12 @@ static int do_pr_out(int fd, const uint8_t *cdb, uint8= _t *sense, const uint8_t *param, int sz) { int resp_sz; + + if ((fcntl(fd, F_GETFL) & O_ACCMODE) =3D=3D O_RDONLY) { + scsi_build_sense(sense, SENSE_CODE(INVALID_OPCODE)); + return CHECK_CONDITION; + } + #ifdef CONFIG_MPATH if (is_mpath(fd)) { return multipath_pr_out(fd, cdb, sense, param, sz); @@ -690,21 +704,6 @@ static int coroutine_fn prh_read_request(PRHelperClien= t *client, errp) < 0) { goto out_close; } - if ((fcntl(client->fd, F_GETFL) & O_ACCMODE) =3D=3D O_RDONLY) { - scsi_build_sense(resp->sense, SENSE_CODE(INVALID_OPCODE)); - sz =3D 0; - } else if (sz < PR_OUT_FIXED_PARAM_SIZE) { - /* Illegal request, Parameter list length error. This isn't f= atal; - * we have read the data, send an error without closing the so= cket. - */ - scsi_build_sense(resp->sense, SENSE_CODE(INVALID_PARAM_LEN)); - sz =3D 0; - } - if (sz =3D=3D 0) { - resp->result =3D CHECK_CONDITION; - close(client->fd); - client->fd =3D -1; - } } =20 req->fd =3D client->fd; @@ -785,25 +784,23 @@ static void coroutine_fn prh_co_entry(void *opaque) break; } =20 - if (sz > 0) { - num_active_sockets++; - if (req.cdb[0] =3D=3D PERSISTENT_RESERVE_OUT) { - r =3D do_pr_out(req.fd, req.cdb, resp.sense, - client->data, sz); - resp.sz =3D 0; - } else { - resp.sz =3D sizeof(client->data); - r =3D do_pr_in(req.fd, req.cdb, resp.sense, - client->data, &resp.sz); - resp.sz =3D MIN(resp.sz, sz); - } - num_active_sockets--; - close(req.fd); - if (r =3D=3D -1) { - break; - } - resp.result =3D r; + num_active_sockets++; + if (req.cdb[0] =3D=3D PERSISTENT_RESERVE_OUT) { + r =3D do_pr_out(req.fd, req.cdb, resp.sense, + client->data, sz); + resp.sz =3D 0; + } else { + resp.sz =3D sizeof(client->data); + r =3D do_pr_in(req.fd, req.cdb, resp.sense, + client->data, &resp.sz); + resp.sz =3D MIN(resp.sz, sz); + } + num_active_sockets--; + close(req.fd); + if (r =3D=3D -1) { + break; } + resp.result =3D r; =20 if (prh_write_response(client, &req, &resp, &local_err) < 0) { break; --=20 1.8.3.1 From nobody Tue Nov 4 19:01:34 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 153089777216748.388512829743604; Fri, 6 Jul 2018 10:22:52 -0700 (PDT) Received: from localhost ([::1]:59038 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fbURX-0006tz-BH for importer@patchew.org; Fri, 06 Jul 2018 13:22:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51049) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fbUK4-0001D5-6q for qemu-devel@nongnu.org; Fri, 06 Jul 2018 13:15:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fbUK0-0000lF-PP for qemu-devel@nongnu.org; Fri, 06 Jul 2018 13:15:08 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:33779) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fbUK0-0000kv-HF for qemu-devel@nongnu.org; Fri, 06 Jul 2018 13:15:04 -0400 Received: by mail-wr1-x444.google.com with SMTP id k7-v6so4865155wrq.0 for ; Fri, 06 Jul 2018 10:15:04 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id h40-v6sm13784683wrf.40.2018.07.06.10.15.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Jul 2018 10:15:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=dkYxrUNZg+LvvaoTjlrZ8AaE2tjNq6W7FbTBUc0UKAM=; b=QsnpmVH5//1u79yyl5o9C3dF+Ah0McLs27SXhlHT11D5cgFj52e6VAZWyqcWOG8wOZ QEWtLc3Z1QrC8xKI1pooKdgtdaq6PU97LcdzoXyzTEdIhARszfg+vcwqBuF6QMUvB11x 4w8c94X8HsVGFWC1Lfnrejsn7bHjnDKhdQcI8Yj3CbrPQhG6cOWztJxDdDBQrfSk4syw 0OXY2moLTkdWgmKa607iE2lz79z4fp//Rf2J3uuZSCm37ziLYHRe5Oosk/h0tZgzaa2g kEdh2ae2RktuJ0aQ3Dn8jwVQQx0n9FhfUc+NS9zZRtbSkfOuPh0z/hZEHm6zhMkejj7X OLdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=dkYxrUNZg+LvvaoTjlrZ8AaE2tjNq6W7FbTBUc0UKAM=; b=GWw3SgGk0i/XYSjt77xrVRJzRRHjgf2EaE24MUpeeEj4fhN1M7UbARz/N4aGIL/LTi XE8w/Pl+fZBBh8ecw7LkCoP9+SbgAUb9qO75hIGHi0Un/V+ph+3L9Eyyp19vN4gBgcko 9f9+FXdaoLkNgnuWPeTX8Z81TD4rMG6tT5hc16RiZzI7oTr6YozGzHKw+i4x/kM6nsAo 7GnMuG6hSI6VqCaM6PmIPlipUbCr1wFYQbgur3pvNv4ERUSun1JL6VJMKm6qExcJ4OxF 0vJxz/eBJpt/2lqKkOz5k0hawvRTk4dBvCjVPp/ii0pvIGjtylB4rit4uVs6lsHY6J3d ZexQ== X-Gm-Message-State: APt69E1w+RH1J/pqbXE8hJ8AXlslHH1OuNtKp50+EvM81W5nXtCTpUhT /+aXxF6mf9Cy21ARYrkpfxvlwzIi X-Google-Smtp-Source: AAOMgpfnnWebo2RvvekpemZE98Cp7OYITINUwMETuFKWjB8kyXOseDlAE4p9XbSMfgQDHHOo2HZ9Qw== X-Received: by 2002:adf:b3d4:: with SMTP id x20-v6mr8459388wrd.272.1530897303311; Fri, 06 Jul 2018 10:15:03 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 6 Jul 2018 19:14:22 +0200 Message-Id: <1530897268-22932-3-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530897268-22932-1-git-send-email-pbonzini@redhat.com> References: <1530897268-22932-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::444 Subject: [Qemu-devel] [PULL 2/8] pr-helper: Rework socket path handling X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michal Privoznik Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Michal Privoznik When reviewing Paolo's pr-helper patches I've noticed couple of problems: 1) socket_path needs to be calculated at two different places (one for printing out help, the other if socket activation is NOT used), 2) even though the default socket_path is allocated in compute_default_paths() it is the only default path the function handles. For instance, pidfile is allocated outside of this function. And yet again, at different places than 1) Signed-off-by: Michal Privoznik Message-Id: Signed-off-by: Paolo Bonzini --- scsi/qemu-pr-helper.c | 36 ++++++++++-------------------------- 1 file changed, 10 insertions(+), 26 deletions(-) diff --git a/scsi/qemu-pr-helper.c b/scsi/qemu-pr-helper.c index c89a446..1528a71 100644 --- a/scsi/qemu-pr-helper.c +++ b/scsi/qemu-pr-helper.c @@ -76,14 +76,12 @@ static int gid =3D -1; =20 static void compute_default_paths(void) { - if (!socket_path) { - socket_path =3D qemu_get_local_state_pathname("run/qemu-pr-helper.= sock"); - } + socket_path =3D qemu_get_local_state_pathname("run/qemu-pr-helper.sock= "); + pidfile =3D qemu_get_local_state_pathname("run/qemu-pr-helper.pid"); } =20 static void usage(const char *name) { - compute_default_paths(); (printf) ( "Usage: %s [OPTIONS] FILE\n" "Persistent Reservation helper program for QEMU\n" @@ -841,19 +839,6 @@ static gboolean accept_client(QIOChannel *ioc, GIOCond= ition cond, gpointer opaqu return TRUE; } =20 - -/* - * Check socket parameters compatibility when socket activation is used. - */ -static const char *socket_activation_validate_opts(void) -{ - if (socket_path !=3D NULL) { - return "Unix socket can't be set when using socket activation"; - } - - return NULL; -} - static void termsig_handler(int signum) { atomic_cmpxchg(&state, RUNNING, TERMINATE); @@ -927,6 +912,7 @@ int main(int argc, char **argv) char *trace_file =3D NULL; bool daemonize =3D false; bool pidfile_specified =3D false; + bool socket_path_specified =3D false; unsigned socket_activation; =20 struct sigaction sa_sigterm; @@ -943,12 +929,14 @@ int main(int argc, char **argv) qemu_add_opts(&qemu_trace_opts); qemu_init_exec_dir(argv[0]); =20 - pidfile =3D qemu_get_local_state_pathname("run/qemu-pr-helper.pid"); + compute_default_paths(); =20 while ((ch =3D getopt_long(argc, argv, sopt, lopt, &opt_ind)) !=3D -1)= { switch (ch) { case 'k': - socket_path =3D optarg; + g_free(socket_path); + socket_path =3D g_strdup(optarg); + socket_path_specified =3D true; if (socket_path[0] !=3D '/') { error_report("socket path must be absolute"); exit(EXIT_FAILURE); @@ -1039,10 +1027,9 @@ int main(int argc, char **argv) socket_activation =3D check_socket_activation(); if (socket_activation =3D=3D 0) { SocketAddress saddr; - compute_default_paths(); saddr =3D (SocketAddress){ .type =3D SOCKET_ADDRESS_TYPE_UNIX, - .u.q_unix.path =3D g_strdup(socket_path) + .u.q_unix.path =3D socket_path, }; server_ioc =3D qio_channel_socket_new(); if (qio_channel_socket_listen_sync(server_ioc, &saddr, &local_err)= < 0) { @@ -1050,12 +1037,10 @@ int main(int argc, char **argv) error_report_err(local_err); return 1; } - g_free(saddr.u.q_unix.path); } else { /* Using socket activation - check user didn't use -p etc. */ - const char *err_msg =3D socket_activation_validate_opts(); - if (err_msg !=3D NULL) { - error_report("%s", err_msg); + if (socket_path_specified) { + error_report("Unix socket can't be set when using socket activ= ation"); exit(EXIT_FAILURE); } =20 @@ -1072,7 +1057,6 @@ int main(int argc, char **argv) error_get_pretty(local_err)); exit(EXIT_FAILURE); } - socket_path =3D NULL; } =20 if (qemu_init_main_loop(&local_err)) { --=20 1.8.3.1 From nobody Tue Nov 4 19:01:34 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530897888835604.2725153770659; Fri, 6 Jul 2018 10:24:48 -0700 (PDT) Received: from localhost ([::1]:59053 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fbUTQ-0008SH-5Y for importer@patchew.org; Fri, 06 Jul 2018 13:24:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51046) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fbUK4-0001D3-5l for qemu-devel@nongnu.org; Fri, 06 Jul 2018 13:15:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fbUK1-0000ld-Si for qemu-devel@nongnu.org; Fri, 06 Jul 2018 13:15:08 -0400 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]:44159) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fbUK1-0000lO-IC for qemu-devel@nongnu.org; Fri, 06 Jul 2018 13:15:05 -0400 Received: by mail-wr1-x433.google.com with SMTP id r16-v6so4873105wrt.11 for ; Fri, 06 Jul 2018 10:15:05 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id h40-v6sm13784683wrf.40.2018.07.06.10.15.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Jul 2018 10:15:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=euD46aivlqkXiWYSV3eOhFlcwmRL4GFOV7zojuoNsF4=; b=PjvIiZmD8U4S/R68Xq6VLB65IOPpJwt48NlomSYWiguvP/Xe900BmSnO1KoElMVwiQ NTUxfcFa9rW46LsE27njuW4UmohSwrrhYLNIxNnOx4Cq4C4lDoX0g0yGzlE7Su6nWzUF GbqTJqBzZiAR6Ac75AtRlRqNCHs3dAlxyiplQJrYCy9V4z77wvM1ssGXMaKTPEDCMUqz MQzmItD8AVZzhE0PzkhfPf2gHV7kZwlAbjdE0nfSR/rrrJFrkYT6he/+RdGSgcMHMuDW Zf3PtpXGn7tFL95OO8pI3Qv85fxmTi83wumeNuXI7v2MgwoBVKoY7G8Fv6rH3YV60NJF 6nNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=euD46aivlqkXiWYSV3eOhFlcwmRL4GFOV7zojuoNsF4=; b=mW3PWPhneHVMwgos8B9ZrgydaZl02PQMSDOU4RL7iCq/KmXGdQo7OzVdeBJSGoHxIM tGxTIr3Dslohms+PGhmmwa9xMRxrW+zbjD3atMw6dHKbHlE82eaGCQgIR4QD99BtYyi4 pvGbG8QdkR3UQrvJXLCw9t8593Z4dVqmSPVPHfVu5IblxPDy18vtXh+ka0PtaQdU/bhS x+HkNzSD/A/X5i3BAKoOUIOjLWC1vb6iThQ8NjQjHLArVTy62yrpsTJcnjJ2V0G+SgK6 HFaoE2JnkiCRf8eTPOEnqjCw6lJhcf96I11c1AbmDve/r6pfnDvsRil5OU72nd1dDnNR edeg== X-Gm-Message-State: APt69E0BA9GwbKQUsxAThCxFgO0d1eThZL7h0ci1DR7cOYKg0KkAC2D2 cXqvn4VS9siddM5/s5GLvadIqY5g X-Google-Smtp-Source: AAOMgpe5XrE+lmEoHFJ0jaINoZto0ZG59t0dBYRZUDehVZdxn3IE5KK3VYN6O5nbfnkmo05IsfKWSA== X-Received: by 2002:adf:9603:: with SMTP id b3-v6mr8038140wra.253.1530897304367; Fri, 06 Jul 2018 10:15:04 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 6 Jul 2018 19:14:23 +0200 Message-Id: <1530897268-22932-4-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530897268-22932-1-git-send-email-pbonzini@redhat.com> References: <1530897268-22932-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::433 Subject: [Qemu-devel] [PULL 3/8] qtest: Use cpu address space instead of system memory X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Julia Suvorova Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Julia Suvorova Some devices (like nvic in armv7m) are not accessable through address_space_memory, therefore can not be tested with qtest. Signed-off-by: Julia Suvorova Message-Id: <20180702065237.27899-1-jusual@mail.ru> Signed-off-by: Paolo Bonzini --- qtest.c | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/qtest.c b/qtest.c index cbbfb71..69b9e99 100644 --- a/qtest.c +++ b/qtest.c @@ -387,19 +387,23 @@ static void qtest_process_command(CharBackend *chr, g= char **words) =20 if (words[0][5] =3D=3D 'b') { uint8_t data =3D value; - cpu_physical_memory_write(addr, &data, 1); + address_space_rw(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED, + &data, 1, true); } else if (words[0][5] =3D=3D 'w') { uint16_t data =3D value; tswap16s(&data); - cpu_physical_memory_write(addr, &data, 2); + address_space_rw(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED, + (uint8_t *) &data, 2, true); } else if (words[0][5] =3D=3D 'l') { uint32_t data =3D value; tswap32s(&data); - cpu_physical_memory_write(addr, &data, 4); + address_space_rw(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED, + (uint8_t *) &data, 4, true); } else if (words[0][5] =3D=3D 'q') { uint64_t data =3D value; tswap64s(&data); - cpu_physical_memory_write(addr, &data, 8); + address_space_rw(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED, + (uint8_t *) &data, 8, true); } qtest_send_prefix(chr); qtest_send(chr, "OK\n"); @@ -417,18 +421,22 @@ static void qtest_process_command(CharBackend *chr, g= char **words) =20 if (words[0][4] =3D=3D 'b') { uint8_t data; - cpu_physical_memory_read(addr, &data, 1); + address_space_rw(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED, + &data, 1, false); value =3D data; } else if (words[0][4] =3D=3D 'w') { uint16_t data; - cpu_physical_memory_read(addr, &data, 2); + address_space_rw(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED, + (uint8_t *) &data, 2, false); value =3D tswap16(data); } else if (words[0][4] =3D=3D 'l') { uint32_t data; - cpu_physical_memory_read(addr, &data, 4); + address_space_rw(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED, + (uint8_t *) &data, 4, false); value =3D tswap32(data); } else if (words[0][4] =3D=3D 'q') { - cpu_physical_memory_read(addr, &value, 8); + address_space_rw(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED, + (uint8_t *) &value, 8, false); tswap64s(&value); } qtest_send_prefix(chr); @@ -448,7 +456,8 @@ static void qtest_process_command(CharBackend *chr, gch= ar **words) g_assert(len); =20 data =3D g_malloc(len); - cpu_physical_memory_read(addr, data, len); + address_space_rw(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED, + data, len, false); =20 enc =3D g_malloc(2 * len + 1); for (i =3D 0; i < len; i++) { @@ -473,7 +482,8 @@ static void qtest_process_command(CharBackend *chr, gch= ar **words) g_assert(ret =3D=3D 0); =20 data =3D g_malloc(len); - cpu_physical_memory_read(addr, data, len); + address_space_rw(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED, + data, len, false); b64_data =3D g_base64_encode(data, len); qtest_send_prefix(chr); qtest_sendf(chr, "OK %s\n", b64_data); @@ -507,7 +517,8 @@ static void qtest_process_command(CharBackend *chr, gch= ar **words) data[i] =3D 0; } } - cpu_physical_memory_write(addr, data, len); + address_space_rw(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED, + data, len, true); g_free(data); =20 qtest_send_prefix(chr); @@ -529,7 +540,8 @@ static void qtest_process_command(CharBackend *chr, gch= ar **words) if (len) { data =3D g_malloc(len); memset(data, pattern, len); - cpu_physical_memory_write(addr, data, len); + address_space_rw(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED, + data, len, true); g_free(data); } =20 @@ -562,7 +574,8 @@ static void qtest_process_command(CharBackend *chr, gch= ar **words) out_len =3D MIN(out_len, len); } =20 - cpu_physical_memory_write(addr, data, out_len); + address_space_rw(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED, + data, len, true); =20 qtest_send_prefix(chr); qtest_send(chr, "OK\n"); --=20 1.8.3.1 From nobody Tue Nov 4 19:01:34 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530897525520708.5733651895979; Fri, 6 Jul 2018 10:18:45 -0700 (PDT) Received: from localhost ([::1]:59010 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fbUNX-0003Ni-Qr for importer@patchew.org; Fri, 06 Jul 2018 13:18:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51051) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fbUK4-0001D6-7n for qemu-devel@nongnu.org; Fri, 06 Jul 2018 13:15:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fbUK2-0000lo-Lb for qemu-devel@nongnu.org; Fri, 06 Jul 2018 13:15:08 -0400 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:35354) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fbUK2-0000lZ-DK for qemu-devel@nongnu.org; Fri, 06 Jul 2018 13:15:06 -0400 Received: by mail-wm0-x244.google.com with SMTP id v3-v6so11526944wmh.0 for ; Fri, 06 Jul 2018 10:15:06 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id h40-v6sm13784683wrf.40.2018.07.06.10.15.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Jul 2018 10:15:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=DwRVBNuFbiCYw7FLXGfWLmoc3QWixbhcKkDTANVr+/g=; b=jEof/3tNTAdJcf2digLTdXcxj6tdqAR0YKSuRulxuEC+Xh99bgkOkOqmyiUfZe2jJi QqzcjGX7J3WJ+rHAseQ1AiZg5bcsfql9EW7by/T4vIH/t8hqaki6KEcvKA2VZKotCTmG RDX9yNjBt9uJK77DH0PBgdGuQ9Hzt/4QReEDVIqfhGb/LBmCeU0N7PcStymQv6GwicmR Z3SCus0Tc1/jzRmT34rSPY3qs5ImO+QzcTp0X76ObMBYU+MrmvsPfNiffEoNs5ZnfcUv 3xiJP2WopcXWMyt16cX/hGRaznPAh9P0MGNVYiq7Ib0g/+FUz3mTwzzM76Vz7iUQjBmF LFig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=DwRVBNuFbiCYw7FLXGfWLmoc3QWixbhcKkDTANVr+/g=; b=PunpDZAzTZFvlmYwp0wuULAfaC0ftd8z6LsZuNKWULlgu4lVo2FY7GHyoW9/XFIlWN lFA++soAMd+9TfboAauXm4SwMTr3++H6fPKR2ug9NpDBaL6aY7GI+2yhFQznXHtTyP8R B7E2kwyr25ioSS88DUvp4RDSWiATNnS5k8Z+/I8Oqr0dL+jmViFHXsjfu0Pgr+PxI3wW MMNMtq7vDlM9zr/55Q4/Mg5DrwFcGtoYAftj4MaUFBBcfB9j/mK2sDjSDi6TfbJy3rBH t31HSWb11+uzix+UadvgwV+gtwghRtb11Jrx5hID1Lj0b8J1AB+sOwHfc62eTxEm2nhg SPuA== X-Gm-Message-State: APt69E2JM0AWZW3edCcC7vzNDTB+GEOoMw4KUk4/pTi276qpYOk/oPPO nyk4lEja0EUJF6qdgYe88Dv+l6NX X-Google-Smtp-Source: AAOMgpd+VUXgXDe72NFHPGrqxkSvtAIY8JIeckP1Hlk6hYjKMXdto3c9l+pO1DYU5lf1Xifp/YLL5A== X-Received: by 2002:a1c:1183:: with SMTP id 125-v6mr6914363wmr.138.1530897305238; Fri, 06 Jul 2018 10:15:05 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 6 Jul 2018 19:14:24 +0200 Message-Id: <1530897268-22932-5-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530897268-22932-1-git-send-email-pbonzini@redhat.com> References: <1530897268-22932-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::244 Subject: [Qemu-devel] [PULL 4/8] i386: fix '-cpu ?' output for host cpu type X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Greg Kurz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Greg Kurz Since commit d6dcc5583e7, '-cpu ?' shows the description of the X86_CPU_TYPE_NAME("max") for the host CPU model: Enables all features supported by the accelerator in the current host instead of the expected: KVM processor with all supported host features or HVF processor with all supported host features This is caused by the early use of kvm_enabled() and hvf_enabled() in a class_init function. Since the accelerator isn't configured yet, both helpers return false unconditionally. A QEMU binary will only be compiled with one of these accelerators, not both. The appropriate description can thus be decided at build time. Signed-off-by: Greg Kurz Message-Id: <153055056654.212317.4697363278304826913.stgit@bahia.lan> Signed-off-by: Paolo Bonzini --- target/i386/cpu.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index b0b87c3..e0e2f2e 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -2836,13 +2836,13 @@ static void host_x86_cpu_class_init(ObjectClass *oc= , void *data) xcc->host_cpuid_required =3D true; xcc->ordering =3D 8; =20 - if (kvm_enabled()) { - xcc->model_description =3D - "KVM processor with all supported host features "; - } else if (hvf_enabled()) { - xcc->model_description =3D - "HVF processor with all supported host features "; - } +#if defined(CONFIG_KVM) + xcc->model_description =3D + "KVM processor with all supported host features "; +#elif defined(CONFIG_HVF) + xcc->model_description =3D + "HVF processor with all supported host features "; +#endif } =20 static const TypeInfo host_x86_cpu_type_info =3D { --=20 1.8.3.1 From nobody Tue Nov 4 19:01:34 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530897450566172.8017869487387; Fri, 6 Jul 2018 10:17:30 -0700 (PDT) Received: from localhost ([::1]:59009 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fbUML-0002VD-P1 for importer@patchew.org; Fri, 06 Jul 2018 13:17:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51071) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fbUK5-0001DR-25 for qemu-devel@nongnu.org; Fri, 06 Jul 2018 13:15:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fbUK3-0000mF-Qz for qemu-devel@nongnu.org; Fri, 06 Jul 2018 13:15:09 -0400 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:52029) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fbUK3-0000lw-Ju for qemu-devel@nongnu.org; Fri, 06 Jul 2018 13:15:07 -0400 Received: by mail-wm0-x242.google.com with SMTP id s12-v6so15581981wmc.1 for ; Fri, 06 Jul 2018 10:15:07 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id h40-v6sm13784683wrf.40.2018.07.06.10.15.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Jul 2018 10:15:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zPTghbrp0HF5js7WGB76JabqaXSlrR8gV6l9vjWVj6A=; b=QvSawCmP+vxsVsHA9qdZ2crh9SqEM0sArHAPMvYlcN0Tdlf/U18aOQBHZMRQqF0otx OikTE/xThYMeRZAm6nld6V3261kY8bv/huSp14V4V6Ub1zA7d3A1resV2gk9nsO4mtoA vhmsPobuJ7qoiQV3xy2NOSwINGIxVnG3bEd8XLPy7kAv1v6Du5VXkIj0IxEiExjOy9bT kFZVnPiUnvpJXrO9oM/lsh82ktbxpdxZkEjlbfejaueMJql0534cIsSgdpQMnHyVuFrW zVzc1Y/EEU31NifeY7EwJLDq+dylNsRd2h/uaFiRH/SDf2pXUBG1jbhXQYBAKmiRHcUV ljQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=zPTghbrp0HF5js7WGB76JabqaXSlrR8gV6l9vjWVj6A=; b=XOwZ6x5OcLanD95r9hgglqTAPTSKF4PrTIdKwltHh41S+Pg/EdQSrOYJVpmf5v0dZe +VJ20bGfcp2f+Vv0ZLI1iFWvh9YLNafoJNx9h+E0hEBe15Rghw9rDGGZF80D4Qk7G+0d CUJ/nTZxGA2HcyxpPsmmkYVNHbQ5CE7jwVhps8H1QnoIFZICvBIhWr3pG/yicz0G0jv1 PzKNbyJaoSwqmeTbTX1y3o7igGHAZaq+adtvOoznp1S04giHOyXDk+b7mxMes7VwDBYW phEOG0Cu8ybsWVSZC9oyXQ43+13uW+oPPzWJYRcIKd8BNN5VPRSOM/GADatmCIwXg6rH xM8Q== X-Gm-Message-State: APt69E1CQGglJ1Shw247Trr05Qo2W7HkxRHKxOHFh/I+cgW1js1NOiCI CAhPSwR0P8dFYPyh7ejqjmn+Nor8 X-Google-Smtp-Source: AAOMgpfzmGqlDMLpXmUF0rdPYsrnZLv+ruRFIPebT3GSVYPF1qfmj2l8yvhrsvBK5NklQmdToYEJCw== X-Received: by 2002:a1c:f009:: with SMTP id a9-v6mr7303393wmb.104.1530897306390; Fri, 06 Jul 2018 10:15:06 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 6 Jul 2018 19:14:25 +0200 Message-Id: <1530897268-22932-6-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530897268-22932-1-git-send-email-pbonzini@redhat.com> References: <1530897268-22932-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::242 Subject: [Qemu-devel] [PULL 5/8] qemu-char: check errno together with ret < 0 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "xinhua.Cao" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 From: "xinhua.Cao" In the tcp_chr_write function, we checked errno, but errno was not reset before a read or write operation. Therefore, this check of errno's actions is often incorrect after EAGAIN has occurred. we need check errno together with ret < 0. Signed-off-by: xinhua.Cao Message-Id: <20180704033642.15996-1-caoxinhua@huawei.com> Reviewed-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Daniel P. Berrang=C3=A9 Fixes: 9fc53a10f81d3a9027b23fa810147d21be29e614 Signed-off-by: Paolo Bonzini --- chardev/char-socket.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/chardev/char-socket.c b/chardev/char-socket.c index 17519ec..efbad6e 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -134,8 +134,11 @@ static int tcp_chr_write(Chardev *chr, const uint8_t *= buf, int len) s->write_msgfds, s->write_msgfds_num); =20 - /* free the written msgfds in any cases other than errno=3D=3DEAGA= IN */ - if (EAGAIN !=3D errno && s->write_msgfds_num) { + /* free the written msgfds in any cases + * other than ret < 0 && errno =3D=3D EAGAIN + */ + if (!(ret < 0 && EAGAIN =3D=3D errno) + && s->write_msgfds_num) { g_free(s->write_msgfds); s->write_msgfds =3D 0; s->write_msgfds_num =3D 0; --=20 1.8.3.1 From nobody Tue Nov 4 19:01:34 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530897967777830.3419316233533; Fri, 6 Jul 2018 10:26:07 -0700 (PDT) Received: from localhost ([::1]:59071 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fbUUd-0000w4-4k for importer@patchew.org; Fri, 06 Jul 2018 13:26:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51096) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fbUK5-0001GS-UT for qemu-devel@nongnu.org; Fri, 06 Jul 2018 13:15:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fbUK4-0000ms-I3 for qemu-devel@nongnu.org; Fri, 06 Jul 2018 13:15:09 -0400 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:52031) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fbUK4-0000m9-9x for qemu-devel@nongnu.org; Fri, 06 Jul 2018 13:15:08 -0400 Received: by mail-wm0-x244.google.com with SMTP id s12-v6so15582019wmc.1 for ; Fri, 06 Jul 2018 10:15:08 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id h40-v6sm13784683wrf.40.2018.07.06.10.15.06 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Jul 2018 10:15:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=jAGzrVwuskLzhj62inkuuyHcOe4MFXxnwag51F/cI6k=; b=mbbpGxa4pRC2O9FFQpzLxG2ssQM0ICuy8ns4csE999y0h6BLnv4sY/CAaayfIbCC34 zZunARXpWcTXaTHo5maYseTTEps9nEWbZs5FhIajF2CFp9Vf8IBcOApC/80HT9eNID7S tCZkWN0IepmGJtud35RXDxtMKfS5XnXV+6xAFXbuc3fG3EyqYrEvOUbLLIvElTDfqosu cjJidydFJvVl06Ww1r6fK6chVYEPMH08z0QTBy52uXwTam78p2qkHdVrxUzf5Te4q+Qu Dt+FQIODyaO9ww4Vt3JqDrVj3saqoPB2KT8UuSVs6JOR7kBCxLUGw0SG7CeoptO76nST 0dNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=jAGzrVwuskLzhj62inkuuyHcOe4MFXxnwag51F/cI6k=; b=WPeJ7iwwPjiVGjwcDvGwiRAOhwvi7qdPzYpNHoqSutaZYDGLaVx1fPlt5GcmGvM+ya cYKqnvcyWQ8lpmrAfZGnqhs072BJdu+kXy/tvETXGmUJLWyZBfXROSMdsDPqpw6rgtSW XlwJiTPiqyveTgEeJ8VMo+o5dJxiEZbEGGPEMlDVMLjQRgtIS/DIhWVJ6kQMe8TxzKFX /BB4M7UXAH174H84F1ZK+sGb1mz3r4OB1V2I63Jd+xWAuPyWL/+hB+AGXMCw154vQMLN hOib7RjFeEl0ThT0YFJTT3z3HqfHckBLqWL3xFvETMa68RE5NsosjXB4uSqkTzmONz88 91cw== X-Gm-Message-State: APt69E0m3r9m31tHeRJNoLouIHSvbY/ygqIziRVmfOqdqUBqt521HA4Q oA/e7WhklFjneyCjYkl5kmLMiP+s X-Google-Smtp-Source: AAOMgpfdWqb3aGKhmrOLqSm0vMkM8vKj+Ts2la2iO8u3Ty2w4uJFlqLvjIWZ7H5tJezZFk+AsEmt3g== X-Received: by 2002:a1c:7eca:: with SMTP id z193-v6mr6915941wmc.139.1530897307206; Fri, 06 Jul 2018 10:15:07 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 6 Jul 2018 19:14:26 +0200 Message-Id: <1530897268-22932-7-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530897268-22932-1-git-send-email-pbonzini@redhat.com> References: <1530897268-22932-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::244 Subject: [Qemu-devel] [PULL 6/8] pr-manager-helper: fix memory leak on event X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Reported by Coverity. Signed-off-by: Paolo Bonzini --- scsi/pr-manager-helper.c | 1 + 1 file changed, 1 insertion(+) diff --git a/scsi/pr-manager-helper.c b/scsi/pr-manager-helper.c index 519a296..3027dde 100644 --- a/scsi/pr-manager-helper.c +++ b/scsi/pr-manager-helper.c @@ -46,6 +46,7 @@ static void pr_manager_send_status_changed_event(PRManage= rHelper *pr_mgr) if (id) { qapi_event_send_pr_manager_status_changed(id, !!pr_mgr->ioc, &error_abort); + g_free(id); } } =20 --=20 1.8.3.1 From nobody Tue Nov 4 19:01:34 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 153089770371399.50570720358019; Fri, 6 Jul 2018 10:21:43 -0700 (PDT) Received: from localhost ([::1]:59029 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fbUQQ-00060T-MF for importer@patchew.org; Fri, 06 Jul 2018 13:21:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51101) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fbUK6-0001H9-F3 for qemu-devel@nongnu.org; Fri, 06 Jul 2018 13:15:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fbUK5-0000nl-Er for qemu-devel@nongnu.org; Fri, 06 Jul 2018 13:15:10 -0400 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:36739) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fbUK5-0000mx-6z for qemu-devel@nongnu.org; Fri, 06 Jul 2018 13:15:09 -0400 Received: by mail-wm0-x244.google.com with SMTP id s14-v6so15139228wmc.1 for ; Fri, 06 Jul 2018 10:15:09 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id h40-v6sm13784683wrf.40.2018.07.06.10.15.07 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Jul 2018 10:15:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=+Br/NtQF9jrVEo+0S0Ax/D412qjzQYpqRMea5neg5QM=; b=sNJy233H10H9pInA5X9pS86yQ/OR/Odiuao4kI9IoBQAybrU4v53k6dLN36chCRiQI n3HzSwkhC5zhiFqvtLCB9dUGcOu6twCZ1m1SSCiJavj7Lx8GrvrdFKZ8NbsgQBP6iwb4 zbB91dvifrZ0VPm29XEDyuMJDVKGPE3G3ueoD9Yeo8g8R4QBhZzG/HBXeHlC9xViicBc NVx71aQSlR9pGKHKy28Ycy/P94dCuJztWpsm40YhWk/uAyke3eDRMuCYRDvrAZpzJddh kdOxcgGv1eWe/KCmPL1RtWnPVqoX1iFFeBAwnWvMKflK1au9RfAAV8kYOLc9uMG2DCWO alcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=+Br/NtQF9jrVEo+0S0Ax/D412qjzQYpqRMea5neg5QM=; b=PNOQsPuzynD7zpDEoNDAmRGOPTlQ61PBHDpYcz5q+h3QHKxiXLiZEiGwndVbJ25wVY a2gseY25vROMe4f5Csm6x0AI9sZ3hJd+ir4vHfjclYD+ereoqmIMQ+K4r/lMMTLYQaG8 hQUWFb12eEFve0AdG4G8JZwcwYR4OoHmZAfbqTjhU8bnbydXJyk+tQpY6+CKFb0eaIeU gOani0OUFJHz/QcAZuujMJD2xwQ9nx+yforr+vCZp5VXT+/+XclX0LuSkTy2AYbwNh6t nIplCOWfEaDgvbOd0f0THdrkbM6C6YpYs2/OkNkn9WCCE1kKlBSd73umL7YqVCS24tJ/ 5H1w== X-Gm-Message-State: APt69E1m4WqGR+7TO1kPTiMbE2Pw5CG8SdrMTvKB5PIJ0we9Ul7cwjvK hy2d8gk0BRpMb98lrtWWB+sS01pF X-Google-Smtp-Source: AAOMgpeGrYcsi3CIj3RiL8DjbVThtz6AmfPb4h2+ZxoPtSAla/6tiSrRLViuUumEfMG79SXS9CTyrw== X-Received: by 2002:a1c:ee5d:: with SMTP id m90-v6mr6953973wmh.113.1530897308023; Fri, 06 Jul 2018 10:15:08 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 6 Jul 2018 19:14:27 +0200 Message-Id: <1530897268-22932-8-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530897268-22932-1-git-send-email-pbonzini@redhat.com> References: <1530897268-22932-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::244 Subject: [Qemu-devel] [PULL 7/8] ioapic: remove useless lower bounds check X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The vector cannot be negative. Coverity now reports this because it sees an array access before the check, in ioapic_stat_update_irq. Reviewed-by: Peter Xu Signed-off-by: Paolo Bonzini --- hw/intc/ioapic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/intc/ioapic.c b/hw/intc/ioapic.c index b393780..b6896ac 100644 --- a/hw/intc/ioapic.c +++ b/hw/intc/ioapic.c @@ -152,7 +152,7 @@ static void ioapic_set_irq(void *opaque, int vector, in= t level) if (vector =3D=3D 0) { vector =3D 2; } - if (vector >=3D 0 && vector < IOAPIC_NUM_PINS) { + if (vector < IOAPIC_NUM_PINS) { uint32_t mask =3D 1 << vector; uint64_t entry =3D s->ioredtbl[vector]; =20 --=20 1.8.3.1 From nobody Tue Nov 4 19:01:34 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530897639569394.8471076287883; Fri, 6 Jul 2018 10:20:39 -0700 (PDT) Received: from localhost ([::1]:59020 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fbUPL-0004si-3g for importer@patchew.org; Fri, 06 Jul 2018 13:20:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51119) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fbUK7-0001JA-Jh for qemu-devel@nongnu.org; Fri, 06 Jul 2018 13:15:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fbUK6-0000qf-Ip for qemu-devel@nongnu.org; Fri, 06 Jul 2018 13:15:11 -0400 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:53659) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fbUK6-0000oR-By for qemu-devel@nongnu.org; Fri, 06 Jul 2018 13:15:10 -0400 Received: by mail-wm0-x243.google.com with SMTP id b188-v6so15570719wme.3 for ; Fri, 06 Jul 2018 10:15:10 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id h40-v6sm13784683wrf.40.2018.07.06.10.15.08 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Jul 2018 10:15:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=2FEPgev5kcwrP2noABIeJ+Sm41hZx7Ka3ze2dZNiWiI=; b=pe2iw15Bh4QQ/lcaSDIO8U93ky9r1O2yCTTleFzibzwrLO+2Aygo0R6q4uKvP9kkPh WwFyEXRM+BKpEWwtAeRJYd/V/qcZlHpCfLqxCX4hSdpZKqUAJMG19Ft6Pq6HZLlt87/m pyODG+BSDRwZraYypQzdzoZFwJw1hnMo8mW/jvgvpjqu/SS4FZ6SUUFpR9dQb+FpXNpq obUIHZ/7CYkRQX8p0stw3D5Q94ftkvxqhMVitxA/yb1NDqaqitTZvxTv88IDaH9In77x aQ4ODAgdqSwJ7OsMOhbXVPRWCZKJMIoxipn2iy779izSoFofZg1CyEjKUeYr7a6LACig FCvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=2FEPgev5kcwrP2noABIeJ+Sm41hZx7Ka3ze2dZNiWiI=; b=pUXgdn4TyVB7O3uo2yEBjISI5M5Ng9FfrM3lL+6Q8bwPm/z+IJZz56IQMp3BFux/Fz J0iyr2i4rJ6nb7H14Y+Cdg0/YCMkZu9di5seI7HqjDv4z9V6w31DhAZKJ3ST6L6g4Sos NxH5uDW9VJyIf0jKxmtNcfcre04Cr+K4nYHa5FBxcLLuKqFjDFDSLAus74U0PUITg5gX fqEXOAiFA9bV1XmY37/Dh85Vzam1g6Nm9F9O5MHNckYi5L7XvVEIIeOb2eFQAeHDJaua 980L0HEepwcCLaWkeL+SOEf9XtZ4QsIn4IwcOD21L/xizSHTsu58VKh+7gjqiArXtTZG 7itw== X-Gm-Message-State: APt69E2WPN0cpHr8w985PrXdOCLS0z9h2x4ynxaJnMIdckyVbKyxNv0e jc6k955JHlcFvf+8C33+r0JipGMu X-Google-Smtp-Source: AAOMgpctSHPFrevOVkCQJbu7R7q1k6fNNMrMc0hQHBZEKRotMnEeHz8PcgArFSc00/QSslTaURTwfA== X-Received: by 2002:a1c:9809:: with SMTP id a9-v6mr2721778wme.15.1530897309098; Fri, 06 Jul 2018 10:15:09 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 6 Jul 2018 19:14:28 +0200 Message-Id: <1530897268-22932-9-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530897268-22932-1-git-send-email-pbonzini@redhat.com> References: <1530897268-22932-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::243 Subject: [Qemu-devel] [PULL 8/8] checkpatch: handle token pasting better X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The mechanism to find possible type tokens can sometimes be confused and go= into an infinite loop. This happens for example in QEMU for a line that looks like uint## BITS ##_t S =3D _S, T =3D _T; \ uint## BITS ##_t as, at, xs, xt, xd; \ Because the token pasting operator does not have a space before _t, it does= not match $notPermitted. However, (?x) is turned on in the regular expression = for modifiers, and thus ##_t matches the empty string. As a result, annotate_v= alues goes in an infinite loop. The solution is simply to remove token pasting operators from the string be= fore looking for modifiers. In the example above, the string uintBITS_t will be evaluated as a candidate modifier. This is not optimal, but it works as lo= ng as people do not write things like a##s##m, and it fits nicely into sub possible. For a similar reason, \# should be rejected always, even if it is not at end of line or followed by whitespace. The same patch was sent to the Linux kernel mailing list. Reported-by: Aleksandar Markovic Signed-off-by: Paolo Bonzini --- scripts/checkpatch.pl | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 223681b..42e1c50 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -1132,11 +1132,10 @@ sub possible { case| else| asm|__asm__| - do| - \#| - \#\# + do )(?:\s|$)| - ^(?:typedef|struct|enum)\b + ^(?:typedef|struct|enum)\b| + ^\# )}x; warn "CHECK<$possible> ($line)\n" if ($dbg_possible > 2); if ($possible !~ $notPermitted) { @@ -1146,7 +1145,7 @@ sub possible { if ($possible =3D~ /^\s*$/) { =20 } elsif ($possible =3D~ /\s/) { - $possible =3D~ s/\s*$Type\s*//g; + $possible =3D~ s/\s*(?:$Type|\#\#)\s*//g; for my $modifier (split(' ', $possible)) { if ($modifier !~ $notPermitted) { warn "MODIFIER: $modifier ($possible) ($line)\n" if ($dbg_possible); --=20 1.8.3.1