From patchwork Mon Jul 23 20:16:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 947985 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="suXkQ0/j"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZCj40K1Mz9s1x for ; Tue, 24 Jul 2018 06:27:35 +1000 (AEST) Received: from localhost ([::1]:36376 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhQa-0000dA-UC for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 16:27:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40868) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhIU-0001cC-67 for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhIS-0002jm-Do for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:10 -0400 Received: from mail-oi0-x244.google.com ([2607:f8b0:4003:c06::244]:34583) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhIS-0002iY-87; Mon, 23 Jul 2018 16:19:08 -0400 Received: by mail-oi0-x244.google.com with SMTP id 13-v6so3498191ois.1; Mon, 23 Jul 2018 13:19:08 -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=zFzq6Ei3lfnSF0Mmyno6jMb8yhtaZ0caRWnInTl9j2A=; b=suXkQ0/j3h4kE86zPFBoQpmHCCz3ruTL4wGSMG57CgVoQS4iBSnnhNgxPijn3qGFek cVz2YXYX0HW8MPSgBogg+Q4Q6PWYKAo3FEr+sqymQ4LDiHik7RaiCbSOtdYQkXYf4pjp ozOCt+52eHGhRqKN/H3U06eU7FxfAYw+a1FbH8ZlgEoNyMivJ6rh/K62asLiF9mKYQJX bQphx4aJGi9wfPgyYrv+11tszfTNX5BITAkOWleDbnmhagFn+vV6hIkJVbuSHTuEkrM4 +7EDhKnCCcqYDsRJ4ghllgtJyqSZgEEC7zEX+CHKDe6XneGVM3Zp+PVjuPypsj1GEUUF i4wA== 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=zFzq6Ei3lfnSF0Mmyno6jMb8yhtaZ0caRWnInTl9j2A=; b=PcmiTKZrEqcajaL0YHCNEnDs+8WCjQsjaRHO+VqmroKQyCZf+BkuPbAVx3THM+yZ9M UdKtdX1/C6Zz39VWyE73W4oVIuJCSdC0WeO9c1A79bq576pkBku+mzldV5l+eqwN3pig zS3SqnBqiCKpUmU2cyvJwL8s4+3RcP8IUjhWyGBGcZtpXFeM6n/cm376gdTpDXlBSutJ Xv+K+d0Cv7OLbqt+Y27eLU3YNXwpaCACSl/N8pZ3GA975snHtUTcnu5NkebQeJuf3p59 AaY8gyMmJ7QjJqBcf7cHp9owzMIIAA2RjNbpaydDp4FC8osJHtAWavEwGynSkR8e1Nne k+Fw== X-Gm-Message-State: AOUpUlGNoQgQnMoP7Hpb1l1owO5zx+aC+kc/rrxoHl0/58YlarYYAlQY 3RH4wKedHiNnkwd9lSPQDQQfH0zpaR0= X-Google-Smtp-Source: AAOMgpfQ1ETvC3v5WFAuyEbWZ9HbVanpVNlzBVy1y1dggCNnBDhPPyLwpGzR4qPqTiGP8Niis4mbPw== X-Received: by 2002:aca:ea05:: with SMTP id i5-v6mr340436oih.60.1532377147028; Mon, 23 Jul 2018 13:19:07 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id r10-v6sm7202995oif.37.2018.07.23.13.19.05 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:19:05 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:16:10 -0500 Message-Id: <20180723201748.25573-2-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::244 Subject: [Qemu-devel] [PATCH 01/99] tests: fix tpm-crb tpm-tis tests race 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: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Michael Tokarev , qemu-stable@nongnu.org, Stefan Berger Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Marc-André Lureau No need to close the TPM data socket on the emulator end, qemu will close it after a SHUTDOWN. This avoids a race between close() and read() in the TPM data thread. Reported-by: Peter Maydell Signed-off-by: Marc-André Lureau Signed-off-by: Stefan Berger Reviewed-by: Daniel P. Berrangé Signed-off-by: Michael Tokarev (cherry picked from commit 7647d5c6b5e3b3f36a6e0441c81ae3fe797eb233) Signed-off-by: Michael Roth --- tests/tpm-emu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/tpm-emu.c b/tests/tpm-emu.c index 4dada76834..8c2bd53cad 100644 --- a/tests/tpm-emu.c +++ b/tests/tpm-emu.c @@ -125,7 +125,7 @@ void *tpm_emu_ctrl_thread(void *data) case CMD_SHUTDOWN: { ptm_res res = 0; qio_channel_write(ioc, (char *)&res, sizeof(res), &error_abort); - qio_channel_close(s->tpm_ioc, &error_abort); + /* the tpm data thread is expected to finish now */ g_thread_join(s->emu_tpm_thread); break; } From patchwork Mon Jul 23 20:16:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948013 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="IalvqY3/"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZD2j5pnkz9s4V for ; Tue, 24 Jul 2018 06:42:53 +1000 (AEST) Received: from localhost ([::1]:36466 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhfP-0005U0-BX for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 16:42:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41237) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhIs-0001wd-0U for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhIr-0003R4-1H for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:33 -0400 Received: from mail-oi0-x242.google.com ([2607:f8b0:4003:c06::242]:46623) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhIq-0003P7-S6; Mon, 23 Jul 2018 16:19:32 -0400 Received: by mail-oi0-x242.google.com with SMTP id y207-v6so3453892oie.13; Mon, 23 Jul 2018 13:19:32 -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=twUJcmd/N8xwxOSpV2yBQ2E8Ve0Ub9KH6gQGHKk5AdU=; b=IalvqY3/jpY0Kx14rGYzQt23/RVdxDY/9m7k0fa8I6rWp8FyRQiLlZvv2o9g19laGH SAnOKDshGGecbmSjipDZylcX0W/TsPmpvzVPsyz8L5wPh/ZcM7PpaPTbkINmex2lOZsk WqMymMgDQmdT6g2UbpawP+7jz6/V5hjYImW/oypVMMnHifzMLQjvSg2ekmb5eT8wbGs+ Q5FuNGXph2kMVBhqTY/PYshN1Q+9a+rnBbp3uE0iZbKmYnTzaATwUOrr2G14R4SdZrf/ OziGu7ZNTm1cfz5+nbndyI+zS5ycvYmuwxaHa+uRM4e8WzXQhOwa5r4n0PnSxbTLlEJi 9UrA== 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=twUJcmd/N8xwxOSpV2yBQ2E8Ve0Ub9KH6gQGHKk5AdU=; b=H7hGiUhszbOFG2zf84hf5ld68sOcv2qqOzQjgOX/I6erCq/5mwtpUWV2WHiJbiFrfX 6gWx9zR5Yavb6jBk/s5mZKckK1wJjPys3kycp2jj6j5LLUpzyc2LDdBtHEalsi3rW4Qm Z8x2coVXrYbau8X3ptZWi/748CzV1auMJAbKiLuXQMlO0vi6WDskOPAdeqr/LzNwbVMf wgFB5rxVLMdKvTkvc3z9JBf6TwJnly9LSxDqgvIT3pTDFZMhK9ZDAF5cPJGNCATQqbMn 59olGJdqK0s6KWoyCVZZp/SFQkymt1cvxVBPW2qsHOd4UxRyaEm2qADWuUj8JqaK2CVH Nc9w== X-Gm-Message-State: AOUpUlEqou39hKkGHb8Vr2YeEVZMgklyF0X4s0QKlNRrkNXKNeZysFPY 7jSmOoLYfha3/np+6AKz+VUaAudz8TQ= X-Google-Smtp-Source: AAOMgpdDbbjIrlUtUQD0dsLxx0/BYWTvwPDQ3uDclLYQf59SYmhK7Rb5TTUxo4c+5F0gtsrJzft5LA== X-Received: by 2002:aca:7247:: with SMTP id p68-v6mr325197oic.252.1532377171794; Mon, 23 Jul 2018 13:19:31 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id x126-v6sm4994271oig.15.2018.07.23.13.19.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:19:30 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:16:11 -0500 Message-Id: <20180723201748.25573-3-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::242 Subject: [Qemu-devel] [PATCH 02/99] device_tree: Increase FDT_MAX_SIZE to 1 MiB 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: Peter Maydell , qemu-stable@nongnu.org, Geert Uytterhoeven Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Geert Uytterhoeven It is not uncommon for a contemporary FDT to be larger than 64 KiB, leading to failures loading the device tree from sysfs: qemu-system-aarch64: qemu_fdt_setprop: Couldn't set ...: FDT_ERR_NOSPACE Hence increase the limit to 1 MiB, like on PPC. For reference, the largest arm64 DTB created from the Linux sources is ca. 75 KiB large (100 KiB when built with symbols/fixup support). Cc: qemu-stable@nongnu.org Signed-off-by: Geert Uytterhoeven Message-id: 1523541337-23919-1-git-send-email-geert+renesas@glider.be Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell (cherry picked from commit 14ec3cbd7c1e31dca4d23f028100c8f43e156573) Signed-off-by: Michael Roth --- device_tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/device_tree.c b/device_tree.c index 19458b32bf..52c3358a55 100644 --- a/device_tree.c +++ b/device_tree.c @@ -29,7 +29,7 @@ #include -#define FDT_MAX_SIZE 0x10000 +#define FDT_MAX_SIZE 0x100000 void *create_device_tree(int *sizep) { From patchwork Mon Jul 23 20:16:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948016 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="LanEk0u1"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZD5f2CBKz9s4Z for ; Tue, 24 Jul 2018 06:45:26 +1000 (AEST) Received: from localhost ([::1]:36482 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhhr-0007gd-VA for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 16:45:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41645) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhJF-0002QQ-Fm for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhJE-00042V-E8 for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:57 -0400 Received: from mail-oi0-x230.google.com ([2607:f8b0:4003:c06::230]:43119) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhJE-00041G-8t; Mon, 23 Jul 2018 16:19:56 -0400 Received: by mail-oi0-x230.google.com with SMTP id b15-v6so3462720oib.10; Mon, 23 Jul 2018 13:19:56 -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=Xi9VM4wWC1DZONVNw6Nji25v60X7DbGDnigAib39ayk=; b=LanEk0u18qOEZc9/1oRzGFkM6hmND6uRYxtU2gMUJL4m1NBLOHJwUAdq6EnpkdPo+/ i8UTXjaFuJO3mXO8mOBX7PvVUAmxuPQdXa/L7JlcY3L/cAXnK/R8oWK6PEmusq3QZA/t U+n+ptZjJzKhWjumHsY4HvA8rYR+0ldS4nHkO92ps31EivPaX5x1RnUnIpHg2qJ1Cl1V W2tQzjbSFuwnHzxTgJfAlQl2hm/SKdqYwHFdXQAQWd+9VVf4Uhk8RRuWh9L1z/+2YJU6 cqJ9mOX8UPXfLuNEd+VGHY+rGH4yK65jOIv3aIDQPZMcl/IoOAsmVemtV5KJ8LOZYN5U bN+w== 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=Xi9VM4wWC1DZONVNw6Nji25v60X7DbGDnigAib39ayk=; b=j//QFZ2CHQpofKFsSAf+8gprnpMxyCY3u53kxlK8I13pCZculj0dJOPpobEtcTMJNZ xlaE4eqfrRDcvICCl4lZ2JzKLvbcaWG2Am/q99xqx/xK/W/XQwe5dcatcLW6GrHl7EGD 2nQWXQelJZzJ0UaoZNmLYwkW3HptyyMBn2zGX9taLPVlcBAPKmHFS4yFdGrRHraJfhdo QOhIJYWfphRG0Jm0K2w+LYOBhZKzP9vV+8Ggif4pjRRE0lxn9OWb7whEeyJH2ieOwgp9 phvS6Nk+gJHxynMTmBonFwUWOMo+Adi4UYAnEyr9e0/XMPn97BDKiBkgQDwFgOOd2g4W Ap0g== X-Gm-Message-State: AOUpUlHsBmnB8WkxaEdl5HBVQh8m2iXA9gDU+aLI2yiNcyqrZ8loDH89 MEUOsSzbvNHSOT5ot5w11uSNdbDzuJ4= X-Google-Smtp-Source: AAOMgpcyNL0uU1NjLdmh9gnsl/hK/NM4yKjfUU3VsWwM+oUYyiYFOavWFtoofs5uofGmkeD6NjALjg== X-Received: by 2002:aca:e504:: with SMTP id c4-v6mr329724oih.246.1532377195105; Mon, 23 Jul 2018 13:19:55 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id i204-v6sm19818584oia.41.2018.07.23.13.19.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:19:54 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:16:12 -0500 Message-Id: <20180723201748.25573-4-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::230 Subject: [Qemu-devel] [PATCH 03/99] ccid: Fix dwProtocols advertisement of T=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: Gerd Hoffmann , qemu-stable@nongnu.org, Jason Andryuk Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Jason Andryuk Commit d7d218ef02d87c637d20d64da8f575d434ff6f78 attempted to change dwProtocols to only advertise support for T=0 and not T=1. The change was incorrect as it changed 0x00000003 to 0x00010000. lsusb -v in a linux guest shows: "dwProtocols 65536 (Invalid values detected)", though the smart card could still be accessed. Windows 7 does not detect inserted smart cards and logs the the following Error in the Event Logs: Source: Smart Card Service Event ID: 610 Smart Card Reader 'QEMU QEMU USB CCID 0' rejected IOCTL SET_PROTOCOL: Incorrect function. If this error persists, your smart card or reader may not be functioning correctly Command Header: 03 00 00 00 Setting to 0x00000001 fixes the Windows issue. Signed-off-by: Jason Andryuk Message-id: 20180420183219.20722-1-jandryuk@gmail.com Cc: qemu-stable@nongnu.org Signed-off-by: Gerd Hoffmann (cherry picked from commit 0ee86bb6c5beb6498488850104f7557c376d0bef) Signed-off-by: Michael Roth --- hw/usb/dev-smartcard-reader.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard-reader.c index e6468057a0..cabb564788 100644 --- a/hw/usb/dev-smartcard-reader.c +++ b/hw/usb/dev-smartcard-reader.c @@ -329,8 +329,8 @@ static const uint8_t qemu_ccid_descriptor[] = { */ 0x07, /* u8 bVoltageSupport; 01h - 5.0v, 02h - 3.0, 03 - 1.8 */ - 0x00, 0x00, /* u32 dwProtocols; RRRR PPPP. RRRR = 0000h.*/ - 0x01, 0x00, /* PPPP: 0001h = Protocol T=0, 0002h = Protocol T=1 */ + 0x01, 0x00, /* u32 dwProtocols; RRRR PPPP. RRRR = 0000h.*/ + 0x00, 0x00, /* PPPP: 0001h = Protocol T=0, 0002h = Protocol T=1 */ /* u32 dwDefaultClock; in kHZ (0x0fa0 is 4 MHz) */ 0xa0, 0x0f, 0x00, 0x00, /* u32 dwMaximumClock; */ From patchwork Mon Jul 23 20:16:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948041 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="MPeiOo1i"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZDWJ0YvSz9ryn for ; Tue, 24 Jul 2018 07:04:12 +1000 (AEST) Received: from localhost ([::1]:36611 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhi01-0006Sx-L9 for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 17:04:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42053) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhJd-0002qQ-AL for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhJc-0004ef-AU for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:21 -0400 Received: from mail-oi0-x22e.google.com ([2607:f8b0:4003:c06::22e]:45703) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhJb-0004eG-Q4; Mon, 23 Jul 2018 16:20:19 -0400 Received: by mail-oi0-x22e.google.com with SMTP id q11-v6so3449839oic.12; Mon, 23 Jul 2018 13:20:19 -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=2V5LQCR6NqPwZ27Qk2WwhMBjOF4RGe0+VxG6IDpBZv0=; b=MPeiOo1iKQl6xrR/aMkcr6S1Wik9gwudLljrUQPuXKNDxPWbJlaTif0yxPLdfGPrmm izurVH4TVxTqw6yjGhXxY8bGx0iVHn7D9vNA0n1fav0rEJPcn7b0qm8NE4WhBlh1D5pK lz3Pz/rlLiFfi2cMkji3j+uYHktxyysjt2QGFd8MZ5uJoVC24/9fOHWc8rWf133I+ulR PDFhL8VWPsgf3hvI90XRfIZ92Tk7PyzBPr78CZ3jyxORhRTaZAsDDM2AOauijM919Z2S 7qnkX02T2e00mc/Q2R8JB/kWIrY56/EXRS8KtBC/G299X3t2wYKM3O0toMsJmoJR02i3 TuQw== 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=2V5LQCR6NqPwZ27Qk2WwhMBjOF4RGe0+VxG6IDpBZv0=; b=AAThuuA6t06ZGySapM6KznuSmeREQ+vv2sZzDLgOIZt1BN7LFWNqDanShTZ6Ov1xWg 2Q3E4VmYNgi6HvEdne8ZYdbDYgq81uRay5oseRFa9j0sdffNQgvV16HU+SPlPHGSDWrn pO8ZjYy9t/1oKpvATi+fRWKOzp/rV5c4roFPm3jC3lcShrKZ3+L9UnKa5Onhq4Ujb2oq 2hu5z25mdcL6K8S+YYEEVH9k4bR9CTMkaa7+/FtNJ55srGyaVOHb144M/zHir+C9N6wS KOvRNCiihNqS5z1XJ0mpUZimmtK8Ualb1KqD1DlDcQ20atFgmwIKonvOUycH+PvWCrCr pqVQ== X-Gm-Message-State: AOUpUlGZgehQN0Kd/Qff1BKSJaqx9mN9W5ns5ZwstoiGHPZTkVO7duPy m/muBNYxxVsseTF9qvSgXLImpLjnOkM= X-Google-Smtp-Source: AAOMgpcZLxwahDlfXle1OB3jUblXjH+/TcgXJC8+qZ6bOoJ81E7IwrYeUg+t0r8qnksXAjfmabz1IA== X-Received: by 2002:aca:171a:: with SMTP id j26-v6mr279878oii.277.1532377218685; Mon, 23 Jul 2018 13:20:18 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id e125-v6sm9836179oig.4.2018.07.23.13.20.17 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:20:17 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:16:13 -0500 Message-Id: <20180723201748.25573-5-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::22e Subject: [Qemu-devel] [PATCH 04/99] nbd/client: Fix error messages during NBD_INFO_BLOCK_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: , Cc: qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Eric Blake A missing space makes for poor error messages, and sizes can't go negative. Also, we missed diagnosing a server that sends a maximum block size less than the minimum. Fixes: 081dd1fe CC: qemu-stable@nongnu.org Signed-off-by: Eric Blake Message-Id: <20180501154654.943782-1-eblake@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy (cherry picked from commit e475d108f1b3d3163f0affea67cdedbe5fc9752b) Signed-off-by: Michael Roth --- nbd/client.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/nbd/client.c b/nbd/client.c index b9e175d1c2..3523c863fe 100644 --- a/nbd/client.c +++ b/nbd/client.c @@ -435,8 +435,8 @@ static int nbd_opt_go(QIOChannel *ioc, const char *wantname, } be32_to_cpus(&info->min_block); if (!is_power_of_2(info->min_block)) { - error_setg(errp, "server minimum block size %" PRId32 - "is not a power of two", info->min_block); + error_setg(errp, "server minimum block size %" PRIu32 + " is not a power of two", info->min_block); nbd_send_opt_abort(ioc); return -1; } @@ -450,8 +450,8 @@ static int nbd_opt_go(QIOChannel *ioc, const char *wantname, be32_to_cpus(&info->opt_block); if (!is_power_of_2(info->opt_block) || info->opt_block < info->min_block) { - error_setg(errp, "server preferred block size %" PRId32 - "is not valid", info->opt_block); + error_setg(errp, "server preferred block size %" PRIu32 + " is not valid", info->opt_block); nbd_send_opt_abort(ioc); return -1; } @@ -462,6 +462,12 @@ static int nbd_opt_go(QIOChannel *ioc, const char *wantname, return -1; } be32_to_cpus(&info->max_block); + if (info->max_block < info->min_block) { + error_setg(errp, "server maximum block size %" PRIu32 + " is not valid", info->max_block); + nbd_send_opt_abort(ioc); + return -1; + } trace_nbd_opt_go_info_block_size(info->min_block, info->opt_block, info->max_block); break; From patchwork Mon Jul 23 20:16:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948047 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="q2dLIU4O"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZDbQ3khXz9s29 for ; Tue, 24 Jul 2018 07:07:46 +1000 (AEST) Received: from localhost ([::1]:36635 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhi3U-00038v-47 for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 17:07:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42512) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhK2-0003Fk-Pa for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhK0-0004vg-2r for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:46 -0400 Received: from mail-oi0-x244.google.com ([2607:f8b0:4003:c06::244]:38121) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhJz-0004vQ-TL; Mon, 23 Jul 2018 16:20:44 -0400 Received: by mail-oi0-x244.google.com with SMTP id v8-v6so3481528oie.5; Mon, 23 Jul 2018 13:20:43 -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=3t9mtqi73+A00bv4UrwjrhZij7lPYKpQi/9K5Jarv1E=; b=q2dLIU4OsDo0ufUbeHwpAv+QWR574j18gmGmvrmb3w9VT2rS4JjGHb/Lei+Jl5i+A0 zzCDUO6f0g6QbMBenNXNbLhp3d1p5qIhLeHunObpAwDHhk1z6r8m0iDgfwXHhu8oFDzX jXIctC9IeRfa4s515AgiZU/HhF26KTq/Ma7rRqtTKP+dIVkQHWRADzZrHpLNESQWomH0 AzKRxjrLNI8zdERnv2SqoP7rWwk8pcuRtuKh2yqF6qbIRcBRO2n8Ri77KsJPlcKncDzZ at828f3sSa7PN8bckGi82NgpisWJxhWAhm2XKrUM+o00/U1G+WefeDhAfjXewfYeGMPQ PJ+w== 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=3t9mtqi73+A00bv4UrwjrhZij7lPYKpQi/9K5Jarv1E=; b=p9BhYeAj1LzphMLAoHDNxiiT/gvOx9bzDzVD7ImPHTDf6u0c4mfHswuUCdwe+kwWGK r4HEK+I463THbgDLxnV3o6dfUpbd93TTOCCCArx6O8cOQahunZ1Hc86fm0pI04ob4pOA zWpvaP1JyNwYePOI+Z8dQ7GPjUGlaCQeMQ1muQATo2ODPtF+xLtIIGtVJv+GYhR4a//c OIdt2KiFlv+k1rE/ntBZNPTrsDByXUGFtiEsxv59FvSPu65wmQdA6VGJQUiVrHaViNuI tZyJHaLa6JfqQEeFjWTO2jhOz6s6LSpkN3rX7aTJsTGehmrFShmVuDHKDd3bQn2y8VuD JApQ== X-Gm-Message-State: AOUpUlGn8ZbZuHqoWBf6Vd77NAzeQ4pk7Bny1jnDwcQLaDBAV3wbyQUr /vZ5X2SR59kIFb3qVPui57+2ee4vzH34ug== X-Google-Smtp-Source: AAOMgpdKVwzZpzNsGPOCHu406+kjS84MjvS03pWAS2ByCURONNZFoud8oBNPo1Bp3F/ngiDWt4yWFQ== X-Received: by 2002:aca:c7c2:: with SMTP id x185-v6mr289003oif.43.1532377242645; Mon, 23 Jul 2018 13:20:42 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id i204-v6sm19821348oia.41.2018.07.23.13.20.41 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:20:41 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:16:14 -0500 Message-Id: <20180723201748.25573-6-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::244 Subject: [Qemu-devel] [PATCH 05/99] s390-ccw: force diag 308 subcode to unsigned long 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: Thomas Huth , Cornelia Huck , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Cornelia Huck We currently pass an integer as the subcode parameter. However, the upper bits of the register containing the subcode need to be 0, which is not guaranteed unless we explicitly specify the subcode to be an unsigned long value. Fixes: d046c51dad3 ("pc-bios/s390-ccw: Get device address via diag 308/6") Cc: qemu-stable@nongnu.org Signed-off-by: Cornelia Huck Acked-by: Christian Borntraeger Tested-by: Thomas Huth Signed-off-by: Thomas Huth (cherry picked from commit 63d8b5ace31c1e1f3996fe4cd551d6d377594d5a) Signed-off-by: Michael Roth --- pc-bios/s390-ccw/iplb.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pc-bios/s390-ccw/iplb.h b/pc-bios/s390-ccw/iplb.h index 5357a36d51..ded20c834e 100644 --- a/pc-bios/s390-ccw/iplb.h +++ b/pc-bios/s390-ccw/iplb.h @@ -101,10 +101,11 @@ static inline bool manage_iplb(IplParameterBlock *iplb, bool store) { register unsigned long addr asm("0") = (unsigned long) iplb; register unsigned long rc asm("1") = 0; + unsigned long subcode = store ? 6 : 5; asm volatile ("diag %0,%2,0x308\n" : "+d" (addr), "+d" (rc) - : "d" (store ? 6 : 5) + : "d" (subcode) : "memory", "cc"); return rc == 0x01; } From patchwork Mon Jul 23 20:16:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948053 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="kuoJ/fdH"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZDk421H4z9s3N for ; Tue, 24 Jul 2018 07:13:32 +1000 (AEST) Received: from localhost ([::1]:36672 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhi93-0000C9-Rz for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 17:13:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42865) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhKO-0003ck-Rq for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:21:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhKN-0005Ea-T2 for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:21:08 -0400 Received: from mail-oi0-x244.google.com ([2607:f8b0:4003:c06::244]:36735) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhKN-0005EQ-O2; Mon, 23 Jul 2018 16:21:07 -0400 Received: by mail-oi0-x244.google.com with SMTP id n21-v6so3498460oig.3; Mon, 23 Jul 2018 13:21:07 -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=F1nV6cjMRE+5DYKc2RECY4sNdc0eWRoMhLaDTtyuzus=; b=kuoJ/fdHZL2SxXWH+NWRejDTLmhxfLVQOZ7TKfr/RrfnllhcVHMtT3OlcBRtAjGfWS +GmE9Y3kPfYTQk1mJJLs5ijJh3Dfr5vsTbYGaw6W7X46gsVMOtKh4Pupr9PEnRviczIg De+n/qbkENIFD6l+eh3HAxuJdnM6UlO12Qi2Y7eRLhhDX+qm2gR1TDXjypEpcggu935+ 8rAg+32eVDRCqyEZ6sv0qcK+NM4m8XCNwmohy4h8hehxVGDCiVweM+q/TgFOY/iJmN1w AB/PX+pesD/R61GAZMVtIoejdo+9nQkNOCLAZzt02hopDRfmGMCAmlNI+TRHbs3Yjbj+ s+3A== 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=F1nV6cjMRE+5DYKc2RECY4sNdc0eWRoMhLaDTtyuzus=; b=XJpoCfjuMSnLKcooUkRTrUvkKTKtf2x6KznPZZm0CkAOaq+H1BenwC05QBw1SuHpl4 OdQn7TPCJXRGtaYMa8lT9G0FyM8HLbOZUtqNSwvPygh4mX/Twi1HcjXK2Y6HMRYTEKuC iPY8iYUc5S/cUt5U7URiuFU1VEbtZEz7J1Ctsa8O2OeRFoCGN1HA5WN3kLnmWJlwLisy SWwij8BFwJ/pFKE4hK/vi2y2WpegIekqz/JzRrbI+ezpSQdvKMSc3+XHt8yJ9bO4cVUe C1XrBF451bu+/L+IatwjfToDHQO0GiQM2XlpF+fYXYBNECXbD2Sr8cRiQjl6XH+N5CQe VVJA== X-Gm-Message-State: AOUpUlExQrb7V2Tgh8HES25jHveSymPC1+2sUdmg26rnJpyzBUFhqDvL QlhZ6jxaKAJdqAbVApCw4ZwlLfWfqwplMw== X-Google-Smtp-Source: AAOMgpfb4rddck93v5sjNU5ToIERL5tnEm8//2b3fa4UOIG/NrRdjKzTtv8dUuOwQfaLDzw8huZLpQ== X-Received: by 2002:aca:4dca:: with SMTP id a193-v6mr252801oib.343.1532377266618; Mon, 23 Jul 2018 13:21:06 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id e205-v6sm9811592oia.9.2018.07.23.13.21.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:21:05 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:16:15 -0500 Message-Id: <20180723201748.25573-7-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::244 Subject: [Qemu-devel] [PATCH 06/99] tcg/arm: Fix memory barrier encoding 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: Henry Wertz , Richard Henderson , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Henry Wertz I found with qemu 2.11.x or newer that I would get an illegal instruction error running some Intel binaries on my ARM chromebook. On investigation, I found it was quitting on memory barriers. qemu instruction: mb $0x31 was translating as: 0x604050cc: 5bf07ff5 blpl #0x600250a8 After patch it gives: 0x604050cc: f57ff05b dmb ish In short, I found INSN_DMB_ISH (memory barrier for ARMv7) appeared to be correct based on online docs, but due to some endian-related shenanigans it had to be byte-swapped to suit qemu; it appears INSN_DMB_MCR (memory barrier for ARMv6) also should be byte swapped (and this patch does so). I have not checked for correctness of aarch64's barrier instruction. Cc: qemu-stable@nongnu.org Reviewed-by: Peter Maydell Signed-off-by: Henry Wertz Signed-off-by: Richard Henderson (cherry picked from commit 3f814b803797c007abfe5c4041de754e01723031) Signed-off-by: Michael Roth --- tcg/arm/tcg-target.inc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tcg/arm/tcg-target.inc.c b/tcg/arm/tcg-target.inc.c index dc83f3e5be..56a32a470f 100644 --- a/tcg/arm/tcg-target.inc.c +++ b/tcg/arm/tcg-target.inc.c @@ -159,8 +159,8 @@ typedef enum { INSN_STRD_IMM = 0x004000f0, INSN_STRD_REG = 0x000000f0, - INSN_DMB_ISH = 0x5bf07ff5, - INSN_DMB_MCR = 0xba0f07ee, + INSN_DMB_ISH = 0xf57ff05b, + INSN_DMB_MCR = 0xee070fba, /* Architected nop introduced in v6k. */ /* ??? This is an MSR (imm) 0,0,0 insn. Anyone know if this From patchwork Mon Jul 23 20:16:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948061 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="eYtA3MTo"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZDsH0mhrz9s3N for ; Tue, 24 Jul 2018 07:19:47 +1000 (AEST) Received: from localhost ([::1]:36713 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhiF6-0006DJ-Kj for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 17:19:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43170) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhKn-00040Q-Vi for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:21:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhKm-0005RE-VQ for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:21:33 -0400 Received: from mail-oi0-x232.google.com ([2607:f8b0:4003:c06::232]:45719) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhKm-0005QD-Pu; Mon, 23 Jul 2018 16:21:32 -0400 Received: by mail-oi0-x232.google.com with SMTP id q11-v6so3456144oic.12; Mon, 23 Jul 2018 13:21:32 -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=EaTxCD4dCy7sNTik1/TmsBRvMf4jyt0iRialxKCbExs=; b=eYtA3MTolElYKHZ4BtGGqMm6WSEY4LxcE85q9TVdCvBOBAXHnehumEUtQFbMNRVsr/ ntPBo1/ve3A+T4yMVE2UjuMcUhGk65fwSBciK8//uophG9nT4TvTfvxhgXa5eh5mU5pr l3KQyOAjoT/ZxAOzDdBDAIB6BuqiyckhqIav4k/E4zJW+6VNzkZJxIdqU0qtQcXYUD+E 9ajsBTy+RSFaNtQ7wcMnSDdGiXaRQgVzRhDOYnD3IhWluJxd91sMftogGkSI3U6rCh1t iNY15fwHIkIVuMev6LqBWCdrcfyXxZRDCa7qGkEwWBq5+7F/Y62Jj9Cik6CKkV6WNqo4 xFYQ== 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=EaTxCD4dCy7sNTik1/TmsBRvMf4jyt0iRialxKCbExs=; b=uDBhJxJFvBuAwA1oXDiQUsMCeSTAYdlFm4/l+jBe6U7nWYySLRbHlF8hql7G6yS/Q6 vEGAYW+mRscQWrn92uM0k6dC2+1PmCZlT8YRKD3C7BmE6UkN69d3IMQdQdRqELaXLfxM pFB8++oo40b36C3XWmuBbXZ+YeetpSXe0xzQeFAUG1W5oa08FZoYbvQyLqDw/8Tc6IdC qDd/Kt5YcTu2x+9hCIAqmb4st29Nj3JpHc/eC5rrVF/Gg56Ij+eO8yR8EG32bk5danG/ ISLRZ47bI14rmSXcTmj7XakWFSMhX0+dpeM75LnlTevCLa/L4sWNREHPSuiyrJPIwx+o QQ8g== X-Gm-Message-State: AOUpUlFDe3ALwuzqVgmuVujn3rozojawudZh+R0oA51gE0yBKxV6ghvD j7/IMfN/c/cXPdG74LoIRROUz2VK0JYLVg== X-Google-Smtp-Source: AAOMgpcq2OPfOY7pyxTEIIrGj9K40IWKOqVV9rs95BIl0WlbpwozTsErl6y2p2vT/baHnYt81+cmew== X-Received: by 2002:aca:3357:: with SMTP id z84-v6mr321956oiz.49.1532377291653; Mon, 23 Jul 2018 13:21:31 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id m62-v6sm26390868oik.30.2018.07.23.13.21.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:21:30 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:16:16 -0500 Message-Id: <20180723201748.25573-8-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::232 Subject: [Qemu-devel] [PATCH 07/99] target/arm: Implement v8M VLLDM and VLSTM 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: Peter Maydell , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell For v8M the instructions VLLDM and VLSTM support lazy saving and restoring of the secure floating-point registers. Even if the floating point extension is not implemented, these instructions must act as NOPs in Secure state, so they can be used as part of the secure-to-nonsecure call sequence. Fixes: https://bugs.launchpad.net/qemu/+bug/1768295 Cc: qemu-stable@nongnu.org Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20180503105730.5958-1-peter.maydell@linaro.org (cherry picked from commit b1e5336a9899016c53d59eba53ebf6abcc21995c) Signed-off-by: Michael Roth --- target/arm/translate.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/target/arm/translate.c b/target/arm/translate.c index db1ce6510a..64b9bf33af 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -10783,8 +10783,23 @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) /* Coprocessor. */ if (arm_dc_feature(s, ARM_FEATURE_M)) { /* We don't currently implement M profile FP support, - * so this entire space should give a NOCP fault. + * so this entire space should give a NOCP fault, with + * the exception of the v8M VLLDM and VLSTM insns, which + * must be NOPs in Secure state and UNDEF in Nonsecure state. */ + if (arm_dc_feature(s, ARM_FEATURE_V8) && + (insn & 0xffa00f00) == 0xec200a00) { + /* 0b1110_1100_0x1x_xxxx_xxxx_1010_xxxx_xxxx + * - VLLDM, VLSTM + * We choose to UNDEF if the RAZ bits are non-zero. + */ + if (!s->v8m_secure || (insn & 0x0040f0ff)) { + goto illegal_op; + } + /* Just NOP since FP support is not implemented */ + break; + } + /* All other insns: NOCP */ gen_exception_insn(s, 4, EXCP_NOCP, syn_uncategorized(), default_exception_el(s)); break; From patchwork Mon Jul 23 20:16:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948089 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="GmF1nv2q"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZFBn2pwLz9s3N for ; Tue, 24 Jul 2018 07:34:57 +1000 (AEST) Received: from localhost ([::1]:36818 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhiTn-0002qK-2U for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 17:34:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43504) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhLC-0004PZ-OV for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:22:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhLA-0005g4-Vq for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:21:58 -0400 Received: from mail-oi0-x241.google.com ([2607:f8b0:4003:c06::241]:41195) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhLA-0005fr-Pi; Mon, 23 Jul 2018 16:21:56 -0400 Received: by mail-oi0-x241.google.com with SMTP id k12-v6so3472578oiw.8; Mon, 23 Jul 2018 13:21:56 -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=NULqqU/3dIueE3+ZPBvLtCUWVQe7/KOjN1JMityETwE=; b=GmF1nv2qt7ACrGnu/ghrvOkSjwQT5XI7Irx5GOhi9K7eDcektH2npNa2RI3d8sRMbn Z3yDmc7aQNSjFAWbph5IvyXmyH+N79aKSkvzrs7CpZUShiRkNubMpKiCTkvxsVS/cRHT 5Fc8vCQOX0OKaIuhTEVAFhpazoZhoVqOU1DGWzz21OKxNA94BR2aXV/Eqz+7TH52UxIU RrB6AVEUUdg+SfSt3BtsS6RgF9jQp6ag+N4bjOBCNDJ4aWkmw41NZmUBC/4MDI8Nb9fD K+nyFJs8SQ6MN8NdxK6rSj5+8XCFb/G9QbZfdIt/6zQzzsP2Jp9XKcXqXvFbWZ/E07Fb PV5A== 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=NULqqU/3dIueE3+ZPBvLtCUWVQe7/KOjN1JMityETwE=; b=X3iNRwP3WNW6I8Q2hYdG/8w85nWYvC6tgA7klBxMU9R4x5wnIqfLHRw+BXGapSZM3/ dliDGuSEDA5Ny1+8xZYBIKVsGfXbi9OfmMGgIow/ymRM+Ygr002basQ8o4H3lN/rKzxT OGAOE4AXxqVBErfdxkE1ejpO2JMx3hPBxHoK0pfZIt69d0E2zxmV/hp8Otaw5vi8GDR4 e54SA1ueLkUP8USCpk3KLo0PV+kc0DLgl7l8/v7/YAl3JKbw8yRwm+/qQoVKfInm390h E6kS9sCnmVv5jlW1XKALt40bqakoFX1aHq6yBYyc5OIyalHRDhfdRo3szbOpsY6TLQm3 1N8w== X-Gm-Message-State: AOUpUlFSr5JpaShYM40Lndctqft80qBOZtvrqFNXDYKARpp5gsczDzdQ /k0vZ25dRT8ZhYYU4X+9G/y+iQuGJc3Zlw== X-Google-Smtp-Source: AAOMgpeCyS3OHMUlyF1cGeMuzZ1NkegSyWp9D5C6H20KgxP/rPBQSZ/MPX/7R8tsB5+4I8tPP/BlJQ== X-Received: by 2002:aca:3ad4:: with SMTP id h203-v6mr302644oia.294.1532377315565; Mon, 23 Jul 2018 13:21:55 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id j193-v6sm7591528oih.55.2018.07.23.13.21.54 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:21:54 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:16:17 -0500 Message-Id: <20180723201748.25573-9-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::241 Subject: [Qemu-devel] [PATCH 08/99] target/ppc: always set PPC_MEM_TLBIE in pre 2.8 migration hack 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: David Gibson , qemu-stable@nongnu.org, Greg Kurz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Greg Kurz The pseries-2.7 and older machine types require CPUPPCState::insns_flags to be strictly equal between source and destination. This checking is abusive and breaks migration of KVM guests when the host CPU models are different, even if they are compatible enough to allow the guest to run transparently. This buggy behaviour was fixed for pseries-2.8 and we added some hacks to allow backward migration of older machine types. These hacks assume that the CPU belongs to the POWER8 family, which was true for most KVM based setup we cared about at the time. But now POWER9 systems are coming, and backward migration of pre 2.8 guests running in POWER8 architected mode from a POWER9 host to a POWER8 host is broken: qemu-system-ppc64: error while loading state for instance 0x0 of device 'cpu' qemu-system-ppc64: load of migration failed: Invalid argument This happens because POWER9 doesn't set PPC_MEM_TLBIE in insns_flags, while POWER8 does. Let's force PPC_MEM_TLBIE in the migration hack to fix the issue. This is an acceptable hack because these old machine types only support CPU models that do set PPC_MEM_TLBIE. Signed-off-by: Greg Kurz Signed-off-by: David Gibson (cherry picked from commit bce009645b9f1d59195518e35747c8ea30f985f7) Signed-off-by: Michael Roth --- target/ppc/machine.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/target/ppc/machine.c b/target/ppc/machine.c index 0634cdb295..cf44b97ced 100644 --- a/target/ppc/machine.c +++ b/target/ppc/machine.c @@ -200,6 +200,11 @@ static int cpu_pre_save(void *opaque) ; cpu->mig_msr_mask = env->msr_mask & ~metamask; cpu->mig_insns_flags = env->insns_flags & insns_compat_mask; + /* CPU models supported by old machines all have PPC_MEM_TLBIE, + * so we set it unconditionally to allow backward migration from + * a POWER9 host to a POWER8 host. + */ + cpu->mig_insns_flags |= PPC_MEM_TLBIE; cpu->mig_insns_flags2 = env->insns_flags2 & insns_compat_mask2; cpu->mig_nb_BATs = env->nb_BATs; } From patchwork Mon Jul 23 20:16:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 947971 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="U1vGbPBE"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZCbX03sJz9s1x for ; Tue, 24 Jul 2018 06:22:48 +1000 (AEST) Received: from localhost ([::1]:36340 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhLx-0004R9-Fp for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 16:22:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40523) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhI2-0001Ha-NS for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:18:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhI1-00027I-PD for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:18:42 -0400 Received: from mail-oi0-x235.google.com ([2607:f8b0:4003:c06::235]:34553) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhI1-00026J-JY; Mon, 23 Jul 2018 16:18:41 -0400 Received: by mail-oi0-x235.google.com with SMTP id 13-v6so3496091ois.1; Mon, 23 Jul 2018 13:18:41 -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=kzcnaUng3vOHeyfZi/+yG0MMYvHtE1wxhzeRmjRDOz4=; b=U1vGbPBEamP/XUM/5V4EAc4zIVjxKM3kR3WN08uMzv1t6GtcuNsIwwqPsmZQpzSYyZ Lssfpm++/dAZlDRmFOqdE3PmzaAUUGADkGmtjNl9qNAvZI+l04QQW0NN9SYo0GL70TRp qmTaqVQf6VSesaranPh2rRohswqQQexOgm2ELhqWCaXC92tgrpw+sUytZnKnPhT8aVEy l3tLOu37ZUxLEcKuJYD/V/dvzKzGch9LfzvtzQ/GeZ/kxOjA5WhpaQTGY+PkdztMfvyq sl9pu1QNM+pIMDE0vdADsDwv1n8LMfYeCa2hkQN3Jd1iCTK3o7XCL2n/nDuTIn0+8MHE 4Liw== 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=kzcnaUng3vOHeyfZi/+yG0MMYvHtE1wxhzeRmjRDOz4=; b=fFJWK5RvvknwtodAozKvcMuiQc/eKKHZbZnCpQveovJP+RPznruNdui1Dxa6j3Xxew TSMVhCKXWOU8d5aE5HA2t+LCw3jWPzpaCSsHiMEEJyX58kZP4a9jcF++okgbZoo3QFuq BObGJmsCpPeXM/29Yd57HwGhkzpdZjIxPWehRwOlPUwo7i7z499Tk1rvUFxmNGw1IROQ Nd2hxYGXChj5rzUcm4MDg0Rar25/0o7m3ByaSS797e3CybsFavt+2r4/9dYkjoXuXl/r 4SJuBNB4s1tomye4zGZIkTb6vDAlKUpdIHmSwj0FJDtckYf8GH1m/Gh/FRpPwgc+IyRg 9bhg== X-Gm-Message-State: AOUpUlGlj7tgIkz3FeKD8jUdnG8cp9RTyK5m/r5/ig48RalYgqSyN8F4 FALyUX7y1x3mctogqU63m9oynjIHv+Y= X-Google-Smtp-Source: AAOMgpeKL9disj31bZ7zv5PFeal9h0WUFrip/kMWfjU3g5IjK+rMLWeMQAuPSqGX6qDNYynFv4cZ5A== X-Received: by 2002:aca:b208:: with SMTP id b8-v6mr305137oif.144.1532377120369; Mon, 23 Jul 2018 13:18:40 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id 10-v6sm6885081oip.29.2018.07.23.13.18.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:18:39 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:16:19 -0500 Message-Id: <20180723201748.25573-11-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::235 Subject: [Qemu-devel] [PATCH 10/99] qxl: fix local renderer crash 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: qemu-stable@nongnu.org, Gerd Hoffmann Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Gerd Hoffmann Make sure we only ask the spice local renderer for display updates in case we have a valid primary surface. Without that spice is confused and throws errors in case a display update request (triggered by screendump for example) happens in parallel to a mode switch and hits the race window where the old primary surface is gone and the new isn't establisted yet. Cc: qemu-stable@nongnu.org Fixes: https://bugzilla.redhat.com//show_bug.cgi?id=1567733 Signed-off-by: Gerd Hoffmann Reviewed-by: Marc-André Lureau Message-id: 20180427115528.345-1-kraxel@redhat.com (cherry picked from commit 5bd5c27c7d284d01477c5cc022ce22438c46bf9f) Signed-off-by: Michael Roth --- hw/display/qxl-render.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/display/qxl-render.c b/hw/display/qxl-render.c index e7ac4f8789..c62b9a5e75 100644 --- a/hw/display/qxl-render.c +++ b/hw/display/qxl-render.c @@ -169,7 +169,8 @@ void qxl_render_update(PCIQXLDevice *qxl) qemu_mutex_lock(&qxl->ssd.lock); - if (!runstate_is_running() || !qxl->guest_primary.commands) { + if (!runstate_is_running() || !qxl->guest_primary.commands || + qxl->mode == QXL_MODE_UNDEFINED) { qxl_render_update_area_unlocked(qxl); qemu_mutex_unlock(&qxl->ssd.lock); return; From patchwork Mon Jul 23 20:16:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 947960 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="RgdkwIvy"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZCXP67Fzz9s4Z for ; Tue, 24 Jul 2018 06:20:05 +1000 (AEST) Received: from localhost ([::1]:36325 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhJL-0001j2-Bf for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 16:20:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40577) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhI6-0001Jl-Rf for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:18:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhI6-0002En-1T for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:18:46 -0400 Received: from mail-oi0-x243.google.com ([2607:f8b0:4003:c06::243]:40391) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhI5-0002EC-Sg; Mon, 23 Jul 2018 16:18:45 -0400 Received: by mail-oi0-x243.google.com with SMTP id w126-v6so3468410oie.7; Mon, 23 Jul 2018 13:18:45 -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=ZICUuy4x9uAkDkbdFis7h7liTiKVlTMHqHEyCwBU9V8=; b=RgdkwIvyupU/OH7tEAyecE14qCLTjHjUHMqB6oVbgODX42N/5ZGYFJnOO4KSXCQ+qB ntqH+rNOJBqO5NrZN5x4v9ZuFn3aCHfnz0gttZwOShglmb+csXvYXvJDkeblu+vsltAc EjAfJZQ0l7xDXXtkfBwjeRlibNdRQ/aWtp3iJUOAmZRIb7B7kMMpUBRId5dRSibYYrqv R9DyRlKYcd+NG6JHp4p/8M/3ycY/v77fgjlFh2B8Si68EO/zUEyzk8fuS+Ith26LZeGq kKNvgKWAhKIbWfDERJulEG28sRxmZVK+AQDSALKO/lSv8Px52XwbysKT4Yd3DMVuojgY udQQ== 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=ZICUuy4x9uAkDkbdFis7h7liTiKVlTMHqHEyCwBU9V8=; b=pbbrM5JMSXLyQ57zLuAsnGITpaK2YhuGzSty+r8zrfp2BvGaZZRIUZ563dmm/Oy62y 9t0X2ze4b85LrODJnB748m5WAEM619TFaQkAvqhnR8Ypi8QC7dVxXuKT1BTT8hOXaHLl pH6KxeUzK6GWI1NStfoYvkFPXqvO2iSK7pBgbQVEIzmTzymYAfSwkh/QCVl7o+jnda1y KXNs5BI9RRIFQJT0P06F2zEAVk6qDNqM+sLFzzKIoeAU7ek4ku9I+MyPgXsKwwkzbt/+ 7NT6LGFKZu0L39tcd3jmWUaQ/Urvj7akXYqsdl5QAtAtVwwC9TiW3c4xzBlBiSg1jBLP fYeA== X-Gm-Message-State: AOUpUlGOWr7VANXjpk1sDaL0ee/UdazO7GilauK2QhYoAnofMPhZlpSB lopFx0Wm7gMgyOSUAkEVfLQioH01zKU= X-Google-Smtp-Source: AAOMgpexobNyq990+CcuX5mygVZXVdxh9Zeh0APJgc694rq85AQLzN1dQVImoxVYqK4xgoKQD9OJYw== X-Received: by 2002:aca:e184:: with SMTP id y126-v6mr277861oig.313.1532377124759; Mon, 23 Jul 2018 13:18:44 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id u83-v6sm7992788oig.6.2018.07.23.13.18.43 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:18:43 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:16:20 -0500 Message-Id: <20180723201748.25573-12-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::243 Subject: [Qemu-devel] [PATCH 11/99] configure: recognize more rpmbuild macros 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: Paolo Bonzini , Olaf Hering , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Olaf Hering Extend the list of recognized, but ignored options from rpms %configure macro. This fixes build on hosts running SUSE Linux. Cc: qemu-stable@nongnu.org Signed-off-by: Olaf Hering Message-Id: <20180418075045.27393-1-olaf@aepfle.de> Signed-off-by: Paolo Bonzini (cherry picked from commit 181ce1d05c6d4f1c80f0e7ebb41e489c2b541edf) Signed-off-by: Michael Roth --- configure | 2 ++ 1 file changed, 2 insertions(+) diff --git a/configure b/configure index 0a19b033bc..44bf1fef04 100755 --- a/configure +++ b/configure @@ -959,6 +959,8 @@ for opt do ;; --firmwarepath=*) firmwarepath="$optarg" ;; + --host=*|--build=*|\ + --disable-dependency-tracking|\ --sbindir=*|--sharedstatedir=*|\ --oldincludedir=*|--datarootdir=*|--infodir=*|--localedir=*|\ --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*) From patchwork Mon Jul 23 20:16:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 947975 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Iq/Llohf"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZCgr0Nnxz9s1x for ; Tue, 24 Jul 2018 06:26:32 +1000 (AEST) Received: from localhost ([::1]:36365 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhPZ-0008Bc-ML for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 16:26:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40626) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhIB-0001MR-RV for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:18:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhI8-0002JZ-HQ for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:18:51 -0400 Received: from mail-oi0-x234.google.com ([2607:f8b0:4003:c06::234]:37377) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhI8-0002Il-BE; Mon, 23 Jul 2018 16:18:48 -0400 Received: by mail-oi0-x234.google.com with SMTP id k81-v6so3469461oib.4; Mon, 23 Jul 2018 13:18:48 -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=WwITfhk8KiOTFgv9FiELfz5lI90hgvziGAE5hDjMYFE=; b=Iq/LlohfDOQ1MFifJz7wuu6GOrak5uZW09bN/41wsgIcIUhviDX+BM+KXvO8s2YvEV lpLEn/ThFNyjY7dz/R6QsBJ7fWh236JElJP0DUplJyfDzCd2lgJbgMRJp4VPu4l+EUPY K4SqK128MJTzDjbKHRl/1TxUNXvqLMTphk/86r69VjcWBvs/9McEu2gXzfxkE3c6JGzT k2/bEU7XJIEGZJmUrOgewiyJhDNPlTaMm4YViD8X5itjn3TjfE7+Nv47F4HVtu0/LLQR oPv9XmdKNaa/ZUKINrp+l/MOIN2sZAYEGMIvxl4APSSJlBLrDdAE3N9fdFKXU94DtLEC ccIA== 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=WwITfhk8KiOTFgv9FiELfz5lI90hgvziGAE5hDjMYFE=; b=jCN2fx4j6UsVBb3/Jc8Sb0EuGffuULh+Pi2gex6V1bmg5E98n8HxfqGTF0Be/hq61u JoR7C4vakVBgWNuINqVVZju5nHL5aV6m6rp7G9oGEV/AuEmYyYZ7UKsn1hVKvICSLKqm UbXDRNDWlMux4HdK22SOQUglYKgKx99FxtWd7DFDo0UOveglgMWYwp2PsPQbsjTiZSRa xSXAg2wWWA4Pa9XRzzuvzc3tBSgFy8hCd9flY2t8fG8P6NBvCAGX/N0WyDKnANTKYTEq QM/KrMauQsMmB4aAPCdMoAhzHuKev+sR+b4G6Z8oO3r4UopuIS3mctIsJVPU4UwM57Ro u9OA== X-Gm-Message-State: AOUpUlEJV2odJ5CiFH+1iCadtCEoDPs/e5UqBiQbNQQwhpk+kui8ZCpj 4PDusj3zl4iNz/kY6mTyM+okJP7MCI0= X-Google-Smtp-Source: AAOMgpeifXvouXcwvhpnWA85VWAJOSIVqFjRARmZaDm3cccnULqE4kOLS1BWW7EIzHBtyoy/kw+kaA== X-Received: by 2002:aca:dad7:: with SMTP id r206-v6mr255350oig.271.1532377127145; Mon, 23 Jul 2018 13:18:47 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id s142-v6sm8868851oie.48.2018.07.23.13.18.45 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:18:46 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:16:21 -0500 Message-Id: <20180723201748.25573-13-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::234 Subject: [Qemu-devel] [PATCH 12/99] qemu-img: Resolve relative backing paths in rebase 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: qemu-stable@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Max Reitz Currently, rebase interprets a relative path for the new backing image as follows: (1) Open the new backing image with the given relative path (thus relative to qemu-img's working directory). (2) Write it directly into the overlay's backing path field (thus relative to the overlay). If the overlay is not in qemu-img's working directory, both will be different interpretations, which may either lead to an error somewhere (either rebase fails because it cannot open the new backing image, or your overlay becomes unusable because its backing path does not point to a file), or, even worse, it may result in your rebase being performed for a different backing file than what your overlay will point to after the rebase. Fix this by interpreting the target backing path as relative to the overlay, like qemu-img does everywhere else. Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1569835 Cc: qemu-stable@nongnu.org Signed-off-by: Max Reitz Message-id: 20180509182002.8044-2-mreitz@redhat.com Reviewed-by: Eric Blake Signed-off-by: Max Reitz (cherry picked from commit d16699b64671466b42079c45b89127aeea1ca565) Signed-off-by: Michael Roth --- qemu-img.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/qemu-img.c b/qemu-img.c index 855fa52514..15d457d6b8 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -3191,6 +3191,9 @@ static int img_rebase(int argc, char **argv) } if (out_baseimg[0]) { + const char *overlay_filename; + char *out_real_path; + options = qdict_new(); if (out_basefmt) { qdict_put_str(options, "driver", out_basefmt); @@ -3199,8 +3202,26 @@ static int img_rebase(int argc, char **argv) qdict_put_bool(options, BDRV_OPT_FORCE_SHARE, true); } - blk_new_backing = blk_new_open(out_baseimg, NULL, + overlay_filename = bs->exact_filename[0] ? bs->exact_filename + : bs->filename; + out_real_path = g_malloc(PATH_MAX); + + bdrv_get_full_backing_filename_from_filename(overlay_filename, + out_baseimg, + out_real_path, + PATH_MAX, + &local_err); + if (local_err) { + error_reportf_err(local_err, + "Could not resolve backing filename: "); + ret = -1; + g_free(out_real_path); + goto out; + } + + blk_new_backing = blk_new_open(out_real_path, NULL, options, src_flags, &local_err); + g_free(out_real_path); if (!blk_new_backing) { error_reportf_err(local_err, "Could not open new backing file '%s': ", From patchwork Mon Jul 23 20:16:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 947961 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Xul0o68t"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZCXc3CVQz9s1x for ; Tue, 24 Jul 2018 06:20:16 +1000 (AEST) Received: from localhost ([::1]:36326 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhJU-0001oG-DZ for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 16:20:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40630) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhIC-0001Md-3r for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:18:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhIA-0002MI-Ld for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:18:52 -0400 Received: from mail-oi0-x236.google.com ([2607:f8b0:4003:c06::236]:37379) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhIA-0002L7-Ey; Mon, 23 Jul 2018 16:18:50 -0400 Received: by mail-oi0-x236.google.com with SMTP id k81-v6so3469637oib.4; Mon, 23 Jul 2018 13:18:50 -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=BVbHtDrZ8RMjc4fpVRy5sDtoxnrkssQJuqlh4EGzN+o=; b=Xul0o68tHxPaSNNl7+uiAADIvTz1bSmAmJweyj0YnFCh4g+k7LG27qOkJBapQaWhaG 60OIH3YlAZzxBvLN8bbpivlYwUWf9hDXgFpD9tUkvXmTQqyqy19OAm5eoqK77rjteq8F SOivH7+Ibdhpp+fbYDHipiIDQt+Z9iHhVsIgRKn5v3mZaEsgn5FZt3zu0yupimYrZGcm HkCdcw/Ua1rpTMMECWmrzInFBPhSPlGuNMXwCq/LjX3bcYpb+ttC/jvvxdZtP2CHuDbK V+ov2iwhLeRDJlJBkiUXK9jsDhS9a9WYh5RyfnDW1q9ZnpOhd2l17UwgiCZkIMV0LlKc 9j8g== 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=BVbHtDrZ8RMjc4fpVRy5sDtoxnrkssQJuqlh4EGzN+o=; b=JOwzx7JMqmJo7O8pE2DcU+sz9cWtvp7UTjSa5F7eqXm/za1KiOhQ4lfUd4sReqjCXu JDT79+taLIh0oSLCanhAUuq/4BrZ7P3ffEJUWAXue8Kv5HhuioCN3aWupIKPLEN+Z4dd Wvb15kqGHojeIv3Tt4voun0M7iYgEoxC6V7Kea7GbW2voPF8sxSGRPhPr1cjxkHe1jI8 1x/xQ/X6CJjXkPgMdnz9CsMp9Ewyt3PLrDjARXn9gp7TkeJxhz8zKXElvLue8ArM3c2g 55TqrepetrjDXL5GFMIlwWVlDNVbpHJIYcq7rJCKw7w8nZZ7VydeeRbyisu/1tFnAVYu JaVg== X-Gm-Message-State: AOUpUlFbU/Wz9qqv4GlhIZJRGTQc7aE/OIpu1TEo0N5XQNkxisJ0Q4zP JbaNL8UHALe7Q/5On20Bxw4Tmv2z90k= X-Google-Smtp-Source: AAOMgpe8cmNx3VtP3meeG9pl4ichGDjQQ8EmUNXaJqc2ED1UsQweK7w9fc8X46LW5sIXdMzNHXI4fg== X-Received: by 2002:aca:d986:: with SMTP id q128-v6mr244939oig.349.1532377129195; Mon, 23 Jul 2018 13:18:49 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id q206-v6sm6591520oih.46.2018.07.23.13.18.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:18:48 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:16:22 -0500 Message-Id: <20180723201748.25573-14-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::236 Subject: [Qemu-devel] [PATCH 13/99] iotests: Add test for rebasing with relative paths 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: qemu-stable@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Max Reitz Signed-off-by: Max Reitz Reviewed-by: Eric Blake Message-id: 20180509182002.8044-3-mreitz@redhat.com Signed-off-by: Max Reitz (cherry picked from commit 28036a7f7044fddb79819e3c8fcb4ae5605c60e0) Signed-off-by: Michael Roth --- tests/qemu-iotests/024 | 82 ++++++++++++++++++++++++++++++++++++-- tests/qemu-iotests/024.out | 30 ++++++++++++++ 2 files changed, 109 insertions(+), 3 deletions(-) diff --git a/tests/qemu-iotests/024 b/tests/qemu-iotests/024 index e0d77ce2f5..4071ed6093 100755 --- a/tests/qemu-iotests/024 +++ b/tests/qemu-iotests/024 @@ -29,9 +29,14 @@ status=1 # failure is the default! _cleanup() { - _cleanup_test_img - rm -f "$TEST_DIR/t.$IMGFMT.base_old" - rm -f "$TEST_DIR/t.$IMGFMT.base_new" + _cleanup_test_img + rm -f "$TEST_DIR/t.$IMGFMT.base_old" + rm -f "$TEST_DIR/t.$IMGFMT.base_new" + + rm -f "$TEST_DIR/subdir/t.$IMGFMT" + rm -f "$TEST_DIR/subdir/t.$IMGFMT.base_old" + rm -f "$TEST_DIR/subdir/t.$IMGFMT.base_new" + rmdir "$TEST_DIR/subdir" 2> /dev/null } trap "_cleanup; exit \$status" 0 1 2 3 15 @@ -123,6 +128,77 @@ io_pattern readv $((13 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x00 io_pattern readv $((14 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x11 io_pattern readv $((15 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x00 +echo +echo "=== Test rebase in a subdirectory of the working directory ===" +echo + +# Clean up the old images beforehand so they do not interfere with +# this test +_cleanup + +mkdir "$TEST_DIR/subdir" + +# Relative to the overlay +BASE_OLD_OREL="t.$IMGFMT.base_old" +BASE_NEW_OREL="t.$IMGFMT.base_new" + +# Relative to $TEST_DIR (which is going to be our working directory) +OVERLAY_WREL="subdir/t.$IMGFMT" + +BASE_OLD="$TEST_DIR/subdir/$BASE_OLD_OREL" +BASE_NEW="$TEST_DIR/subdir/$BASE_NEW_OREL" +OVERLAY="$TEST_DIR/$OVERLAY_WREL" + +# Test done here: +# +# Backing (old): 11 11 -- 11 +# Backing (new): -- 22 22 11 +# Overlay: -- -- -- -- +# +# Rebasing works, we have verified that above. Here, we just want to +# see that rebasing is done for the correct target backing file. + +TEST_IMG=$BASE_OLD _make_test_img 1M +TEST_IMG=$BASE_NEW _make_test_img 1M +TEST_IMG=$OVERLAY _make_test_img -b "$BASE_OLD_OREL" 1M + +echo + +$QEMU_IO "$BASE_OLD" \ + -c "write -P 0x11 $((0 * CLUSTER_SIZE)) $((2 * CLUSTER_SIZE))" \ + -c "write -P 0x11 $((3 * CLUSTER_SIZE)) $((1 * CLUSTER_SIZE))" \ + | _filter_qemu_io + +$QEMU_IO "$BASE_NEW" \ + -c "write -P 0x22 $((1 * CLUSTER_SIZE)) $((2 * CLUSTER_SIZE))" \ + -c "write -P 0x11 $((3 * CLUSTER_SIZE)) $((1 * CLUSTER_SIZE))" \ + | _filter_qemu_io + +echo + +pushd "$TEST_DIR" >/dev/null +$QEMU_IMG rebase -f "$IMGFMT" -b "$BASE_NEW_OREL" "$OVERLAY_WREL" +popd >/dev/null + +# Verify the backing path is correct +TEST_IMG=$OVERLAY _img_info | grep '^backing file' + +echo + +# Verify the data is correct +$QEMU_IO "$OVERLAY" \ + -c "read -P 0x11 $((0 * CLUSTER_SIZE)) $CLUSTER_SIZE" \ + -c "read -P 0x11 $((1 * CLUSTER_SIZE)) $CLUSTER_SIZE" \ + -c "read -P 0x00 $((2 * CLUSTER_SIZE)) $CLUSTER_SIZE" \ + -c "read -P 0x11 $((3 * CLUSTER_SIZE)) $CLUSTER_SIZE" \ + | _filter_qemu_io + +echo + +# Verify that cluster #3 is not allocated (because it is the same in +# $BASE_OLD and $BASE_NEW) +$QEMU_IMG map "$OVERLAY" | _filter_qemu_img_map + # success, all done echo "*** done" diff --git a/tests/qemu-iotests/024.out b/tests/qemu-iotests/024.out index 33cfaf5cfc..024dc786b3 100644 --- a/tests/qemu-iotests/024.out +++ b/tests/qemu-iotests/024.out @@ -141,4 +141,34 @@ read 65536/65536 bytes at offset 917504 === IO: pattern 0x00 read 65536/65536 bytes at offset 983040 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +=== Test rebase in a subdirectory of the working directory === + +Formatting 'TEST_DIR/subdir/t.IMGFMT.base_old', fmt=IMGFMT size=1048576 +Formatting 'TEST_DIR/subdir/t.IMGFMT.base_new', fmt=IMGFMT size=1048576 +Formatting 'TEST_DIR/subdir/t.IMGFMT', fmt=IMGFMT size=1048576 backing_file=t.IMGFMT.base_old + +wrote 131072/131072 bytes at offset 0 +128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 65536/65536 bytes at offset 196608 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 131072/131072 bytes at offset 65536 +128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 65536/65536 bytes at offset 196608 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +backing file: t.IMGFMT.base_new (actual path: TEST_DIR/subdir/t.IMGFMT.base_new) + +read 65536/65536 bytes at offset 0 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 65536/65536 bytes at offset 65536 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 65536/65536 bytes at offset 131072 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 65536/65536 bytes at offset 196608 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +Offset Length File +0 0x30000 TEST_DIR/subdir/t.IMGFMT +0x30000 0x10000 TEST_DIR/subdir/t.IMGFMT.base_new *** done From patchwork Mon Jul 23 20:16:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 947995 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ulAL0Phd"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZCl42r6pz9s1x for ; Tue, 24 Jul 2018 06:29:20 +1000 (AEST) Received: from localhost ([::1]:36382 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhSH-00023S-KA for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 16:29:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40656) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhID-0001O4-EE for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:18:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhIC-0002Oz-G5 for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:18:53 -0400 Received: from mail-oi0-x231.google.com ([2607:f8b0:4003:c06::231]:35533) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhIC-0002Ny-A2; Mon, 23 Jul 2018 16:18:52 -0400 Received: by mail-oi0-x231.google.com with SMTP id i12-v6so3493817oik.2; Mon, 23 Jul 2018 13:18:52 -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=I1qUby2ZYBVo1DN3ctJZ7vRPrhcaNSDkreQyMnQqsAQ=; b=ulAL0PhdyGM18wBjZVoIyDDZeFoMBjnP0MY/kaefqE4vhOrvAbPN2rA8NiVKvfanVT WsQwUP3QG4avZs6FYo5QLMQN9nmRrlD4sYPKnP9MrVehfI3u9oVXbACZzKp8xkfN2aq+ VNL8AMxqB+TF3vPyzVnlboCAL7sEARu2mG50vMOxI/i2VQw1QgdVkr77f+DcM8sGRi/4 cTdqkF0+Pt5fberBeE3220J7kIh7fIXd7zF7+lM3JIUXwpbHYnAhAkVw7if+SxAwc+Lf xXhjmK7rvJh9Pkj26d4WUYHsU9Af+KcfwhqG8vetRN1/ugEsY6GR3XeyligBTyDmxaTR Qt/w== 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=I1qUby2ZYBVo1DN3ctJZ7vRPrhcaNSDkreQyMnQqsAQ=; b=spELpYXMVuRwFjPw7acoi7FnZbVN1PAqXQk/7b43gOyi9D6XHjWGQkrxdVLQsh5BsS CC8VyY5xkdbyFFQ7dNuo6hW5cAQItukojanWBRGsjOsgoBEVKJoI4AqCzDbDuRpmuumj mH+5CjGlZ15yX7jfKccWdBfKdLbdMxOMolJ0Qwo6jf4eNJynyWkY9X8T+K+mFyoVhpYv WwK6vMPdVW08Nf/TuilyCHvDgvZ77Yi2Qd6NFg5WMAJbvutLbl7YAm54LcNuOLPP0/Yd 87uEx+5rZqE/j7kaX8iHhhMM4vLeASXRs1HT2sZ1tAoD5teklyAUv33DKlVq6PkOx+wJ Qz2w== X-Gm-Message-State: AOUpUlEhnHJ7RCXXKkb3rUMqfYrtHmPrBBdxqahuEBoYpJ/KOBuvdFi5 XhO80qvR5/ew50B1K9XKqehwiRtjXII= X-Google-Smtp-Source: AAOMgpcCypqCTd56x9Zli+bM5D/jVWzjzp1N1hSwwWYRBTBdHZO7kkmZwNrcmZ70fniHUWCgV610Jg== X-Received: by 2002:aca:6b51:: with SMTP id g78-v6mr321745oic.290.1532377131221; Mon, 23 Jul 2018 13:18:51 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id n84-v6sm7548602oif.23.2018.07.23.13.18.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:18:50 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:16:23 -0500 Message-Id: <20180723201748.25573-15-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::231 Subject: [Qemu-devel] [PATCH 14/99] qemu-io: Use purely string blockdev options 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: qemu-stable@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Max Reitz Currently, qemu-io only uses string-valued blockdev options (as all are converted directly from QemuOpts) -- with one exception: -U adds the force-share option as a boolean. This in itself is already a bit questionable, but a real issue is that it also assumes the value already existing in the options QDict would be a boolean, which is wrong. That has the following effect: $ ./qemu-io -r -U --image-opts \ driver=file,filename=/dev/null,force-share=off [1] 15200 segmentation fault (core dumped) ./qemu-io -r -U --image-opts driver=file,filename=/dev/null,force-share=off Since @opts is converted from QemuOpts, the value must be a string, and we have to compare it as such. Consequently, it makes sense to also set it as a string instead of a boolean. Cc: qemu-stable@nongnu.org Signed-off-by: Max Reitz Message-id: 20180502202051.15493-2-mreitz@redhat.com Reviewed-by: Eric Blake Signed-off-by: Max Reitz (cherry picked from commit 2a01c01f9ecb43af4c0a85fe6adc429ffc9c31b5) Signed-off-by: Michael Roth --- qemu-io.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qemu-io.c b/qemu-io.c index e692c555e0..0755a30447 100644 --- a/qemu-io.c +++ b/qemu-io.c @@ -95,12 +95,12 @@ static int openfile(char *name, int flags, bool writethrough, bool force_share, opts = qdict_new(); } if (qdict_haskey(opts, BDRV_OPT_FORCE_SHARE) - && !qdict_get_bool(opts, BDRV_OPT_FORCE_SHARE)) { + && strcmp(qdict_get_str(opts, BDRV_OPT_FORCE_SHARE), "on")) { error_report("-U conflicts with image options"); QDECREF(opts); return 1; } - qdict_put_bool(opts, BDRV_OPT_FORCE_SHARE, true); + qdict_put_str(opts, BDRV_OPT_FORCE_SHARE, "on"); } qemuio_blk = blk_new_open(name, NULL, opts, flags, &local_err); if (!qemuio_blk) { From patchwork Mon Jul 23 20:16:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 947973 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="uVxWp5e5"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZCcq4TPgz9s1x for ; Tue, 24 Jul 2018 06:23:55 +1000 (AEST) Received: from localhost ([::1]:36350 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhN2-0005ZJ-4v for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 16:23:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40704) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhIF-0001QU-Ot for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:18:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhIE-0002Sp-R2 for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:18:55 -0400 Received: from mail-oi0-x229.google.com ([2607:f8b0:4003:c06::229]:33562) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhIE-0002R8-M4; Mon, 23 Jul 2018 16:18:54 -0400 Received: by mail-oi0-x229.google.com with SMTP id l10-v6so3493865oii.0; Mon, 23 Jul 2018 13:18:54 -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=pgeIXs/uHoRVfNlBGmWIXBh9ayrWzXkSCAujd7RNfMM=; b=uVxWp5e5zW+RhGjzovSPNffqXWviFkPiQ8KjkrRUsKtCvFtxBr8uSmscj2Jus79Hpu 8wnDPkrAXdDknRsVerSLBZXZYOAqBnLobuymDlQc8KixCmtgnXN9qcmARlU85HVQ6zMG cr1ehZLoii7N7lixs7E3uaQktadTpyhu6x1uFgn66a0omdBdAqWoxRRnZd+9gUai+nfR qU6pi+Mzpb2xT2VyUrv1/HHZ4bNKWaeofcuzPVEBYMX8GykGvthS1+2XEcE9jCqJMEXE z6Drwk/KJMqlNJGWvl3YDtpgNJaeJ4WJznP+BzRD63A//eM34vKyHxNV0pS8dYi0h44y UBEQ== 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=pgeIXs/uHoRVfNlBGmWIXBh9ayrWzXkSCAujd7RNfMM=; b=hPY20bpqiAdmpZGusrXXAESpE6oqTVntDp0uY8eZ8CaskPv/L6G+ctdmguFeiiHZXV QUPuX0GvOtEgh5EU9HdPIIy7oEC8ObaX1YGuwvwazAGAauHOjB+JZAVzMll72IppvGj6 3QItolzTGLdOAL2Emtlb1j3AyIZScpfgJ28JPvbM0GkYbJt/jekWjjqPv1MFi+MXJ02R B7T1ZG3Snu80F9E8nhUrrFmsXVn78/dbWKpRehdNKPYnpXM3EGQ/PWgKK2hsrTZ/XfzV tK/0PvMn22xm0alBblyc4OLyCdewPwQFpkuAJbJNXeD8azP1ShMAbG3gvqRPmcAlWAGo rNqA== X-Gm-Message-State: AOUpUlFXoeE5npxu+dA5CqRLS+asBTtYO2WuS26tRMYLEkN81tOcP5BU pbyOMrRxnixCff0cxz+NCAASUsU1FvA= X-Google-Smtp-Source: AAOMgpfg8g9nlc4WGCjQSC1V5LjT9cwg5si7vOnDGhD44YDaWw024reLiOQA3X3LKltVB4NXMcAmMw== X-Received: by 2002:aca:4c7:: with SMTP id 190-v6mr292099oie.107.1532377133498; Mon, 23 Jul 2018 13:18:53 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id e125-v6sm9832771oig.4.2018.07.23.13.18.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:18:52 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:16:24 -0500 Message-Id: <20180723201748.25573-16-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::229 Subject: [Qemu-devel] [PATCH 15/99] qemu-img: Use only string options in img_open_opts 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: qemu-stable@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Max Reitz img_open_opts() takes a QemuOpts and converts them to a QDict, so all values therein are strings. Then it may try to call qdict_get_bool(), however, which will fail with a segmentation fault every time: $ ./qemu-img info -U --image-opts \ driver=file,filename=/dev/null,force-share=off [1] 27869 segmentation fault (core dumped) ./qemu-img info -U --image-opts driver=file,filename=/dev/null,force-share=off Fix this by using qdict_get_str() and comparing the value as a string. Also, when adding a force-share value to the QDict, add it as a string so it fits the rest of the dict. Cc: qemu-stable@nongnu.org Signed-off-by: Max Reitz Message-id: 20180502202051.15493-3-mreitz@redhat.com Reviewed-by: Eric Blake Signed-off-by: Max Reitz (cherry picked from commit 4615f87832d2fcb7a544bedeece2741bf8c21f94) Signed-off-by: Michael Roth --- qemu-img.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index 15d457d6b8..b422fda6f3 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -277,12 +277,12 @@ static BlockBackend *img_open_opts(const char *optstr, options = qemu_opts_to_qdict(opts, NULL); if (force_share) { if (qdict_haskey(options, BDRV_OPT_FORCE_SHARE) - && !qdict_get_bool(options, BDRV_OPT_FORCE_SHARE)) { + && strcmp(qdict_get_str(options, BDRV_OPT_FORCE_SHARE), "on")) { error_report("--force-share/-U conflicts with image options"); QDECREF(options); return NULL; } - qdict_put_bool(options, BDRV_OPT_FORCE_SHARE, true); + qdict_put_str(options, BDRV_OPT_FORCE_SHARE, "on"); } blk = blk_new_open(NULL, NULL, options, flags, &local_err); if (!blk) { From patchwork Mon Jul 23 20:16:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 947999 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="vU0ddyY0"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZCpz48j4z9s1x for ; Tue, 24 Jul 2018 06:32:43 +1000 (AEST) Received: from localhost ([::1]:36401 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhVZ-0005Ck-5B for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 16:32:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40734) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhIK-0001VB-Vz for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhIH-0002VO-06 for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:00 -0400 Received: from mail-oi0-x231.google.com ([2607:f8b0:4003:c06::231]:45697) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhIG-0002Uj-PA; Mon, 23 Jul 2018 16:18:56 -0400 Received: by mail-oi0-x231.google.com with SMTP id q11-v6so3442587oic.12; Mon, 23 Jul 2018 13:18:56 -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=DLDFm/vqd0+IU4hiUirr8gQFfB3YVn29b0UJvHRPDtU=; b=vU0ddyY0uYdM/wrNIFgSfNGxM+RR64BeCAtt1rAOJtSXaq68IdR9Tp1UBLJ3ZvwnMr 1349KU30mpHJjf+6iD87VKphKamwlnmAcya52T8l+4prUD4x92DH+H5XMBYe2N83AMn+ QyT8yy7h8c2gXqNDwCCpm65Bd/eQX7kahb5uBl8GpK4CdWU5jNwrEGjdBr+7sQ8+1Dk6 1e/ZcqhKcdDh7Cnzv4gM5pb11hbz+nBs0XfX3CejfYMFfcY+K0qhtqYkPqKH2Kew7u92 6fFUkEyQ48cqE1nmIQPdXeJo0Za737mXqReAlmZRa6DTNAE29zbEZeMkzUud2Rs+h8/A 2Geg== 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=DLDFm/vqd0+IU4hiUirr8gQFfB3YVn29b0UJvHRPDtU=; b=cKYyAgEwyw6pnPni4nJAZXfLElsKdt+p4tOAglgNJKsf8Zpv8KB7n53dfoAMEvB3/A 6kg4TrXxEyuIUEpb4GISwPGWP6X9GCTOG1oDSZVXN9YnUndPnCWZnKV2eI01l9NozLLk PJ6LhMWUFmtbTZ2xEZ9kuCls+J3muM326sKPA23M4wuRGzJPf3MmuUW13/CeKUUUbXC6 sDWe6UZwBUPM4JbH9pRgmwpMlV8MeuFRh4vJ2gS4pUYBcXUH2GtD9kr+1Gcit/Fr68xa 23MjTT1z1p+7+fmUUJtR8E4vgVcexGvZyvO0UtLfpUUoHQwxAIbhg1Bbf0XiAoW0xBGd eCog== X-Gm-Message-State: AOUpUlEbcdEFiMt6ZVhFjnOdajcy817wLeJfx2i97t+OZpmhIb/khjRs dzPO/P4WCopch2BNxK5WMOaToFVmSFo= X-Google-Smtp-Source: AAOMgpfoq0cR0TroD2QZ7ln8atkSHnH5VhGqJGrxA9RK2zCHu4+WVHqfOMMASHsuGDUR6m/Ageed9g== X-Received: by 2002:aca:1719:: with SMTP id j25-v6mr304784oii.138.1532377135626; Mon, 23 Jul 2018 13:18:55 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id m203-v6sm25490867oig.42.2018.07.23.13.18.54 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:18:54 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:16:25 -0500 Message-Id: <20180723201748.25573-17-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::231 Subject: [Qemu-devel] [PATCH 16/99] iotests: Add test for -U/force-share conflicts 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: qemu-stable@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Max Reitz Signed-off-by: Max Reitz Message-id: 20180502202051.15493-4-mreitz@redhat.com Reviewed-by: Eric Blake Signed-off-by: Max Reitz (cherry picked from commit 4e7d73c5fbd97e55ffe5af02f24d1f7dbe3bbf20) Signed-off-by: Michael Roth --- tests/qemu-iotests/153 | 17 +++++++++++++++++ tests/qemu-iotests/153.out | 16 ++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/tests/qemu-iotests/153 b/tests/qemu-iotests/153 index a0fd815483..ec508c758f 100755 --- a/tests/qemu-iotests/153 +++ b/tests/qemu-iotests/153 @@ -242,6 +242,23 @@ _run_cmd $QEMU_IO "${TEST_IMG}" -c 'write 0 512' _cleanup_qemu +echo +echo "== Detecting -U and force-share conflicts ==" + +echo +echo 'No conflict:' +$QEMU_IMG info -U --image-opts driver=null-co,force-share=on +echo +echo 'Conflict:' +$QEMU_IMG info -U --image-opts driver=null-co,force-share=off + +echo +echo 'No conflict:' +$QEMU_IO -c 'open -r -U -o driver=null-co,force-share=on' +echo +echo 'Conflict:' +$QEMU_IO -c 'open -r -U -o driver=null-co,force-share=off' + # success, all done echo "*** done" rm -f $seq.full diff --git a/tests/qemu-iotests/153.out b/tests/qemu-iotests/153.out index bb721cb747..2510762ba1 100644 --- a/tests/qemu-iotests/153.out +++ b/tests/qemu-iotests/153.out @@ -399,4 +399,20 @@ Is another process using the image? Closing the other _qemu_io_wrapper TEST_DIR/t.qcow2 -c write 0 512 + +== Detecting -U and force-share conflicts == + +No conflict: +image: null-co:// +file format: null-co +virtual size: 1.0G (1073741824 bytes) +disk size: unavailable + +Conflict: +qemu-img: --force-share/-U conflicts with image options + +No conflict: + +Conflict: +-U conflicts with image options *** done From patchwork Mon Jul 23 20:16:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 947974 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="uOFdyrn8"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZCd03l18z9s1x for ; Tue, 24 Jul 2018 06:24:04 +1000 (AEST) Received: from localhost ([::1]:36351 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhNC-0005mt-3b for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 16:24:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40731) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhIK-0001V8-V1 for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhIJ-0002Xf-Ba for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:00 -0400 Received: from mail-oi0-x22d.google.com ([2607:f8b0:4003:c06::22d]:46724) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhIJ-0002XD-5J; Mon, 23 Jul 2018 16:18:59 -0400 Received: by mail-oi0-x22d.google.com with SMTP id y207-v6so3451290oie.13; Mon, 23 Jul 2018 13:18:59 -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=kz/tVu0ffHPmXgxDSDXSCQxwhmehNwIUgZSrJyQzPWo=; b=uOFdyrn8Z/QRRk6SFiN9AIhzf4Ug02yTZy2uhxaZgYKwgz/WBZ7BO/cWmSABz9OQb8 f4/bh4Fh+H97ELCFzEimNX09JW85D3Sp3B5EDWom5KyZe+NKg37LwsttjXUX/1Lf4j3A OWZc9S4AeAGbLR9jE8nnpRq/QA0lXpohjvjRF14jJvsWbt3nmbJG9/tDGUh0kI763NdV CxatJrTfvgE10GR63eWD2Yk341xr758FsicnBHj2ta1ffuD2reVWR/0k+mY+u5YA0SNw wzeHS/rlv9y8QD9HNf5hLpbaUZJF1UDmLScSrahfSs976TRlMVpesEdyeKrSnYqw/SkS uggA== 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=kz/tVu0ffHPmXgxDSDXSCQxwhmehNwIUgZSrJyQzPWo=; b=sTNAINXFVfuodxbWwpOQNqq3tOucS+7jH+IBxzD7W5vlobwZH6wpuqbFkE3qQi4K0T X+CGiAxu/XLEAbwrnjU+5GZ+hXrBxFipN2KFFBPpMh66MgrhfwdhP1OqrfH8nb/HyC79 BG/MHjvf50iMngLvsgkCpckL06/xkw9Rdae+GALmDffdq1VLBpwOL9eOGzQkgoz7BjIb Dgbu04POQd8/HRBuyWWLP/Oz/MrQWy3DAn7DwrIPcJqyJSYzJAY+NHdzF5SQvzpVoekX rpFjxOLuF6mOHeqA1a0Z4oK586gdwus88dACNiKlKmxk+ONo7izd9MwhZuXOZREJiNYi fAeg== X-Gm-Message-State: AOUpUlHcQSj5K+KY+DJ3YEdHX3b1A24A/xXYRv4Au0ljhXsmogU7b9vL ib9EBhYION4XjNB8lZootajlNlIPmVY= X-Google-Smtp-Source: AAOMgpfeHCSgXsomHZpCOzkEO9WUWHJkmLnzDXGgsgPqiQvcvC0uIB3uo0w/wgexmxHH2bCZ9cOLhw== X-Received: by 2002:aca:3507:: with SMTP id c7-v6mr343901oia.46.1532377138013; Mon, 23 Jul 2018 13:18:58 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id o125-v6sm11680975oig.44.2018.07.23.13.18.56 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:18:56 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:16:26 -0500 Message-Id: <20180723201748.25573-18-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::22d Subject: [Qemu-devel] [PATCH 17/99] lm32: take BQL before writing IP/IM register 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: Michael Walle , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Michael Walle Writing to these registers may raise an interrupt request. Actually, this prevents the milkymist board from starting. Cc: qemu-stable@nongnu.org Signed-off-by: Michael Walle Tested-by: Philippe Mathieu-Daudé Reviewed-by: Alex Bennée (cherry picked from commit 81e9cbd0ca1131012b058df6804b1f626a6b730c) Signed-off-by: Michael Roth --- target/lm32/op_helper.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/target/lm32/op_helper.c b/target/lm32/op_helper.c index 577f8306e3..234d55e056 100644 --- a/target/lm32/op_helper.c +++ b/target/lm32/op_helper.c @@ -102,12 +102,16 @@ void HELPER(wcsr_dc)(CPULM32State *env, uint32_t dc) void HELPER(wcsr_im)(CPULM32State *env, uint32_t im) { + qemu_mutex_lock_iothread(); lm32_pic_set_im(env->pic_state, im); + qemu_mutex_unlock_iothread(); } void HELPER(wcsr_ip)(CPULM32State *env, uint32_t im) { + qemu_mutex_lock_iothread(); lm32_pic_set_ip(env->pic_state, im); + qemu_mutex_unlock_iothread(); } void HELPER(wcsr_jtx)(CPULM32State *env, uint32_t jtx) From patchwork Mon Jul 23 20:16:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 947977 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="W/wDlnej"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZChR1809z9s4Z for ; Tue, 24 Jul 2018 06:27:03 +1000 (AEST) Received: from localhost ([::1]:36373 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhQ4-0000AL-Le for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 16:27:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40767) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhIM-0001X2-Uv for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhIL-0002an-Ev for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:02 -0400 Received: from mail-oi0-x235.google.com ([2607:f8b0:4003:c06::235]:46732) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhIL-0002Zd-8P; Mon, 23 Jul 2018 16:19:01 -0400 Received: by mail-oi0-x235.google.com with SMTP id y207-v6so3451459oie.13; Mon, 23 Jul 2018 13:19:01 -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=w6rthY66HSu0q2eoXSyGNZPu3utRhfMXTLBgJTlEVnw=; b=W/wDlnejvm722ztUQ7Re5GIYtLImwCPu55MkzqOiLqL4I6+hG12IPYY83jEf395aHy NOZGIV6+AcRHXXKDLpMVtSnjFjG92CAw8X6tjrc9jjM5M7IswHHUdrSTz4EGcrX9WTes GAxLugPmB+ObNfs51zLcRMfBFzdwVHQxA33wwOYH/K66dqUp7/laeeFNs0BAaKiC+m0n moWAPA+y6/VIBhMXmgTuiu98NdJML+N7LSIn2XWGwQIhmXElwUxlZkd9lAnWRQCqAcU9 Q9kkQZj5JErGrdX0tNdmcI8hefxP0cgtTB3Torr1AuIOErtXc6MKbRp0OPQwzArF38Xk 7Maw== 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=w6rthY66HSu0q2eoXSyGNZPu3utRhfMXTLBgJTlEVnw=; b=Za/E/EhPOCYLw+FDgxEXY/7I0RL6lzQtg/3CQQOT7ia/n31ANUWs9PGgUkUbYC0Ctw l23AQ6DqZ6EuemaC/IxuxnDYmiQLdmGAVtPyuGDJRfcjGoOH+Q5X+caZa0G6o4T4ItHI 9yl0w11rWXTqObdDJcUT2aDdil/NMDWLE3y9PW3d194HUzGst1/gAq6aG5FA//VRyy8A v9C/WTDqIxQVLhdY2/B63DSqqh8Tal2kiCZzC983b0A1x4rTgzhEAvZGCjg+sYunEsAC 6huyK8oI4uENqwnppqEZu0TOnolCgisido0K8Cs4l4cB4Y1i2GrmIb5JMzJBxfeAXNi4 Qf6Q== X-Gm-Message-State: AOUpUlG64vju/g4s1jyCDhL3GUoQHBMDS2oDDBHa1WlUdnisbTrS6/EB ux7sA7tbUThQNNMJxWcbLIFsNzRH6Z8= X-Google-Smtp-Source: AAOMgpdiLAmKELxDrod+KEDvdkOI5zbGGROF4z9XBJ+To4iO3nixkiBuV49Gf6Qdt7jgCVTqDcLeCQ== X-Received: by 2002:aca:e142:: with SMTP id y63-v6mr335842oig.128.1532377140145; Mon, 23 Jul 2018 13:19:00 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id x23-v6sm6180815oie.0.2018.07.23.13.18.58 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:18:59 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:16:27 -0500 Message-Id: <20180723201748.25573-19-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::235 Subject: [Qemu-devel] [PATCH 18/99] raw: Check byte range uniformly 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: Fam Zheng , qemu-stable@nongnu.org, Stefan Hajnoczi Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Fam Zheng We don't verify the request range against s->size in the I/O callbacks except for raw_co_pwritev. This is inconsistent (especially for raw_co_pwrite_zeroes and raw_co_pdiscard), so fix them, in the meanwhile make the helper reusable by the coming new callbacks. Note that in most cases the block layer already verifies the request byte range against our reported image length, before invoking the driver callbacks. The exception is during image creating, after blk_set_allow_write_beyond_eof(blk, true) is called. But in that case, the requests are not directly from the user or guest. So there is no visible behavior change in adding the check code. The int64_t -> uint64_t inconsistency, as shown by the type casting, is pre-existing due to the interface. Reviewed-by: Stefan Hajnoczi Reviewed-by: Eric Blake Signed-off-by: Fam Zheng Message-id: 20180601092648.24614-3-famz@redhat.com Signed-off-by: Stefan Hajnoczi (cherry picked from commit 384455385248762e74a080978f18f0c8f74757fe) Signed-off-by: Michael Roth --- block/raw-format.c | 64 ++++++++++++++++++++++++++++------------------ 1 file changed, 39 insertions(+), 25 deletions(-) diff --git a/block/raw-format.c b/block/raw-format.c index a378547c99..17b9d4e052 100644 --- a/block/raw-format.c +++ b/block/raw-format.c @@ -167,16 +167,37 @@ static void raw_reopen_abort(BDRVReopenState *state) state->opaque = NULL; } +/* Check and adjust the offset, against 'offset' and 'size' options. */ +static inline int raw_adjust_offset(BlockDriverState *bs, uint64_t *offset, + uint64_t bytes, bool is_write) +{ + BDRVRawState *s = bs->opaque; + + if (s->has_size && (*offset > s->size || bytes > (s->size - *offset))) { + /* There's not enough space for the write, or the read request is + * out-of-range. Don't read/write anything to prevent leaking out of + * the size specified in options. */ + return is_write ? -ENOSPC : -EINVAL;; + } + + if (*offset > INT64_MAX - s->offset) { + return -EINVAL; + } + *offset += s->offset; + + return 0; +} + static int coroutine_fn raw_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags) { - BDRVRawState *s = bs->opaque; + int ret; - if (offset > UINT64_MAX - s->offset) { - return -EINVAL; + ret = raw_adjust_offset(bs, &offset, bytes, false); + if (ret) { + return ret; } - offset += s->offset; BLKDBG_EVENT(bs->file, BLKDBG_READ_AIO); return bdrv_co_preadv(bs->file, offset, bytes, qiov, flags); @@ -186,23 +207,11 @@ static int coroutine_fn raw_co_pwritev(BlockDriverState *bs, uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags) { - BDRVRawState *s = bs->opaque; void *buf = NULL; BlockDriver *drv; QEMUIOVector local_qiov; int ret; - if (s->has_size && (offset > s->size || bytes > (s->size - offset))) { - /* There's not enough space for the data. Don't write anything and just - * fail to prevent leaking out of the size specified in options. */ - return -ENOSPC; - } - - if (offset > UINT64_MAX - s->offset) { - ret = -EINVAL; - goto fail; - } - if (bs->probed && offset < BLOCK_PROBE_BUF_SIZE && bytes) { /* Handling partial writes would be a pain - so we just * require that guests have 512-byte request alignment if @@ -237,7 +246,10 @@ static int coroutine_fn raw_co_pwritev(BlockDriverState *bs, uint64_t offset, qiov = &local_qiov; } - offset += s->offset; + ret = raw_adjust_offset(bs, &offset, bytes, true); + if (ret) { + goto fail; + } BLKDBG_EVENT(bs->file, BLKDBG_WRITE_AIO); ret = bdrv_co_pwritev(bs->file, offset, bytes, qiov, flags); @@ -267,22 +279,24 @@ static int coroutine_fn raw_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, int bytes, BdrvRequestFlags flags) { - BDRVRawState *s = bs->opaque; - if (offset > UINT64_MAX - s->offset) { - return -EINVAL; + int ret; + + ret = raw_adjust_offset(bs, (uint64_t *)&offset, bytes, true); + if (ret) { + return ret; } - offset += s->offset; return bdrv_co_pwrite_zeroes(bs->file, offset, bytes, flags); } static int coroutine_fn raw_co_pdiscard(BlockDriverState *bs, int64_t offset, int bytes) { - BDRVRawState *s = bs->opaque; - if (offset > UINT64_MAX - s->offset) { - return -EINVAL; + int ret; + + ret = raw_adjust_offset(bs, (uint64_t *)&offset, bytes, true); + if (ret) { + return ret; } - offset += s->offset; return bdrv_co_pdiscard(bs->file->bs, offset, bytes); } From patchwork Mon Jul 23 20:16:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 947978 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="DszBFcI6"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZChY3fdsz9s1x for ; Tue, 24 Jul 2018 06:27:09 +1000 (AEST) Received: from localhost ([::1]:36374 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhQB-0000F5-4D for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 16:27:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40813) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhIP-0001YU-0E for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhIN-0002dk-S3 for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:04 -0400 Received: from mail-oi0-x243.google.com ([2607:f8b0:4003:c06::243]:46047) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhIN-0002cn-M7; Mon, 23 Jul 2018 16:19:03 -0400 Received: by mail-oi0-x243.google.com with SMTP id q11-v6so3443174oic.12; Mon, 23 Jul 2018 13:19: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=ftGOhhcn7ObZzaE7x1ZddM4UpJ/3/o81C6JlJyzLlSo=; b=DszBFcI6i6+VU56TAttxR0GSMDiXF3FU1XptxlcKrzmnnydhDvQHN7YH5kVRnFAl1Y i4pfW1m0E6MMNqH6cUJxh6v3xGQwk293SW944brDmvmXlh8tPQ8EIH1Y/9thXXW0p7l8 FyZ4iV6WBz2ePdVhE+4H33cSrCGXsYZ0uBjaclAesmtfF2nHKMQLQ3kczpZ++vVdx9Sr I6q7aNZc6LR0JUsD0x+p9mWn5t7UJebgJ3jKNGzcPJ8GqgB/x8Ofp0/IZnkxt8AxR0m8 N0o3no90DEivkaGNmu3XoBFYTdPGrtkPwHUaXFuFi8780WSSw3cyI/ksWs0HIWidPHms vKKQ== 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=ftGOhhcn7ObZzaE7x1ZddM4UpJ/3/o81C6JlJyzLlSo=; b=KaR4CwGGBQPGSm3n8ZnzfoJkYzuDWBW9SP5y/UtpNDmtJ4YtHcZ1uBuFn43BosIFD2 BDBopcU7r/UaOqL5BXDIryI+56EcnXdDJtsEfBlvGYFX410F64Gy+7+XjQsL2RcLLEON 4aBawJE8Dg7SsyTOeYCYLEQftmXhzSa8O+KxU/ELsP6W2E+0LptX8ze2vYC0muJZuRCb dkx5y6hZX7h8Aonq+Bq7e4eK6APXJih4EkTlGa7Wie2PxVb8jyxU1LDntbceV2mhxm/C PpRivvg7w3+oIyetBd04S/VyX/BdiySkMuyWco/cxGoydbjVEh7VCx3X4LIjiYMMdHOj gx6g== X-Gm-Message-State: AOUpUlET4onQLJtQq0fDAfAarVAY1OCZSBnmvNHQMyzORCwSjzt2KRy/ 2wIe7D1QEQ9/51KU+AnWrukrc3K6UfM= X-Google-Smtp-Source: AAOMgpcH35cy71ENx3m7/v5Ns/E5dpV8dbwaYn3m7zUgs/soiXei+HZvp5fDsy1cVkwTfEm8FqLVpw== X-Received: by 2002:aca:5282:: with SMTP id g124-v6mr278321oib.241.1532377142547; Mon, 23 Jul 2018 13:19:02 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id q18-v6sm1078208oic.18.2018.07.23.13.19.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:19:01 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:16:28 -0500 Message-Id: <20180723201748.25573-20-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::243 Subject: [Qemu-devel] [PATCH 19/99] s390x/css: disabled subchannels cannot be status pending 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: Cornelia Huck , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Cornelia Huck The 3270 code will try to post an attention interrupt when the 3270 emulator (e.g. x3270) attaches. If the guest has not yet enabled the subchannel for the 3270 device, we will present a spurious cc 1 (status pending) when it uses msch on it later on, e.g. when trying to enable the subchannel. To fix this, just don't do anything in css_conditional_io_interrupt() if the subchannel is not enabled. The 3270 code will work fine with that, and the other user of this function (virtio-ccw) never attempts to post an interrupt for a disabled device to begin with. CC: qemu-stable@nongnu.org Reported-by: Thomas Huth Tested-by: Thomas Huth Acked-by: Christian Borntraeger Acked-by: Halil Pasic Reviewed-by: David Hildenbrand Signed-off-by: Cornelia Huck (cherry picked from commit 6e9c893ecd00afd5344c35d0d0ded50eaa0938f6) Signed-off-by: Michael Roth --- hw/s390x/css.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hw/s390x/css.c b/hw/s390x/css.c index 301bf1772f..56c3fa8c89 100644 --- a/hw/s390x/css.c +++ b/hw/s390x/css.c @@ -616,6 +616,14 @@ void css_inject_io_interrupt(SubchDev *sch) void css_conditional_io_interrupt(SubchDev *sch) { + /* + * If the subchannel is not enabled, it is not made status pending + * (see PoP p. 16-17, "Status Control"). + */ + if (!(sch->curr_status.pmcw.flags & PMCW_FLAGS_MASK_ENA)) { + return; + } + /* * If the subchannel is not currently status pending, make it pending * with alert status. From patchwork Mon Jul 23 20:16:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 947996 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="fwaS+lge"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZCll19yHz9s4Z for ; Tue, 24 Jul 2018 06:29:53 +1000 (AEST) Received: from localhost ([::1]:36385 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhSo-0002Sl-An for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 16:29:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40873) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhIU-0001cF-7Y for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhIQ-0002g9-1z for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:10 -0400 Received: from mail-oi0-x232.google.com ([2607:f8b0:4003:c06::232]:46730) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhIP-0002fe-Sq; Mon, 23 Jul 2018 16:19:05 -0400 Received: by mail-oi0-x232.google.com with SMTP id y207-v6so3451816oie.13; Mon, 23 Jul 2018 13:19: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; bh=0tM492gYNuMQi7pxWmSX7LCNRIuEwmO87+NdvfrQF+Y=; b=fwaS+lgeLfK4h82I3C9y0Mp9TaqN3pa/ckR7/sgV/RodnbiHCUBFBcXu8m2oZCdV2V Vr4SLYf1U5B22CVjx9RIaS0CCZPfyzP/IIFLVg+789+BOOOgLbDjovovWLhi3UbEgypR h3oOwreouVmVlnzKDPnLTGWZjxLs3/WjjasUFz1As4wdxRERHiRfU5iJbCXaMAKYqFQ0 aUNHS9jBHJhmLSjdGMJrfJ53oqsrw+eKOa7Popxt6meMAdW8yFdzQdYF6nZl/Cf8bUKn 73qxHLxClAnOEQk2SyYcF1FBL/ApCSMgZBZeXwKFeL+NF88OzYmepz1mOkC0z5IysKMB nXiA== 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=0tM492gYNuMQi7pxWmSX7LCNRIuEwmO87+NdvfrQF+Y=; b=IHty8hsxi5izgFvXFp12m9lw0Fl8EEB4VsPTxJINlqg2UsmNpLdGrYw6xzAvZm9AA9 f2gDqd155kP1qEThCqdUlhjSvBg7LifH2NObfTwUmVmXF+UFgQrNQZz3Dnk5lCcKnFCE rJLegIl6ZfaVydamaNE/bljyU+Cb1cR24uKL9vp1HzY0eEyMaUKWV7QuB1r9yFv9vZsM a0HPXpNZ71ZdQRRff7o+UDWnyFuB9NuREffx2F+JfgIjLILVF+5LX2HZbrfuaE1RwWD/ Mv9zfrOucrCNFka0NF4D2kpcydqHw0aoVxuEBUKf3DEkJnabx8nWHw0WrUksZe/CafEF 3m1g== X-Gm-Message-State: AOUpUlEFqCGwtjNRNx8akDzbtd5fB3ytjKfecFBDQEnMA9k4xDWWSSX2 YyP9LFqrr4tCc9A0w7P29Ek3sPcZj8c= X-Google-Smtp-Source: AAOMgpfWwUqCwrOSvgNEtqDnPnagTKfjVe+BQ1qu3BjSCfBwBHPJwriLNQd9p+yuQnV7tQiKykerkg== X-Received: by 2002:aca:f58f:: with SMTP id t137-v6mr322426oih.244.1532377144764; Mon, 23 Jul 2018 13:19:04 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id f144-v6sm13105537oib.39.2018.07.23.13.19.03 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:19:03 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:16:29 -0500 Message-Id: <20180723201748.25573-21-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::232 Subject: [Qemu-devel] [PATCH 20/99] pc-bios/s390-ccw: struct tpi_info must be declared as aligned(4) 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: Thomas Huth , Cornelia Huck , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Thomas Huth I've run into a compilation error today with the current version of GCC 8: In file included from s390-ccw.h:49, from main.c:12: cio.h:128:1: error: alignment 1 of 'struct tpi_info' is less than 4 [-Werror=packed-not-aligned] } __attribute__ ((packed)); ^ cc1: all warnings being treated as errors Since the struct tpi_info contains an element ("struct subchannel_id schid") which is marked as aligned(4), we've got to mark the struct tpi_info as aligned(4), too. CC: qemu-stable@nongnu.org Signed-off-by: Thomas Huth Message-Id: <1525774672-11913-1-git-send-email-thuth@redhat.com> Reviewed-by: Cornelia Huck Acked-by: Christian Borntraeger Signed-off-by: Cornelia Huck (cherry picked from commit a6e4385dea94850d7b06b0542e7960c1063fdabd) Signed-off-by: Michael Roth --- pc-bios/s390-ccw/cio.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pc-bios/s390-ccw/cio.h b/pc-bios/s390-ccw/cio.h index 55eaeee4b6..1a0795f645 100644 --- a/pc-bios/s390-ccw/cio.h +++ b/pc-bios/s390-ccw/cio.h @@ -125,7 +125,7 @@ struct tpi_info { __u32 reserved3 : 12; __u32 int_type : 3; __u32 reserved4 : 12; -} __attribute__ ((packed)); +} __attribute__ ((packed, aligned(4))); /* channel command word (type 1) */ struct ccw1 { From patchwork Mon Jul 23 20:16:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948004 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="KNjM6ZDt"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZCvF0JyWz9s1x for ; Tue, 24 Jul 2018 06:36:25 +1000 (AEST) Received: from localhost ([::1]:36429 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhZ8-0008Vy-La for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 16:36:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40906) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhIW-0001dN-28 for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhIU-0002oi-KE for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:12 -0400 Received: from mail-oi0-x244.google.com ([2607:f8b0:4003:c06::244]:42717) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhIU-0002o9-Cs; Mon, 23 Jul 2018 16:19:10 -0400 Received: by mail-oi0-x244.google.com with SMTP id n84-v6so3460958oib.9; Mon, 23 Jul 2018 13:19:10 -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=JwXV6lCdYGTsoITieUCAbMMso48s1+5BSagBEGpnQw4=; b=KNjM6ZDt6FNsqxhcbkDFSwYv90kWnixSiXcsNaX20vaGami8XB4+0gjKVWLxpoxCYo woco0vbUeJCxio59EVGlqEd6rs0EkDJYYpUkhS5Ls8lTWWvdWm2X6mcxUl4LMeW7zHCe Ex5xAY9bGvrsvGPtwtBU/6KFXXV4q25y6rNFl9cY7FrwuKdfQY5YsH8EgZL+JQw8eFf6 7IEHJM7GxPQP2PlLM5DtvKnoFbonyywTaZPC6fMDYQ8ndOXOSQnC3NzkrtkDRBxHShM5 61m6snNRM6fBUAwW5VQ8LqbQ2uj00gcCpT1S8AMhzMff4OC5eCJ2jS04GK3ro7UGg+Oi jgCg== 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=JwXV6lCdYGTsoITieUCAbMMso48s1+5BSagBEGpnQw4=; b=sVpmA253vdQRhREcpukyUJZL/B+7LsHJIyhMVEvfLp2419iUaFuFS4iU6BfDck9Y/P NLZ9M009MjvQ/lHC/JNi5to0Kn1+bn7ntCNpxees35v/Ehv8xO9nHHItOfBEEYzyBEKO 88Z4TF9vnEDES45NXGUcONxTIu7djmYh/HbnphXJyYkBuYbbhC6lBBXNwDDyLQtapW5/ qeM6lPh5qImUTBukdV7Cj5379l3jMMXOwALSKttA8bALmQEj4mSNJOd57EgitC/aDqBt p9kHWq+7CeflWqqBw0M9u2gsMeybw6wKYu7h8sr3/3jVBE5PsUBMtbKVc9mJePDiJcle bvVA== X-Gm-Message-State: AOUpUlGC4YCgMmgeBBkbrhzMNp27YmxR2Rd7evhcvD2gA4mg85iKaXdj r7jjGJ5DUwEEAxJYRLcoNs0Z5TqKwSQ= X-Google-Smtp-Source: AAOMgpe+JyxtkeQnt/hcnt9efMsFbhWNk/zseImgVtJWAUHJT+B9BbQKbYMAlUIlMV1epvBPhla5gA== X-Received: by 2002:aca:a64d:: with SMTP id p74-v6mr262894oie.149.1532377149266; Mon, 23 Jul 2018 13:19:09 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id 185-v6sm7074575oid.22.2018.07.23.13.19.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:19:08 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:16:30 -0500 Message-Id: <20180723201748.25573-22-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::244 Subject: [Qemu-devel] [PATCH 21/99] virtio-ccw: common reset handler 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: Cornelia Huck , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Cornelia Huck All the different virtio ccw devices use the same reset handler, so let's move setting it into the base virtio ccw device class. CC: qemu-stable@nongnu.org Reviewed-by: Thomas Huth Reviewed-by: David Hildenbrand Reviewed-by: Halil Pasic Signed-off-by: Cornelia Huck (cherry picked from commit 0c53057adb04d254bc09511880670c92ab185fc6) Signed-off-by: Michael Roth --- hw/s390x/virtio-ccw.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c index e51fbefd23..40a33302a7 100644 --- a/hw/s390x/virtio-ccw.c +++ b/hw/s390x/virtio-ccw.c @@ -1345,7 +1345,6 @@ static void virtio_ccw_net_class_init(ObjectClass *klass, void *data) k->realize = virtio_ccw_net_realize; k->unrealize = virtio_ccw_unrealize; - dc->reset = virtio_ccw_reset; dc->props = virtio_ccw_net_properties; set_bit(DEVICE_CATEGORY_NETWORK, dc->categories); } @@ -1373,7 +1372,6 @@ static void virtio_ccw_blk_class_init(ObjectClass *klass, void *data) k->realize = virtio_ccw_blk_realize; k->unrealize = virtio_ccw_unrealize; - dc->reset = virtio_ccw_reset; dc->props = virtio_ccw_blk_properties; set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); } @@ -1401,7 +1399,6 @@ static void virtio_ccw_serial_class_init(ObjectClass *klass, void *data) k->realize = virtio_ccw_serial_realize; k->unrealize = virtio_ccw_unrealize; - dc->reset = virtio_ccw_reset; dc->props = virtio_ccw_serial_properties; set_bit(DEVICE_CATEGORY_INPUT, dc->categories); } @@ -1429,7 +1426,6 @@ static void virtio_ccw_balloon_class_init(ObjectClass *klass, void *data) k->realize = virtio_ccw_balloon_realize; k->unrealize = virtio_ccw_unrealize; - dc->reset = virtio_ccw_reset; dc->props = virtio_ccw_balloon_properties; set_bit(DEVICE_CATEGORY_MISC, dc->categories); } @@ -1457,7 +1453,6 @@ static void virtio_ccw_scsi_class_init(ObjectClass *klass, void *data) k->realize = virtio_ccw_scsi_realize; k->unrealize = virtio_ccw_unrealize; - dc->reset = virtio_ccw_reset; dc->props = virtio_ccw_scsi_properties; set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); } @@ -1484,7 +1479,6 @@ static void vhost_ccw_scsi_class_init(ObjectClass *klass, void *data) k->realize = vhost_ccw_scsi_realize; k->unrealize = virtio_ccw_unrealize; - dc->reset = virtio_ccw_reset; dc->props = vhost_ccw_scsi_properties; set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); } @@ -1521,7 +1515,6 @@ static void virtio_ccw_rng_class_init(ObjectClass *klass, void *data) k->realize = virtio_ccw_rng_realize; k->unrealize = virtio_ccw_unrealize; - dc->reset = virtio_ccw_reset; dc->props = virtio_ccw_rng_properties; set_bit(DEVICE_CATEGORY_MISC, dc->categories); } @@ -1559,7 +1552,6 @@ static void virtio_ccw_crypto_class_init(ObjectClass *klass, void *data) k->realize = virtio_ccw_crypto_realize; k->unrealize = virtio_ccw_unrealize; - dc->reset = virtio_ccw_reset; dc->props = virtio_ccw_crypto_properties; set_bit(DEVICE_CATEGORY_MISC, dc->categories); } @@ -1597,7 +1589,6 @@ static void virtio_ccw_gpu_class_init(ObjectClass *klass, void *data) k->realize = virtio_ccw_gpu_realize; k->unrealize = virtio_ccw_unrealize; - dc->reset = virtio_ccw_reset; dc->props = virtio_ccw_gpu_properties; dc->hotpluggable = false; set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories); @@ -1626,7 +1617,6 @@ static void virtio_ccw_input_class_init(ObjectClass *klass, void *data) k->realize = virtio_ccw_input_realize; k->unrealize = virtio_ccw_unrealize; - dc->reset = virtio_ccw_reset; dc->props = virtio_ccw_input_properties; set_bit(DEVICE_CATEGORY_INPUT, dc->categories); } @@ -1730,6 +1720,7 @@ static void virtio_ccw_device_class_init(ObjectClass *klass, void *data) dc->realize = virtio_ccw_busdev_realize; dc->unrealize = virtio_ccw_busdev_unrealize; dc->bus_type = TYPE_VIRTUAL_CSS_BUS; + dc->reset = virtio_ccw_reset; } static const TypeInfo virtio_ccw_device_info = { @@ -1806,7 +1797,6 @@ static void virtio_ccw_9p_class_init(ObjectClass *klass, void *data) k->unrealize = virtio_ccw_unrealize; k->realize = virtio_ccw_9p_realize; - dc->reset = virtio_ccw_reset; dc->props = virtio_ccw_9p_properties; set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); } @@ -1856,7 +1846,6 @@ static void vhost_vsock_ccw_class_init(ObjectClass *klass, void *data) k->unrealize = virtio_ccw_unrealize; set_bit(DEVICE_CATEGORY_MISC, dc->categories); dc->props = vhost_vsock_ccw_properties; - dc->reset = virtio_ccw_reset; } static void vhost_vsock_ccw_instance_init(Object *obj) From patchwork Mon Jul 23 20:16:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 947997 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="BMOoNEdE"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZCll19xTz9s1x for ; Tue, 24 Jul 2018 06:29:54 +1000 (AEST) Received: from localhost ([::1]:36386 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhSq-0002Uc-Id for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 16:29:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40958) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhIY-0001fU-0P for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhIW-0002uc-S5 for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:13 -0400 Received: from mail-oi0-x22c.google.com ([2607:f8b0:4003:c06::22c]:44622) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhIW-0002sK-L4; Mon, 23 Jul 2018 16:19:12 -0400 Received: by mail-oi0-x22c.google.com with SMTP id s198-v6so3457170oih.11; Mon, 23 Jul 2018 13:19:12 -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=5HEaxBnYUa+eZPrZp0pDfk4ZGK07fx16EkXrj/q8N18=; b=BMOoNEdEVce1Zyv/iupeRN1sq3F4U0HPuSovKh7DzW/ROJM7nyWrLdbV4h8sSZ5Scr smL+7iMfx1OQVIUHNiYXBVkAZ2B5ebQ+V6Rs3I0j9L9d0oyc33U5MUvXTBSCSoyF3PzU nPA14fav/bEz1fzPxBy1aXuXWwDZK4/yvVcE3HH7jD0PW3MthncGxdl/SL6OyU70ew1x SLnRoT7v0yz7VcK1b9HBOBenu372joax+NxcH5WSBOk16eVja0sCkKlPcmlIgnP17+t4 ri2qid/Qckncxxn43Eo53m1pmGsqnMI5mzx3OTpUbnCTfd/rX8Q3gMqKRxs92P7AMjdO Bbkg== 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=5HEaxBnYUa+eZPrZp0pDfk4ZGK07fx16EkXrj/q8N18=; b=GBQMm2xeU4B2grXaXkNkZc9WsCez/CvxjIDURv6Fbj54IFeWA5grKPPAdTkg66XIZu gF920VkMRumK9jRrij5iV8Jei/oXwLFtWsKQaj+tVSw0dQslx/dCbOYYvGjHrXsvRZGy 5V4thXbTwz738PD640/1D9vlsQu9l/zG+iSn+BEnt1wPM8ptVDmSC9L0Y+4X7mtmV2Iu zX23BFQHHfCuax05LPl0CUafKvpCmsyG1QpygbIKJZ0TfCp6mAI8dJrVKGI4RwDilI7e nw39NEy8bNTD8wc7UrID5PbwKpKP5dADze+ny5q1XZB/8djfACu4zg8q0VaJOP/8aJqb q5zw== X-Gm-Message-State: AOUpUlHJaJb8AKxcjYC6XEo1fXmNUIrPlujj1GLAZ8HlYiUe5CsEjFFe EGTQZL1uGh5du87jmyPJX16ez/Is9TA= X-Google-Smtp-Source: AAOMgpfRpHNGokPN+mZhjEkw05iSQ1xenUKtHuur4oPNMr9TR9V2tUs7rBW+JdgQy1SVZ9w48F+xJA== X-Received: by 2002:aca:cdc2:: with SMTP id d185-v6mr319085oig.350.1532377151483; Mon, 23 Jul 2018 13:19:11 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id d191-v6sm11783282oig.16.2018.07.23.13.19.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:19:10 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:16:31 -0500 Message-Id: <20180723201748.25573-23-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::22c Subject: [Qemu-devel] [PATCH 22/99] s390x/ccw: make sure all ccw devices are properly reset 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: Cornelia Huck , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Cornelia Huck Thomas reported that the subchannel for a 3270 device that ended up in a broken state (status pending even though not enabled) did not get out of that state even after a reboot (which involves a subsytem reset). The reason for this is that the 3270 device did not define a reset handler. Let's fix this by introducing a base reset handler (set up for all ccw devices) that resets the subchannel and have virtio-ccw call its virtio-specific reset procedure in addition to that. CC: qemu-stable@nongnu.org Reported-by: Thomas Huth Suggested-by: Christian Borntraeger Reviewed-by: Thomas Huth Tested-by: Thomas Huth Acked-by: Christian Borntraeger Reviewed-by: Halil Pasic Signed-off-by: Cornelia Huck (cherry picked from commit 838fb84f83c84f00d15b1bede5e080b495644458) Signed-off-by: Michael Roth --- hw/s390x/ccw-device.c | 8 ++++++++ hw/s390x/virtio-ccw.c | 9 ++++++--- hw/s390x/virtio-ccw.h | 1 + 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/hw/s390x/ccw-device.c b/hw/s390x/ccw-device.c index f9bfa154d6..7cd73df4aa 100644 --- a/hw/s390x/ccw-device.c +++ b/hw/s390x/ccw-device.c @@ -40,6 +40,13 @@ static Property ccw_device_properties[] = { DEFINE_PROP_END_OF_LIST(), }; +static void ccw_device_reset(DeviceState *d) +{ + CcwDevice *ccw_dev = CCW_DEVICE(d); + + css_reset_sch(ccw_dev->sch); +} + static void ccw_device_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); @@ -48,6 +55,7 @@ static void ccw_device_class_init(ObjectClass *klass, void *data) k->realize = ccw_device_realize; k->refill_ids = ccw_device_refill_ids; dc->props = ccw_device_properties; + dc->reset = ccw_device_reset; } const VMStateDescription vmstate_ccw_dev = { diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c index 40a33302a7..22df33b509 100644 --- a/hw/s390x/virtio-ccw.c +++ b/hw/s390x/virtio-ccw.c @@ -1058,10 +1058,12 @@ static void virtio_ccw_reset(DeviceState *d) { VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d); VirtIODevice *vdev = virtio_bus_get_device(&dev->bus); - CcwDevice *ccw_dev = CCW_DEVICE(d); + VirtIOCCWDeviceClass *vdc = VIRTIO_CCW_DEVICE_GET_CLASS(dev); virtio_ccw_reset_virtio(dev, vdev); - css_reset_sch(ccw_dev->sch); + if (vdc->parent_reset) { + vdc->parent_reset(d); + } } static void virtio_ccw_vmstate_change(DeviceState *d, bool running) @@ -1715,12 +1717,13 @@ static void virtio_ccw_device_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); CCWDeviceClass *k = CCW_DEVICE_CLASS(dc); + VirtIOCCWDeviceClass *vdc = VIRTIO_CCW_DEVICE_CLASS(klass); k->unplug = virtio_ccw_busdev_unplug; dc->realize = virtio_ccw_busdev_realize; dc->unrealize = virtio_ccw_busdev_unrealize; dc->bus_type = TYPE_VIRTUAL_CSS_BUS; - dc->reset = virtio_ccw_reset; + device_class_set_parent_reset(dc, virtio_ccw_reset, &vdc->parent_reset); } static const TypeInfo virtio_ccw_device_info = { diff --git a/hw/s390x/virtio-ccw.h b/hw/s390x/virtio-ccw.h index 2fc513001e..3453aa1f98 100644 --- a/hw/s390x/virtio-ccw.h +++ b/hw/s390x/virtio-ccw.h @@ -77,6 +77,7 @@ typedef struct VirtIOCCWDeviceClass { CCWDeviceClass parent_class; void (*realize)(VirtioCcwDevice *dev, Error **errp); void (*unrealize)(VirtioCcwDevice *dev, Error **errp); + void (*parent_reset)(DeviceState *dev); } VirtIOCCWDeviceClass; /* Performance improves when virtqueue kick processing is decoupled from the From patchwork Mon Jul 23 20:16:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948003 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="qHQlCJJZ"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZCv76r4fz9s1x for ; Tue, 24 Jul 2018 06:36:19 +1000 (AEST) Received: from localhost ([::1]:36428 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhZ3-0008Qk-IL for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 16:36:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40993) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhIa-0001i5-75 for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhIZ-0002yw-6O for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:16 -0400 Received: from mail-oi0-x244.google.com ([2607:f8b0:4003:c06::244]:35582) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhIZ-0002yM-1q; Mon, 23 Jul 2018 16:19:15 -0400 Received: by mail-oi0-x244.google.com with SMTP id i12-v6so3495656oik.2; Mon, 23 Jul 2018 13:19:15 -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=vJNEMM5J7/Qf1SBLTqXhH7G0om3Wy3P6uvuPWDo0iPY=; b=qHQlCJJZuQoSJa3mF3dgQUMOZL6nKs3nqlxkkjJAQj56ufgWrJtQ44EfRG9+ZZeyWz cb9LmeLyIXSziudG/ikw5KTJcc3Aqs46m+9975F0cNR7iNwoWLVCuQvhm+nvIj4/J5u1 V3yjFPBWI6mIB5pJDy4a+T2pNLr/NNUqW8pj1PYW+45ojMZV+mPGS2J9plJgmr9AXRkG +ESMUr1oq3c5IUuBlalQ+udNNSbNb6bcnPj/cCyZvI7sUuQ+Ah4WLU3usC2Yhj1XNTRS d0m9IU9RyLIDITObPH6OA1V9e850rZbonooDNDOQuwWx6M7w20kBmPl9uK1+0xSfcMBq 2TRg== 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=vJNEMM5J7/Qf1SBLTqXhH7G0om3Wy3P6uvuPWDo0iPY=; b=Wit8hb47V9kREQy9Fi3/Nr+Y48nrL4OR89T2hpYpIXA2P/LsXYDq3dq4n0MR234L4M CaAZ1Yy8wncSSzFyFfqcIrSITxq13P7/1NqjobfTyVPXwCj/kqalP02r4YuqZMJrgN+K 6+LzS4j1F4cUWyXMgbPKGlX5JyA5w71sfEdLv8CmPVy5Upx5hhpIKT/djTbmApenm/Yp aEKxlv4rF2yH8cSV6QjkCHP6w7OdtIJledPZ6wlDCBfzRbLCCeWwaZ0SE9f/IxWTb8WP addgN1vKIxpHgjH8gabnU7lRgKrbM14Jvzzd7qwRW8dw8LJ95tTn6gFBM9uhNzxXxT4y C5yw== X-Gm-Message-State: AOUpUlFciUYDGB9yPlSqj0RgTorkIMnZ+m0VffUH+pqETD43ujtR8GPS DtEv6D0yK0BQXPEocRhCgNA5ll5WWnU= X-Google-Smtp-Source: AAOMgpcKvTSSYEVRMJeMiwFanGuiAAvwrNNmldpOSYaZPw72H0v5PhIQ41OEIUPsPYyZPnDGxEy3uw== X-Received: by 2002:aca:f0a:: with SMTP id 10-v6mr303580oip.183.1532377153856; Mon, 23 Jul 2018 13:19:13 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id m62-v6sm26381628oik.30.2018.07.23.13.19.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:19:12 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:16:32 -0500 Message-Id: <20180723201748.25573-24-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::244 Subject: [Qemu-devel] [PATCH 23/99] console: Avoid segfault in screendump 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 , qemu-stable@nongnu.org, Gerd Hoffmann Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Michal Privoznik After f771c5440e04626f1 it is possible to select device and head which to take screendump from. And even though we check if provided head number falls within range, it may still happen that the console has no surface yet leading to SIGSEGV: qemu.git $ ./x86_64-softmmu/qemu-system-x86_64 \ -qmp stdio \ -device virtio-vga,id=video0,max_outputs=4 {"execute":"qmp_capabilities"} {"execute":"screendump", "arguments":{"filename":"/tmp/screen.ppm", "device":"video0", "head":1}} Segmentation fault #0 0x00005628249dda88 in ppm_save (filename=0x56282826cbc0 "/tmp/screen.ppm", ds=0x0, errp=0x7fff52a6fae0) at ui/console.c:304 #1 0x00005628249ddd9b in qmp_screendump (filename=0x56282826cbc0 "/tmp/screen.ppm", has_device=true, device=0x5628276902d0 "video0", has_head=true, head=1, errp=0x7fff52a6fae0) at ui/console.c:375 #2 0x00005628247740df in qmp_marshal_screendump (args=0x562828265e00, ret=0x7fff52a6fb68, errp=0x7fff52a6fb60) at qapi/qapi-commands-ui.c:110 Here, @ds from frame #0 (or @surface from frame #1) is dereferenced at the very beginning of ppm_save(). And because it's NULL crash happens. Signed-off-by: Michal Privoznik Reviewed-by: Thomas Huth Message-id: cb05bb1909daa6ba62145c0194aafa05a14ed3d1.1526569138.git.mprivozn@redhat.com Signed-off-by: Gerd Hoffmann (cherry picked from commit 08d9864fa4e0c616e076ca8b225d39a7ecb189af) Signed-off-by: Michael Roth --- ui/console.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ui/console.c b/ui/console.c index 3fb2f4e09f..476bf901a4 100644 --- a/ui/console.c +++ b/ui/console.c @@ -370,6 +370,11 @@ void qmp_screendump(const char *filename, bool has_device, const char *device, graphic_hw_update(con); surface = qemu_console_surface(con); + if (!surface) { + error_setg(errp, "no surface"); + return; + } + ppm_save(filename, surface, errp); } From patchwork Mon Jul 23 20:16:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948000 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="TFuZwV6H"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZCqT4ZVgz9s1x for ; Tue, 24 Jul 2018 06:33:09 +1000 (AEST) Received: from localhost ([::1]:36406 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhVz-0005SZ-7V for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 16:33:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41045) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhIf-0001nD-NR for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhIb-00031k-Es for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:21 -0400 Received: from mail-oi0-x230.google.com ([2607:f8b0:4003:c06::230]:39344) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhIb-000313-8O; Mon, 23 Jul 2018 16:19:17 -0400 Received: by mail-oi0-x230.google.com with SMTP id d189-v6so3476521oib.6; Mon, 23 Jul 2018 13:19:17 -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=xa11ownfegEdDdt6qm/4wsMAV8olYURvYcP/Es2RQ48=; b=TFuZwV6Hfyi6/G9tFXRfNZ+oVlwlKC4dwyQeID8ulBHevYVA9qkHnm2YZANQG6XG/G Y773X4Yolb0HRaRpZhftH6vQCo6t9Yfe3A04kIS2ave2e0AWF5nvOSSAMEOB7W+4H7Bt UEdXixLfDl9d+0VNTRCLGCDe6piJx6+i0fJEmqk7k1GWkHMqo56Zx+o8wlvdmXONy4BZ pMhcoPlpgg8nmE6Q2KCbSi+iLv8i6aO7Deso2sL4pAsgeMvSR1OGVEyg8ohZQobf8p86 9IriE2JCAhkqz3TxtwaiaXfqhEFpDjaxNxqeMXJ0TOgRysGFjPZPGl3gT+F92F/os0MC WprA== 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=xa11ownfegEdDdt6qm/4wsMAV8olYURvYcP/Es2RQ48=; b=fGf1mh7jS9YshmWKvGPg2/POFuTJ1A0BIS8z6omcgeNoqvdzXs6Ts04fxgbnl2FZ+y Ly00PMPml7d4Vb9fMLC4H4kBOePZwcgNMLyMWgP1J4b35ixggKc+8703yT0lYzJ8urm5 omJHCZIRl+MAi1yZFDX2MQPq/MBnCvI7p5sD0FVHwCjThn+vx8Ro3jlTJLuHf58f9r5i QqJ4NNPI+CXXDzn5URsAf1lzDqR1oFigPUAeLS5whnVqTgK+MOFwC7Uu16KA1p39By9v M3LFcZjOmgGgNJTBvnsxpBpUUTB+FIe23AkJAMZKX8ZiiyKwY577QvmjtuYpOlvO/iur eiiA== X-Gm-Message-State: AOUpUlFzC5Dj3X1xP9Au6PEqE52QhwAsUM2joy7KMqS+iVSH8bcK124u q3gP4rdCXf4VK3TwAMQLLqsNXB8xDig= X-Google-Smtp-Source: AAOMgpc12o6nvwyRU3uTCjcTiPG3tGZqDCeB8un2Z7ek7kwpJrAT5xkG0NOED8kg4RcYfNoxj3VkhQ== X-Received: by 2002:aca:5282:: with SMTP id g124-v6mr279059oib.241.1532377156017; Mon, 23 Jul 2018 13:19:16 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id q18-v6sm1078952oic.18.2018.07.23.13.19.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:19:14 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:16:33 -0500 Message-Id: <20180723201748.25573-25-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::230 Subject: [Qemu-devel] [PATCH 24/99] hw/intc/arm_gicv3: Fix APxR register dispatching 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: Jan Kiszka , qemu-stable@nongnu.org, Peter Maydell Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Jan Kiszka There was a nasty flip in identifying which register group an access is targeting. The issue caused spuriously raised priorities of the guest when handing CPUs over in the Jailhouse hypervisor. Cc: qemu-stable@nongnu.org Signed-off-by: Jan Kiszka Message-id: 28b927d3-da58-bce4-cc13-bfec7f9b1cb9@siemens.com Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell (cherry picked from commit 887aae10f6150dfdc71c45d7588e8efe6c144019) Signed-off-by: Michael Roth --- hw/intc/arm_gicv3_cpuif.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c index 26f5eeda94..554be25cb7 100644 --- a/hw/intc/arm_gicv3_cpuif.c +++ b/hw/intc/arm_gicv3_cpuif.c @@ -431,7 +431,7 @@ static uint64_t icv_ap_read(CPUARMState *env, const ARMCPRegInfo *ri) { GICv3CPUState *cs = icc_cs_from_env(env); int regno = ri->opc2 & 3; - int grp = ri->crm & 1 ? GICV3_G0 : GICV3_G1NS; + int grp = (ri->crm & 1) ? GICV3_G1NS : GICV3_G0; uint64_t value = cs->ich_apr[grp][regno]; trace_gicv3_icv_ap_read(ri->crm & 1, regno, gicv3_redist_affid(cs), value); @@ -443,7 +443,7 @@ static void icv_ap_write(CPUARMState *env, const ARMCPRegInfo *ri, { GICv3CPUState *cs = icc_cs_from_env(env); int regno = ri->opc2 & 3; - int grp = ri->crm & 1 ? GICV3_G0 : GICV3_G1NS; + int grp = (ri->crm & 1) ? GICV3_G1NS : GICV3_G0; trace_gicv3_icv_ap_write(ri->crm & 1, regno, gicv3_redist_affid(cs), value); @@ -1465,7 +1465,7 @@ static uint64_t icc_ap_read(CPUARMState *env, const ARMCPRegInfo *ri) uint64_t value; int regno = ri->opc2 & 3; - int grp = ri->crm & 1 ? GICV3_G0 : GICV3_G1; + int grp = (ri->crm & 1) ? GICV3_G1 : GICV3_G0; if (icv_access(env, grp == GICV3_G0 ? HCR_FMO : HCR_IMO)) { return icv_ap_read(env, ri); @@ -1487,7 +1487,7 @@ static void icc_ap_write(CPUARMState *env, const ARMCPRegInfo *ri, GICv3CPUState *cs = icc_cs_from_env(env); int regno = ri->opc2 & 3; - int grp = ri->crm & 1 ? GICV3_G0 : GICV3_G1; + int grp = (ri->crm & 1) ? GICV3_G1 : GICV3_G0; if (icv_access(env, grp == GICV3_G0 ? HCR_FMO : HCR_IMO)) { icv_ap_write(env, ri, value); @@ -2296,7 +2296,7 @@ static uint64_t ich_ap_read(CPUARMState *env, const ARMCPRegInfo *ri) { GICv3CPUState *cs = icc_cs_from_env(env); int regno = ri->opc2 & 3; - int grp = ri->crm & 1 ? GICV3_G0 : GICV3_G1NS; + int grp = (ri->crm & 1) ? GICV3_G1NS : GICV3_G0; uint64_t value; value = cs->ich_apr[grp][regno]; @@ -2309,7 +2309,7 @@ static void ich_ap_write(CPUARMState *env, const ARMCPRegInfo *ri, { GICv3CPUState *cs = icc_cs_from_env(env); int regno = ri->opc2 & 3; - int grp = ri->crm & 1 ? GICV3_G0 : GICV3_G1NS; + int grp = (ri->crm & 1) ? GICV3_G1NS : GICV3_G0; trace_gicv3_ich_ap_write(ri->crm & 1, regno, gicv3_redist_affid(cs), value); From patchwork Mon Jul 23 20:16:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 947998 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="iLlgBum9"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZCmk4Xhfz9s1x for ; Tue, 24 Jul 2018 06:30:46 +1000 (AEST) Received: from localhost ([::1]:36391 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhTg-0003hh-9Q for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 16:30:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41079) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhIh-0001oo-BU for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhId-000354-MV for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:23 -0400 Received: from mail-oi0-x230.google.com ([2607:f8b0:4003:c06::230]:37377) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhId-00034e-FR; Mon, 23 Jul 2018 16:19:19 -0400 Received: by mail-oi0-x230.google.com with SMTP id k81-v6so3471999oib.4; Mon, 23 Jul 2018 13:19:19 -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=09ZAfLfbd6SrobG/bzSpP+lzCAHMCLCl2wtQ/YqclnA=; b=iLlgBum9usqsqjqOTC1Fzk+Ozu9dm5ZxG0zur5U7Abx0D5I4/+sYXf/xumGaOiKgSy Rw+m/PrkOm+/wNmrhkIVNsI64l1up7aH6lgMd9mxWFgmYwz9Izb4hrwKtI+YGfn0io5R Hqy/QULUG8m3NLGvM9qh0eWvBLa2RI7vOpg8Agta5s7N+UA+8UiuYJqi6DnliyAsbg3g MBIsm3z3MfnCT2/q9JwnyGEo8fxl0lE7YqTSPPvDgqcan3SKUb2AbXaOUKA2opyVquGR 1At/KAqePNsFlNz+FmcrOeRU77A6ZZGfBg2A+05PIsfG0OCloUwEQ+YfDU+DWeozNk2C tZbw== 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=09ZAfLfbd6SrobG/bzSpP+lzCAHMCLCl2wtQ/YqclnA=; b=lkxvqycr3LMGnYY09/jq2WjUV1VsdyoV8S97veo4+OanaXqT2G1MBuXPYWkRDAhUmD 5tc7ZWRYV1GAhK9ClUIEGRFUQs1BCT520WIiJwZopz6XlGhinSHQBiMQQQmoziSnweuY mh0/dVhTxrNwzbsziHDUwYED7foPT3SZZh7PNkKIzA7Qyon6JI9+aIV0qNBJDN3Rx0jx 1G32K/NPXlEXsfaYR4hysbmuGUpWQD2QHUo1KfM3GQUQxCk499+q426pChFmJkfgiCgr JacWZ5vEpen5er5NNNp0ydil/DPlZSaE0tjRo65EsSHT0Kk1XY1T3gtf2WV104iTyy1D icxQ== X-Gm-Message-State: AOUpUlFHh6W0WUMeNpVRF7I0hvjSypOuKzHwvpbsQS5kFTckNEZWSDrf mLKlRPD3d7QjtPU9dyslfwOb5jFgEUk= X-Google-Smtp-Source: AAOMgpekMw1ALzIrXOHDVlPKV1Z7q0XHAA3/NFI0iItGS17GNskw/sAx6blIZ9GZU55dfOzkjisdcA== X-Received: by 2002:aca:ba57:: with SMTP id k84-v6mr304647oif.10.1532377158324; Mon, 23 Jul 2018 13:19:18 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id m203-v6sm25492354oig.42.2018.07.23.13.19.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:19:17 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:16:34 -0500 Message-Id: <20180723201748.25573-26-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::230 Subject: [Qemu-devel] [PATCH 25/99] intel-iommu: send PSI always even if across PDEs 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: qemu-stable@nongnu.org, Peter Xu , "Michael S . Tsirkin" Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Peter Xu SECURITY IMPLICATION: without this patch, any guest with both assigned device and a vIOMMU might encounter stale IO page mappings even if guest has already unmapped the page, which may lead to guest memory corruption. The stale mappings will only be limited to the guest's own memory range, so it should not affect the host memory or other guests on the host. During IOVA page table walking, there is a special case when the PSI covers one whole PDE (Page Directory Entry, which contains 512 Page Table Entries) or more. In the past, we skip that entry and we don't notify the IOMMU notifiers. This is not correct. We should send UNMAP notification to registered UNMAP notifiers in this case. For UNMAP only notifiers, this might cause IOTLBs cached in the devices even if they were already invalid. For MAP/UNMAP notifiers like vfio-pci, this will cause stale page mappings. This special case doesn't trigger often, but it is very easy to be triggered by nested device assignments, since in that case we'll possibly map the whole L2 guest RAM region into the device's IOVA address space (several GBs at least), which is far bigger than normal kernel driver usages of the device (tens of MBs normally). Without this patch applied to L1 QEMU, nested device assignment to L2 guests will dump some errors like: qemu-system-x86_64: VFIO_MAP_DMA: -17 qemu-system-x86_64: vfio_dma_map(0x557305420c30, 0xad000, 0x1000, 0x7f89a920d000) = -17 (File exists) CC: QEMU Stable Acked-by: Jason Wang [peterx: rewrite the commit message] Signed-off-by: Peter Xu Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin (cherry picked from commit 36d2d52bdb45f5b753a61fdaf0fe7891f1f5b61d) Signed-off-by: Michael Roth --- hw/i386/intel_iommu.c | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index fb31de9416..b359efd6f9 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -722,6 +722,15 @@ static int vtd_iova_to_slpte(VTDContextEntry *ce, uint64_t iova, bool is_write, typedef int (*vtd_page_walk_hook)(IOMMUTLBEntry *entry, void *private); +static int vtd_page_walk_one(IOMMUTLBEntry *entry, int level, + vtd_page_walk_hook hook_fn, void *private) +{ + assert(hook_fn); + trace_vtd_page_walk_one(level, entry->iova, entry->translated_addr, + entry->addr_mask, entry->perm); + return hook_fn(entry, private); +} + /** * vtd_page_walk_level - walk over specific level for IOVA range * @@ -781,28 +790,37 @@ static int vtd_page_walk_level(dma_addr_t addr, uint64_t start, */ entry_valid = read_cur | write_cur; + entry.target_as = &address_space_memory; + entry.iova = iova & subpage_mask; + entry.perm = IOMMU_ACCESS_FLAG(read_cur, write_cur); + entry.addr_mask = ~subpage_mask; + if (vtd_is_last_slpte(slpte, level)) { - entry.target_as = &address_space_memory; - entry.iova = iova & subpage_mask; /* NOTE: this is only meaningful if entry_valid == true */ entry.translated_addr = vtd_get_slpte_addr(slpte, aw); - entry.addr_mask = ~subpage_mask; - entry.perm = IOMMU_ACCESS_FLAG(read_cur, write_cur); if (!entry_valid && !notify_unmap) { trace_vtd_page_walk_skip_perm(iova, iova_next); goto next; } - trace_vtd_page_walk_one(level, entry.iova, entry.translated_addr, - entry.addr_mask, entry.perm); - if (hook_fn) { - ret = hook_fn(&entry, private); - if (ret < 0) { - return ret; - } + ret = vtd_page_walk_one(&entry, level, hook_fn, private); + if (ret < 0) { + return ret; } } else { if (!entry_valid) { - trace_vtd_page_walk_skip_perm(iova, iova_next); + if (notify_unmap) { + /* + * The whole entry is invalid; unmap it all. + * Translated address is meaningless, zero it. + */ + entry.translated_addr = 0x0; + ret = vtd_page_walk_one(&entry, level, hook_fn, private); + if (ret < 0) { + return ret; + } + } else { + trace_vtd_page_walk_skip_perm(iova, iova_next); + } goto next; } ret = vtd_page_walk_level(vtd_get_slpte_addr(slpte, aw), iova, From patchwork Mon Jul 23 20:16:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948001 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ms9GkGWm"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZCrF2wbHz9s1x for ; Tue, 24 Jul 2018 06:33:49 +1000 (AEST) Received: from localhost ([::1]:36408 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhWc-0005zU-RP for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 16:33:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41082) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhIh-0001or-DC for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhIg-00037H-0N for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:23 -0400 Received: from mail-oi0-x242.google.com ([2607:f8b0:4003:c06::242]:43136) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhIf-00036V-O1; Mon, 23 Jul 2018 16:19:21 -0400 Received: by mail-oi0-x242.google.com with SMTP id b15-v6so3460049oib.10; Mon, 23 Jul 2018 13:19:21 -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=kYJKHN5sgkbV+M8ygN86JV5MOglK+efEm7MmkuDOksI=; b=ms9GkGWm3I5SK6bLscUdg5ut+m8BeXX7OAxL2Bw/f1wIrNi32O4oSYU4ZQQj1p8crl rULmz+JCXBsVloBzhdP/fPlFkAze5rcT4ELP1rxQzoTKmiUOSJX3Hq4IovcIjrfulCFr gm68yloII4axUzFW5A7oACuZl2THR+v9fQqeI64yNg8z6GzeprimLUNIAeWODW+fMl7G BwjbHi/qDsVIy0P2soF/QRxMEZnu4gl2VGzMWYl22WoaIHObyrH4yddiQC6/kYMH4JoW BS+W0xE/LcjjiBdYwxeuEviPTecd1sI/R6+tjsKEpBmNTSA35jSodBoMjJeFSmukme1v B28g== 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=kYJKHN5sgkbV+M8ygN86JV5MOglK+efEm7MmkuDOksI=; b=uFW2r+DXTBKlLw1i9GBOLhB5DXCKNmX0ufMILG5duJuozCIPx7+AUQGXIU/sGMJw58 1mcEgRnAkMcK3cGznWjhX6Rzv0YrELc30eawOFI7epO1r6WDTD74c4cMSqtrKcynXG7p n9cy5MSUhrxxXFE/oroiN132wGUq7rrenAOfegmdm0/C4SCgxTXQIp52afBXX69kVDcL M7ztyru+S69U2Wm5Ki5QnGQut1tPIl/qSnktoT/GEquGeUQxT4qq5Ixz6iFTEsUg++OW iSXrh7Y+BPy10x/7RfP/UMaWNAVwpIIT7kWXTuc7JXF9XgPguV39ZVhaAxJKjYbjjYpX ADDQ== X-Gm-Message-State: AOUpUlGX+WINkpfKCoNxQJjTTa7MUKiwaOtjI2acp3pShmZjFuqCtmOm DREgmIP3pJopLl186WXpwGVvD+XocXs= X-Google-Smtp-Source: AAOMgpe6XXzVTzsk7AQqOARrabEVZQ4CE9P1RbLxuayZgHTQNtXPTRqMVlEy+6DfTrNDZtkPnDHmCA== X-Received: by 2002:aca:3507:: with SMTP id c7-v6mr345150oia.46.1532377160555; Mon, 23 Jul 2018 13:19:20 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id j193-v6sm7588056oih.55.2018.07.23.13.19.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:19:19 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:16:35 -0500 Message-Id: <20180723201748.25573-27-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::242 Subject: [Qemu-devel] [PATCH 26/99] intel-iommu: remove IntelIOMMUNotifierNode 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: qemu-stable@nongnu.org, Peter Xu , "Michael S . Tsirkin" Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Peter Xu That is not really necessary. Removing that node struct and put the list entry directly into VTDAddressSpace. It simplfies the code a lot. Since at it, rename the old notifiers_list into vtd_as_with_notifiers. CC: QEMU Stable Signed-off-by: Peter Xu Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin (cherry picked from commit b4a4ba0d68f50f218ee3957b6638dbee32a5eeef) Signed-off-by: Michael Roth --- hw/i386/intel_iommu.c | 41 ++++++++++------------------------- include/hw/i386/intel_iommu.h | 9 ++------ 2 files changed, 13 insertions(+), 37 deletions(-) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index b359efd6f9..3df90457f8 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -1248,10 +1248,10 @@ static void vtd_interrupt_remap_table_setup(IntelIOMMUState *s) static void vtd_iommu_replay_all(IntelIOMMUState *s) { - IntelIOMMUNotifierNode *node; + VTDAddressSpace *vtd_as; - QLIST_FOREACH(node, &s->notifiers_list, next) { - memory_region_iommu_replay_all(&node->vtd_as->iommu); + QLIST_FOREACH(vtd_as, &s->vtd_as_with_notifiers, next) { + memory_region_iommu_replay_all(&vtd_as->iommu); } } @@ -1372,7 +1372,6 @@ static void vtd_iotlb_global_invalidate(IntelIOMMUState *s) static void vtd_iotlb_domain_invalidate(IntelIOMMUState *s, uint16_t domain_id) { - IntelIOMMUNotifierNode *node; VTDContextEntry ce; VTDAddressSpace *vtd_as; @@ -1381,8 +1380,7 @@ static void vtd_iotlb_domain_invalidate(IntelIOMMUState *s, uint16_t domain_id) g_hash_table_foreach_remove(s->iotlb, vtd_hash_remove_by_domain, &domain_id); - QLIST_FOREACH(node, &s->notifiers_list, next) { - vtd_as = node->vtd_as; + QLIST_FOREACH(vtd_as, &s->vtd_as_with_notifiers, next) { if (!vtd_dev_to_context_entry(s, pci_bus_num(vtd_as->bus), vtd_as->devfn, &ce) && domain_id == VTD_CONTEXT_ENTRY_DID(ce.hi)) { @@ -1402,12 +1400,11 @@ static void vtd_iotlb_page_invalidate_notify(IntelIOMMUState *s, uint16_t domain_id, hwaddr addr, uint8_t am) { - IntelIOMMUNotifierNode *node; + VTDAddressSpace *vtd_as; VTDContextEntry ce; int ret; - QLIST_FOREACH(node, &(s->notifiers_list), next) { - VTDAddressSpace *vtd_as = node->vtd_as; + QLIST_FOREACH(vtd_as, &(s->vtd_as_with_notifiers), next) { ret = vtd_dev_to_context_entry(s, pci_bus_num(vtd_as->bus), vtd_as->devfn, &ce); if (!ret && domain_id == VTD_CONTEXT_ENTRY_DID(ce.hi)) { @@ -2344,8 +2341,6 @@ static void vtd_iommu_notify_flag_changed(IOMMUMemoryRegion *iommu, { VTDAddressSpace *vtd_as = container_of(iommu, VTDAddressSpace, iommu); IntelIOMMUState *s = vtd_as->iommu_state; - IntelIOMMUNotifierNode *node = NULL; - IntelIOMMUNotifierNode *next_node = NULL; if (!s->caching_mode && new & IOMMU_NOTIFIER_MAP) { error_report("We need to set caching-mode=1 for intel-iommu to enable " @@ -2354,21 +2349,9 @@ static void vtd_iommu_notify_flag_changed(IOMMUMemoryRegion *iommu, } if (old == IOMMU_NOTIFIER_NONE) { - node = g_malloc0(sizeof(*node)); - node->vtd_as = vtd_as; - QLIST_INSERT_HEAD(&s->notifiers_list, node, next); - return; - } - - /* update notifier node with new flags */ - QLIST_FOREACH_SAFE(node, &s->notifiers_list, next, next_node) { - if (node->vtd_as == vtd_as) { - if (new == IOMMU_NOTIFIER_NONE) { - QLIST_REMOVE(node, next); - g_free(node); - } - return; - } + QLIST_INSERT_HEAD(&s->vtd_as_with_notifiers, vtd_as, next); + } else if (new == IOMMU_NOTIFIER_NONE) { + QLIST_REMOVE(vtd_as, next); } } @@ -2838,12 +2821,10 @@ static void vtd_address_space_unmap(VTDAddressSpace *as, IOMMUNotifier *n) static void vtd_address_space_unmap_all(IntelIOMMUState *s) { - IntelIOMMUNotifierNode *node; VTDAddressSpace *vtd_as; IOMMUNotifier *n; - QLIST_FOREACH(node, &s->notifiers_list, next) { - vtd_as = node->vtd_as; + QLIST_FOREACH(vtd_as, &s->vtd_as_with_notifiers, next) { IOMMU_NOTIFIER_FOREACH(n, &vtd_as->iommu) { vtd_address_space_unmap(vtd_as, n); } @@ -3088,7 +3069,7 @@ static void vtd_realize(DeviceState *dev, Error **errp) return; } - QLIST_INIT(&s->notifiers_list); + QLIST_INIT(&s->vtd_as_with_notifiers); memset(s->vtd_as_by_bus_num, 0, sizeof(s->vtd_as_by_bus_num)); memory_region_init_io(&s->csrmem, OBJECT(s), &vtd_mem_ops, s, "intel_iommu", DMAR_REG_SIZE); diff --git a/include/hw/i386/intel_iommu.h b/include/hw/i386/intel_iommu.h index 45ec8919b6..032e33bcb2 100644 --- a/include/hw/i386/intel_iommu.h +++ b/include/hw/i386/intel_iommu.h @@ -67,7 +67,6 @@ typedef union VTD_IR_TableEntry VTD_IR_TableEntry; typedef union VTD_IR_MSIAddress VTD_IR_MSIAddress; typedef struct VTDIrq VTDIrq; typedef struct VTD_MSIMessage VTD_MSIMessage; -typedef struct IntelIOMMUNotifierNode IntelIOMMUNotifierNode; /* Context-Entry */ struct VTDContextEntry { @@ -93,6 +92,7 @@ struct VTDAddressSpace { MemoryRegion iommu_ir; /* Interrupt region: 0xfeeXXXXX */ IntelIOMMUState *iommu_state; VTDContextCacheEntry context_cache_entry; + QLIST_ENTRY(VTDAddressSpace) next; }; struct VTDBus { @@ -253,11 +253,6 @@ struct VTD_MSIMessage { /* When IR is enabled, all MSI/MSI-X data bits should be zero */ #define VTD_IR_MSI_DATA (0) -struct IntelIOMMUNotifierNode { - VTDAddressSpace *vtd_as; - QLIST_ENTRY(IntelIOMMUNotifierNode) next; -}; - /* The iommu (DMAR) device state struct */ struct IntelIOMMUState { X86IOMMUState x86_iommu; @@ -295,7 +290,7 @@ struct IntelIOMMUState { GHashTable *vtd_as_by_busptr; /* VTDBus objects indexed by PCIBus* reference */ VTDBus *vtd_as_by_bus_num[VTD_PCI_BUS_MAX]; /* VTDBus objects indexed by bus number */ /* list of registered notifiers */ - QLIST_HEAD(, IntelIOMMUNotifierNode) notifiers_list; + QLIST_HEAD(, VTDAddressSpace) vtd_as_with_notifiers; /* interrupt remapping */ bool intr_enabled; /* Whether guest enabled IR */ From patchwork Mon Jul 23 20:16:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948009 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="akhJ/+Ih"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZCzb49cJz9s1x for ; Tue, 24 Jul 2018 06:40:11 +1000 (AEST) Received: from localhost ([::1]:36449 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhcm-0002zW-Mx for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 16:40:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41133) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhIj-0001qC-LD for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhIi-0003AC-01 for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:25 -0400 Received: from mail-oi0-x243.google.com ([2607:f8b0:4003:c06::243]:35583) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhIh-00039O-QK; Mon, 23 Jul 2018 16:19:23 -0400 Received: by mail-oi0-x243.google.com with SMTP id i12-v6so3496454oik.2; Mon, 23 Jul 2018 13:19:23 -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=sb7M4EUc94BWwVC5qCKsum8xHF/v2XM3EVTZC3M7T90=; b=akhJ/+IhHSYFLTkQhFslHXIGGfLMGW1HyNOKSIDnXjSysig2mllMjFj5wn7eh3VfrX od5GxzffDqXgG0fiGFVKu3mzMHqsojoRYd8nJBHF5OBlzE1rYe5ckBFjO78/X0Fq8cvp ovlYwtftCL3bUShBqGY7i3S6p3zdKAfyeHmjHTEjtjSDO/jHgEsINASHBPnmycBpS+Im fkyVmHnA7+Orh/9LtzheqWW1tt4Tifl7uQh/BeAfl2FUyGaR1g33b/6Rg4nUJKn8+STe KbmePrl6Bdl7I7ahbF6mMOIAqIe0YZKxa6wumEmoKQsQOTgVYyE1yiYUPNyfuZy8rItP aQnQ== 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=sb7M4EUc94BWwVC5qCKsum8xHF/v2XM3EVTZC3M7T90=; b=qmkjKjhLBn5uzIIqapnd1V3dJ9vqT0pzw18+8WM/tAuoiW8ANUx4nF9Y1dx0boly9l 9NbCwOKMgTrDU8Lg3iHHkUApXko0LvVfCQK86UnhvVLAkgIVsZFGhUAxTgIta+HCz5Sb xfx7Yv2eG3eMZSQag9stqDTejSnYLVpSzxJaESg+gORB61eJEoxLYiJj7JbGSihgGiOu BXweAaAt9k7I6QOKKl0kSIy17gAdJPbZU8S4CUhhsdoFk8j3iZnrLJEGKsdM3eCaPEdv oak8NQuvhYuplGX3ok2S36OTIeTMvIyELN6FTw74CqCla6b8GlueKSmmIwoeAVPXPMyA 23HQ== X-Gm-Message-State: AOUpUlGhy9/J+Hpy/x4jgKoYR0sKkpMHtUcMxbPvR/uET9xBZ8s0ASvF B4AM2nalEV7l89zrSw+zkW9xNhNh/cI= X-Google-Smtp-Source: AAOMgpf7zcLfyDpayl88wKHL8TrtrtlBHPPbvFjvKoBn7T7ouDiF96IF2Fcr9jQKCSr2GPS/dhBVQQ== X-Received: by 2002:aca:4fd1:: with SMTP id d200-v6mr328208oib.224.1532377162591; Mon, 23 Jul 2018 13:19:22 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id t131-v6sm8732593oie.34.2018.07.23.13.19.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:19:21 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:16:36 -0500 Message-Id: <20180723201748.25573-28-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::243 Subject: [Qemu-devel] [PATCH 27/99] intel-iommu: add iommu lock 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: qemu-stable@nongnu.org, Peter Xu , "Michael S . Tsirkin" Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Peter Xu SECURITY IMPLICATION: this patch fixes a potential race when multiple threads access the IOMMU IOTLB cache. Add a per-iommu big lock to protect IOMMU status. Currently the only thing to be protected is the IOTLB/context cache, since that can be accessed even without BQL, e.g., in IO dataplane. Note that we don't need to protect device page tables since that's fully controlled by the guest kernel. However there is still possibility that malicious drivers will program the device to not obey the rule. In that case QEMU can't really do anything useful, instead the guest itself will be responsible for all uncertainties. CC: QEMU Stable Reported-by: Fam Zheng Signed-off-by: Peter Xu Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin (cherry picked from commit 1d9efa73e12ddf361ea997c2d532cc4afa6674d1) Signed-off-by: Michael Roth --- hw/i386/intel_iommu.c | 56 +++++++++++++++++++++++++++++------ include/hw/i386/intel_iommu.h | 6 ++++ 2 files changed, 53 insertions(+), 9 deletions(-) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 3df90457f8..8d4069de9f 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -128,6 +128,16 @@ static uint64_t vtd_set_clear_mask_quad(IntelIOMMUState *s, hwaddr addr, return new_val; } +static inline void vtd_iommu_lock(IntelIOMMUState *s) +{ + qemu_mutex_lock(&s->iommu_lock); +} + +static inline void vtd_iommu_unlock(IntelIOMMUState *s) +{ + qemu_mutex_unlock(&s->iommu_lock); +} + /* GHashTable functions */ static gboolean vtd_uint64_equal(gconstpointer v1, gconstpointer v2) { @@ -172,9 +182,9 @@ static gboolean vtd_hash_remove_by_page(gpointer key, gpointer value, } /* Reset all the gen of VTDAddressSpace to zero and set the gen of - * IntelIOMMUState to 1. + * IntelIOMMUState to 1. Must be called with IOMMU lock held. */ -static void vtd_reset_context_cache(IntelIOMMUState *s) +static void vtd_reset_context_cache_locked(IntelIOMMUState *s) { VTDAddressSpace *vtd_as; VTDBus *vtd_bus; @@ -197,12 +207,20 @@ static void vtd_reset_context_cache(IntelIOMMUState *s) s->context_cache_gen = 1; } -static void vtd_reset_iotlb(IntelIOMMUState *s) +/* Must be called with IOMMU lock held. */ +static void vtd_reset_iotlb_locked(IntelIOMMUState *s) { assert(s->iotlb); g_hash_table_remove_all(s->iotlb); } +static void vtd_reset_iotlb(IntelIOMMUState *s) +{ + vtd_iommu_lock(s); + vtd_reset_iotlb_locked(s); + vtd_iommu_unlock(s); +} + static uint64_t vtd_get_iotlb_key(uint64_t gfn, uint16_t source_id, uint32_t level) { @@ -215,6 +233,7 @@ static uint64_t vtd_get_iotlb_gfn(hwaddr addr, uint32_t level) return (addr & vtd_slpt_level_page_mask(level)) >> VTD_PAGE_SHIFT_4K; } +/* Must be called with IOMMU lock held */ static VTDIOTLBEntry *vtd_lookup_iotlb(IntelIOMMUState *s, uint16_t source_id, hwaddr addr) { @@ -235,6 +254,7 @@ out: return entry; } +/* Must be with IOMMU lock held */ static void vtd_update_iotlb(IntelIOMMUState *s, uint16_t source_id, uint16_t domain_id, hwaddr addr, uint64_t slpte, uint8_t access_flags, uint32_t level) @@ -246,7 +266,7 @@ static void vtd_update_iotlb(IntelIOMMUState *s, uint16_t source_id, trace_vtd_iotlb_page_update(source_id, addr, slpte, domain_id); if (g_hash_table_size(s->iotlb) >= VTD_IOTLB_MAX_SIZE) { trace_vtd_iotlb_reset("iotlb exceeds size limit"); - vtd_reset_iotlb(s); + vtd_reset_iotlb_locked(s); } entry->gfn = gfn; @@ -1106,7 +1126,7 @@ static bool vtd_do_iommu_translate(VTDAddressSpace *vtd_as, PCIBus *bus, IntelIOMMUState *s = vtd_as->iommu_state; VTDContextEntry ce; uint8_t bus_num = pci_bus_num(bus); - VTDContextCacheEntry *cc_entry = &vtd_as->context_cache_entry; + VTDContextCacheEntry *cc_entry; uint64_t slpte, page_mask; uint32_t level; uint16_t source_id = vtd_make_source_id(bus_num, devfn); @@ -1123,6 +1143,10 @@ static bool vtd_do_iommu_translate(VTDAddressSpace *vtd_as, PCIBus *bus, */ assert(!vtd_is_interrupt_addr(addr)); + vtd_iommu_lock(s); + + cc_entry = &vtd_as->context_cache_entry; + /* Try to fetch slpte form IOTLB */ iotlb_entry = vtd_lookup_iotlb(s, source_id, addr); if (iotlb_entry) { @@ -1182,7 +1206,7 @@ static bool vtd_do_iommu_translate(VTDAddressSpace *vtd_as, PCIBus *bus, * IOMMU region can be swapped back. */ vtd_pt_enable_fast_path(s, source_id); - + vtd_iommu_unlock(s); return true; } @@ -1203,6 +1227,7 @@ static bool vtd_do_iommu_translate(VTDAddressSpace *vtd_as, PCIBus *bus, vtd_update_iotlb(s, source_id, VTD_CONTEXT_ENTRY_DID(ce.hi), addr, slpte, access_flags, level); out: + vtd_iommu_unlock(s); entry->iova = addr & page_mask; entry->translated_addr = vtd_get_slpte_addr(slpte, s->aw_bits) & page_mask; entry->addr_mask = ~page_mask; @@ -1210,6 +1235,7 @@ out: return true; error: + vtd_iommu_unlock(s); entry->iova = 0; entry->translated_addr = 0; entry->addr_mask = 0; @@ -1258,10 +1284,13 @@ static void vtd_iommu_replay_all(IntelIOMMUState *s) static void vtd_context_global_invalidate(IntelIOMMUState *s) { trace_vtd_inv_desc_cc_global(); + /* Protects context cache */ + vtd_iommu_lock(s); s->context_cache_gen++; if (s->context_cache_gen == VTD_CONTEXT_CACHE_GEN_MAX) { - vtd_reset_context_cache(s); + vtd_reset_context_cache_locked(s); } + vtd_iommu_unlock(s); vtd_switch_address_space_all(s); /* * From VT-d spec 6.5.2.1, a global context entry invalidation @@ -1313,7 +1342,9 @@ static void vtd_context_device_invalidate(IntelIOMMUState *s, if (vtd_as && ((devfn_it & mask) == (devfn & mask))) { trace_vtd_inv_desc_cc_device(bus_n, VTD_PCI_SLOT(devfn_it), VTD_PCI_FUNC(devfn_it)); + vtd_iommu_lock(s); vtd_as->context_cache_entry.context_cache_gen = 0; + vtd_iommu_unlock(s); /* * Do switch address space when needed, in case if the * device passthrough bit is switched. @@ -1377,8 +1408,10 @@ static void vtd_iotlb_domain_invalidate(IntelIOMMUState *s, uint16_t domain_id) trace_vtd_inv_desc_iotlb_domain(domain_id); + vtd_iommu_lock(s); g_hash_table_foreach_remove(s->iotlb, vtd_hash_remove_by_domain, &domain_id); + vtd_iommu_unlock(s); QLIST_FOREACH(vtd_as, &s->vtd_as_with_notifiers, next) { if (!vtd_dev_to_context_entry(s, pci_bus_num(vtd_as->bus), @@ -1426,7 +1459,9 @@ static void vtd_iotlb_page_invalidate(IntelIOMMUState *s, uint16_t domain_id, info.domain_id = domain_id; info.addr = addr; info.mask = ~((1 << am) - 1); + vtd_iommu_lock(s); g_hash_table_foreach_remove(s->iotlb, vtd_hash_remove_by_page, &info); + vtd_iommu_unlock(s); vtd_iotlb_page_invalidate_notify(s, domain_id, addr, am); } @@ -2929,8 +2964,10 @@ static void vtd_init(IntelIOMMUState *s) s->cap |= VTD_CAP_CM; } - vtd_reset_context_cache(s); - vtd_reset_iotlb(s); + vtd_iommu_lock(s); + vtd_reset_context_cache_locked(s); + vtd_reset_iotlb_locked(s); + vtd_iommu_unlock(s); /* Define registers with default values and bit semantics */ vtd_define_long(s, DMAR_VER_REG, 0x10UL, 0, 0); @@ -3070,6 +3107,7 @@ static void vtd_realize(DeviceState *dev, Error **errp) } QLIST_INIT(&s->vtd_as_with_notifiers); + qemu_mutex_init(&s->iommu_lock); memset(s->vtd_as_by_bus_num, 0, sizeof(s->vtd_as_by_bus_num)); memory_region_init_io(&s->csrmem, OBJECT(s), &vtd_mem_ops, s, "intel_iommu", DMAR_REG_SIZE); diff --git a/include/hw/i386/intel_iommu.h b/include/hw/i386/intel_iommu.h index 032e33bcb2..016e74bedb 100644 --- a/include/hw/i386/intel_iommu.h +++ b/include/hw/i386/intel_iommu.h @@ -300,6 +300,12 @@ struct IntelIOMMUState { OnOffAuto intr_eim; /* Toggle for EIM cabability */ bool buggy_eim; /* Force buggy EIM unless eim=off */ uint8_t aw_bits; /* Host/IOVA address width (in bits) */ + + /* + * Protects IOMMU states in general. Currently it protects the + * per-IOMMU IOTLB cache, and context entry cache in VTDAddressSpace. + */ + QemuMutex iommu_lock; }; /* Find the VTD Address space associated with the given bus pointer, From patchwork Mon Jul 23 20:16:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948008 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="FNnFu+zC"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZCz16pxwz9s1x for ; Tue, 24 Jul 2018 06:39:41 +1000 (AEST) Received: from localhost ([::1]:36445 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhcJ-0002bE-HU for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 16:39:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41154) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhIl-0001qu-SQ for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhIk-0003Cd-7M for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:27 -0400 Received: from mail-oi0-x231.google.com ([2607:f8b0:4003:c06::231]:42531) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhIk-0003CN-1V; Mon, 23 Jul 2018 16:19:26 -0400 Received: by mail-oi0-x231.google.com with SMTP id n84-v6so3462201oib.9; Mon, 23 Jul 2018 13:19:25 -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=GyQ1vIoBPmPJ8juY4kfmrKlZq3tVvoPLM+z7ItIsYqA=; b=FNnFu+zCcsVQXYF7KuVLwEFBh/p3B9OL4PIv74/fjdnN9lBIRwYY3TjO5iHP8xisK0 81SB+dCxVPszPhDXVGsXAW/tMv31dlHnBU/L+UnKKFd7A80MdD+ydBFnayTSZblEQq8a D+49y86C2BS7FDlBgHViKNxA2h2hQ9JjcCaSL6diTffdX9yzvhBtxvT1ChOxbwn0njFG 1q7htsO6jy5s5cut8lyYOyh49eps5Gg7cMyqyJEwgCsDJTeamnpYSAtRbncHXMmlam7B RE4iVBVQFtxRs7ynUfvWUfxPw882GE8Srbut+uqxkIDyMFqNQIwhKhpQSe/uSGl2UH/K PyMw== 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=GyQ1vIoBPmPJ8juY4kfmrKlZq3tVvoPLM+z7ItIsYqA=; b=rGROOiUYjdly4tBF6jAkJoPj/qStSnW7UPiGaCytjYoZ7cv5QXlVu8u9zuJcT+0Tew AtwTeLvplxkcGPjBT4tpgAp9hXBVdBxaUlKKTdD2xUNnn/hMoN5IHHQO6XFYzB4VxXzA WZDMnsRd1XmZxF0uh1m6CqPLbRd2C0jljKo8POZKw2G0PQc/m8hGaUNAekTgMnQOeydg MF+PAjcfJm9qbj5vO2UzGHY2AfJ4mH+LrF9gR2Yctu0vlwMmttDQ8Iwn8LeF2nmq9fPc 5TslKKgJabcKIdjGnHiZ7fI7TXgbfsUhEDeDZ/cTGT9PQXTiQGkZF1ULUFRu7i7H0TK2 IlUA== X-Gm-Message-State: AOUpUlHNCTTR+uVq0WZh//Zh1h+hvgbrKEkUT0yzQ5CX6qTSAlFeZMgl So/3e8UQVhMIez794hpXQisJEqq0ius= X-Google-Smtp-Source: AAOMgpemIH7vNUBt/qY1/j6/lh4WXoFmGml4m+Zbt6hP/5QTseIFUEt0nASTulFmXIkgC7k2L1uT1A== X-Received: by 2002:aca:cf43:: with SMTP id f64-v6mr307286oig.113.1532377164820; Mon, 23 Jul 2018 13:19:24 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id y85-v6sm10623996oie.25.2018.07.23.13.19.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:19:23 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:16:37 -0500 Message-Id: <20180723201748.25573-29-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::231 Subject: [Qemu-devel] [PATCH 28/99] intel-iommu: only do page walk for MAP notifiers 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: qemu-stable@nongnu.org, Peter Xu , "Michael S . Tsirkin" Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Peter Xu For UNMAP-only IOMMU notifiers, we don't need to walk the page tables. Fasten that procedure by skipping the page table walk. That should boost performance for UNMAP-only notifiers like vhost. CC: QEMU Stable Signed-off-by: Peter Xu Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin (cherry picked from commit 4f8a62a933a79094e44bc1b16b63bb23e62d67b4) Signed-off-by: Michael Roth --- hw/i386/intel_iommu.c | 44 +++++++++++++++++++++++++++++++---- include/hw/i386/intel_iommu.h | 2 ++ 2 files changed, 41 insertions(+), 5 deletions(-) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 8d4069de9f..38ccc741f9 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -138,6 +138,12 @@ static inline void vtd_iommu_unlock(IntelIOMMUState *s) qemu_mutex_unlock(&s->iommu_lock); } +/* Whether the address space needs to notify new mappings */ +static inline gboolean vtd_as_has_map_notifier(VTDAddressSpace *as) +{ + return as->notifier_flags & IOMMU_NOTIFIER_MAP; +} + /* GHashTable functions */ static gboolean vtd_uint64_equal(gconstpointer v1, gconstpointer v2) { @@ -1436,14 +1442,36 @@ static void vtd_iotlb_page_invalidate_notify(IntelIOMMUState *s, VTDAddressSpace *vtd_as; VTDContextEntry ce; int ret; + hwaddr size = (1 << am) * VTD_PAGE_SIZE; QLIST_FOREACH(vtd_as, &(s->vtd_as_with_notifiers), next) { ret = vtd_dev_to_context_entry(s, pci_bus_num(vtd_as->bus), vtd_as->devfn, &ce); if (!ret && domain_id == VTD_CONTEXT_ENTRY_DID(ce.hi)) { - vtd_page_walk(&ce, addr, addr + (1 << am) * VTD_PAGE_SIZE, - vtd_page_invalidate_notify_hook, - (void *)&vtd_as->iommu, true, s->aw_bits); + if (vtd_as_has_map_notifier(vtd_as)) { + /* + * As long as we have MAP notifications registered in + * any of our IOMMU notifiers, we need to sync the + * shadow page table. + */ + vtd_page_walk(&ce, addr, addr + size, + vtd_page_invalidate_notify_hook, + (void *)&vtd_as->iommu, true, s->aw_bits); + } else { + /* + * For UNMAP-only notifiers, we don't need to walk the + * page tables. We just deliver the PSI down to + * invalidate caches. + */ + IOMMUTLBEntry entry = { + .target_as = &address_space_memory, + .iova = addr, + .translated_addr = 0, + .addr_mask = size - 1, + .perm = IOMMU_NONE, + }; + memory_region_notify_iommu(&vtd_as->iommu, entry); + } } } } @@ -2383,6 +2411,9 @@ static void vtd_iommu_notify_flag_changed(IOMMUMemoryRegion *iommu, exit(1); } + /* Update per-address-space notifier flags */ + vtd_as->notifier_flags = new; + if (old == IOMMU_NOTIFIER_NONE) { QLIST_INSERT_HEAD(&s->vtd_as_with_notifiers, vtd_as, next); } else if (new == IOMMU_NOTIFIER_NONE) { @@ -2891,8 +2922,11 @@ static void vtd_iommu_replay(IOMMUMemoryRegion *iommu_mr, IOMMUNotifier *n) PCI_FUNC(vtd_as->devfn), VTD_CONTEXT_ENTRY_DID(ce.hi), ce.hi, ce.lo); - vtd_page_walk(&ce, 0, ~0ULL, vtd_replay_hook, (void *)n, false, - s->aw_bits); + if (vtd_as_has_map_notifier(vtd_as)) { + /* This is required only for MAP typed notifiers */ + vtd_page_walk(&ce, 0, ~0ULL, vtd_replay_hook, (void *)n, false, + s->aw_bits); + } } else { trace_vtd_replay_ce_invalid(bus_n, PCI_SLOT(vtd_as->devfn), PCI_FUNC(vtd_as->devfn)); diff --git a/include/hw/i386/intel_iommu.h b/include/hw/i386/intel_iommu.h index 016e74bedb..156f35e919 100644 --- a/include/hw/i386/intel_iommu.h +++ b/include/hw/i386/intel_iommu.h @@ -93,6 +93,8 @@ struct VTDAddressSpace { IntelIOMMUState *iommu_state; VTDContextCacheEntry context_cache_entry; QLIST_ENTRY(VTDAddressSpace) next; + /* Superset of notifier flags that this address space has */ + IOMMUNotifierFlag notifier_flags; }; struct VTDBus { From patchwork Mon Jul 23 20:16:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948014 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="OiBmzysL"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZD2p1JnQz9s4V for ; Tue, 24 Jul 2018 06:42:58 +1000 (AEST) Received: from localhost ([::1]:36468 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhfT-0005Xf-QA for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 16:42:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41204) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhIo-0001tg-4c for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhIm-0003GH-JT for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:30 -0400 Received: from mail-oi0-x233.google.com ([2607:f8b0:4003:c06::233]:44630) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhIm-0003FU-9I; Mon, 23 Jul 2018 16:19:28 -0400 Received: by mail-oi0-x233.google.com with SMTP id s198-v6so3458464oih.11; Mon, 23 Jul 2018 13:19:28 -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=JCJJqx1WZVulnTd+qY2Ldfx2VPksywZR7hBjYoCb3hM=; b=OiBmzysLLzMVdjFSWZtwQmhiWzdnUHTZKk6zk2f/RCtcipWgvQmXmito6nW27iv6VO vSIzibX+hpSsHISDwBJ5GDjQzI94XOa/V+vOSzmnPrF2LzFrEJBVzvZugakzanQppYz6 LHo2KJUSWRvnecdNAHW37X76KnLAjymzvlne0rvOsLSgmteuBXojIffwj5FPreL25Lm/ b6hKkgntHsHlJYrdeb/01hlk6MkqcaDli9l4/3OmwHSct9vShHTYPtplpuxTRTVqiKEt JNbODOb/ttSFE9cFOqvWtQz20ujbDOSuldytRxzV2TZFcbFJNsw4VagSbC01B97braNR aaMQ== 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=JCJJqx1WZVulnTd+qY2Ldfx2VPksywZR7hBjYoCb3hM=; b=XGuNQRvgLZA3GrBAuH96qckEF3DrNiocvc3AQ3G0nduP6Jlm4/6vtiCokXHtAoKNIv 8eWsyoVTUZP5VZuXru28aKjS89Jjs2aUpjfFvUs8SDzJrkwUeiPjFJ4hLiWz7Sap2PSx QBQaJv/MAOnEJRyO8xYDqEG3IrF2WDqSBBEcW6U5On63tRha/0TjH7wkwXb0V5XZdN8o IoWUbgfb0F8CwYOipPiK+2aODvLaj6t+9whFHOTpy/V/iDl14F0HuBcKg4EK5pFzN+Rp fojMVsRftrtBnIN0YhcSt/a3osl0YuvTjamcC7suS2rBcwub9obrbbmILyaF6NSoaSRF DS8Q== X-Gm-Message-State: AOUpUlH4OP8remUwm+1BhbL1TyjM4NmSTuuDIAtxUCdbuRnCtmylx0j2 jWJhfgpUWjfXIWvE4+xl4tLrefBGKok= X-Google-Smtp-Source: AAOMgpdZlwqz7QNPnCY7NENrVfalAEZki+U6Tjj1H0IzbK+DPEiPfTjHyFo6/kOSQ0Dg4OLsmHlrJw== X-Received: by 2002:aca:edc1:: with SMTP id l184-v6mr273623oih.65.1532377167100; Mon, 23 Jul 2018 13:19:27 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id i204-v6sm19817120oia.41.2018.07.23.13.19.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:19:26 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:16:38 -0500 Message-Id: <20180723201748.25573-30-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::233 Subject: [Qemu-devel] [PATCH 29/99] intel-iommu: introduce vtd_page_walk_info 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: qemu-stable@nongnu.org, Peter Xu , "Michael S . Tsirkin" Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Peter Xu During the recursive page walking of IOVA page tables, some stack variables are constant variables and never changed during the whole page walking procedure. Isolate them into a struct so that we don't need to pass those contants down the stack every time and multiple times. CC: QEMU Stable Signed-off-by: Peter Xu Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin (cherry picked from commit fe215b0cbb8c1f4b4af0a64aa5c02042080dd537) Signed-off-by: Michael Roth --- hw/i386/intel_iommu.c | 84 ++++++++++++++++++++++++++----------------- 1 file changed, 52 insertions(+), 32 deletions(-) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 38ccc741f9..e247269659 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -748,9 +748,27 @@ static int vtd_iova_to_slpte(VTDContextEntry *ce, uint64_t iova, bool is_write, typedef int (*vtd_page_walk_hook)(IOMMUTLBEntry *entry, void *private); +/** + * Constant information used during page walking + * + * @hook_fn: hook func to be called when detected page + * @private: private data to be passed into hook func + * @notify_unmap: whether we should notify invalid entries + * @aw: maximum address width + */ +typedef struct { + vtd_page_walk_hook hook_fn; + void *private; + bool notify_unmap; + uint8_t aw; +} vtd_page_walk_info; + static int vtd_page_walk_one(IOMMUTLBEntry *entry, int level, - vtd_page_walk_hook hook_fn, void *private) + vtd_page_walk_info *info) { + vtd_page_walk_hook hook_fn = info->hook_fn; + void *private = info->private; + assert(hook_fn); trace_vtd_page_walk_one(level, entry->iova, entry->translated_addr, entry->addr_mask, entry->perm); @@ -763,17 +781,13 @@ static int vtd_page_walk_one(IOMMUTLBEntry *entry, int level, * @addr: base GPA addr to start the walk * @start: IOVA range start address * @end: IOVA range end address (start <= addr < end) - * @hook_fn: hook func to be called when detected page - * @private: private data to be passed into hook func * @read: whether parent level has read permission * @write: whether parent level has write permission - * @notify_unmap: whether we should notify invalid entries - * @aw: maximum address width + * @info: constant information for the page walk */ static int vtd_page_walk_level(dma_addr_t addr, uint64_t start, - uint64_t end, vtd_page_walk_hook hook_fn, - void *private, uint32_t level, bool read, - bool write, bool notify_unmap, uint8_t aw) + uint64_t end, uint32_t level, bool read, + bool write, vtd_page_walk_info *info) { bool read_cur, write_cur, entry_valid; uint32_t offset; @@ -823,24 +837,24 @@ static int vtd_page_walk_level(dma_addr_t addr, uint64_t start, if (vtd_is_last_slpte(slpte, level)) { /* NOTE: this is only meaningful if entry_valid == true */ - entry.translated_addr = vtd_get_slpte_addr(slpte, aw); - if (!entry_valid && !notify_unmap) { + entry.translated_addr = vtd_get_slpte_addr(slpte, info->aw); + if (!entry_valid && !info->notify_unmap) { trace_vtd_page_walk_skip_perm(iova, iova_next); goto next; } - ret = vtd_page_walk_one(&entry, level, hook_fn, private); + ret = vtd_page_walk_one(&entry, level, info); if (ret < 0) { return ret; } } else { if (!entry_valid) { - if (notify_unmap) { + if (info->notify_unmap) { /* * The whole entry is invalid; unmap it all. * Translated address is meaningless, zero it. */ entry.translated_addr = 0x0; - ret = vtd_page_walk_one(&entry, level, hook_fn, private); + ret = vtd_page_walk_one(&entry, level, info); if (ret < 0) { return ret; } @@ -849,10 +863,9 @@ static int vtd_page_walk_level(dma_addr_t addr, uint64_t start, } goto next; } - ret = vtd_page_walk_level(vtd_get_slpte_addr(slpte, aw), iova, - MIN(iova_next, end), hook_fn, private, - level - 1, read_cur, write_cur, - notify_unmap, aw); + ret = vtd_page_walk_level(vtd_get_slpte_addr(slpte, info->aw), + iova, MIN(iova_next, end), level - 1, + read_cur, write_cur, info); if (ret < 0) { return ret; } @@ -871,28 +884,24 @@ next: * @ce: context entry to walk upon * @start: IOVA address to start the walk * @end: IOVA range end address (start <= addr < end) - * @hook_fn: the hook that to be called for each detected area - * @private: private data for the hook function - * @aw: maximum address width + * @info: page walking information struct */ static int vtd_page_walk(VTDContextEntry *ce, uint64_t start, uint64_t end, - vtd_page_walk_hook hook_fn, void *private, - bool notify_unmap, uint8_t aw) + vtd_page_walk_info *info) { dma_addr_t addr = vtd_ce_get_slpt_base(ce); uint32_t level = vtd_ce_get_level(ce); - if (!vtd_iova_range_check(start, ce, aw)) { + if (!vtd_iova_range_check(start, ce, info->aw)) { return -VTD_FR_ADDR_BEYOND_MGAW; } - if (!vtd_iova_range_check(end, ce, aw)) { + if (!vtd_iova_range_check(end, ce, info->aw)) { /* Fix end so that it reaches the maximum */ - end = vtd_iova_limit(ce, aw); + end = vtd_iova_limit(ce, info->aw); } - return vtd_page_walk_level(addr, start, end, hook_fn, private, - level, true, true, notify_unmap, aw); + return vtd_page_walk_level(addr, start, end, level, true, true, info); } /* Map a device to its corresponding domain (context-entry) */ @@ -1449,14 +1458,19 @@ static void vtd_iotlb_page_invalidate_notify(IntelIOMMUState *s, vtd_as->devfn, &ce); if (!ret && domain_id == VTD_CONTEXT_ENTRY_DID(ce.hi)) { if (vtd_as_has_map_notifier(vtd_as)) { + vtd_page_walk_info info = { + .hook_fn = vtd_page_invalidate_notify_hook, + .private = (void *)&vtd_as->iommu, + .notify_unmap = true, + .aw = s->aw_bits, + }; + /* * As long as we have MAP notifications registered in * any of our IOMMU notifiers, we need to sync the * shadow page table. */ - vtd_page_walk(&ce, addr, addr + size, - vtd_page_invalidate_notify_hook, - (void *)&vtd_as->iommu, true, s->aw_bits); + vtd_page_walk(&ce, addr, addr + size, &info); } else { /* * For UNMAP-only notifiers, we don't need to walk the @@ -2924,8 +2938,14 @@ static void vtd_iommu_replay(IOMMUMemoryRegion *iommu_mr, IOMMUNotifier *n) ce.hi, ce.lo); if (vtd_as_has_map_notifier(vtd_as)) { /* This is required only for MAP typed notifiers */ - vtd_page_walk(&ce, 0, ~0ULL, vtd_replay_hook, (void *)n, false, - s->aw_bits); + vtd_page_walk_info info = { + .hook_fn = vtd_replay_hook, + .private = (void *)n, + .notify_unmap = false, + .aw = s->aw_bits, + }; + + vtd_page_walk(&ce, 0, ~0ULL, &info); } } else { trace_vtd_replay_ce_invalid(bus_n, PCI_SLOT(vtd_as->devfn), From patchwork Mon Jul 23 20:16:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948006 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="nzUZmoYs"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZCxY533sz9s1x for ; Tue, 24 Jul 2018 06:38:25 +1000 (AEST) Received: from localhost ([::1]:36438 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhb5-0001dH-88 for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 16:38:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41220) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhIq-0001vg-9R for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhIp-0003ML-0J for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:32 -0400 Received: from mail-oi0-x230.google.com ([2607:f8b0:4003:c06::230]:40342) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhIo-0003Ky-Qe; Mon, 23 Jul 2018 16:19:30 -0400 Received: by mail-oi0-x230.google.com with SMTP id w126-v6so3472311oie.7; Mon, 23 Jul 2018 13:19:30 -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=mpLWXbe+qyMbEN0pvvW1x3gz13gRdbpJPpr5HZeanew=; b=nzUZmoYsZLajiPV6WglYIbZIyuC6Jhx4uEc4asMpllrflFf5lvXDwluKrXfMshTdmj iWjjOPKQjJ4EBtW7x7Evvi9ak5W+XgrHy8H8eIUEynwZuhUht8B8EiBX5IH7Lz8fmjsN wW6p/BoxF+GoldCGsNa4c8k3cBDZqeKoLUc6J3r3SEBv8lawNStC8FiK51UPXygp25Wz khTJUPEhAANsBoo2e1blT8T/irjuzYOuXeaAn43pRN/xMXM4lSROeMg0hHObk882Ebxk pguZOUOSviYGWrq/BXO1dTkAUPrtiRLKMP3wd6KPfLAAHuQJo63nEH65qIRm0rhCjCWY ERaA== 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=mpLWXbe+qyMbEN0pvvW1x3gz13gRdbpJPpr5HZeanew=; b=lnVBeDNU8375RlOejEwvcVnC4TQH1c8kzSIJO+BLxDh5Z3ja8i8pFhh51ajSEpRP0S Yl9l1bpyZHcDW4Kww4YRiQwcfaHv7ynxqnpYzwGYpiy2tWvQ7sEqjY98d1abzDQf/N1w +xo9SNHl4P3n2nPsXm+ejfA/s7gTFgdEGBBH/aD+dMORa66f++VMf5bN3U5EaI+gDZ6p ZNtHl6ovV9bAbNrrgPrBv4n0BuFZmhcV7Z6wIV5VHuBz337uDt1SmwctmF/hoWA7I0o/ vM9HwPNmZbsK06JsPVy30mxAVaOVD1Vg/TSgO3TVTprmxs+KNSYzpxJJ8ZZcVJXWTlg6 Nuvg== X-Gm-Message-State: AOUpUlGQ007GEPWtILaoz9WeJmQK0l7ILK361UBWOREO02TZISWDVzh0 H0DmiTBAfMij6oPwrMq4u2T1G5gzuAY= X-Google-Smtp-Source: AAOMgpfT9d5e64S0NwiZ/9OtkBeL+mcLcUMV6Fs7i7OqM0eP3XX/fIuuvP19vgR83ZJ3AMBNw5IDEw== X-Received: by 2002:aca:b7c3:: with SMTP id h186-v6mr306524oif.54.1532377169694; Mon, 23 Jul 2018 13:19:29 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id p4-v6sm11150876oig.43.2018.07.23.13.19.27 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:19:28 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:16:39 -0500 Message-Id: <20180723201748.25573-31-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::230 Subject: [Qemu-devel] [PATCH 30/99] intel-iommu: pass in address space when page walk 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: qemu-stable@nongnu.org, Peter Xu , "Michael S . Tsirkin" Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Peter Xu We pass in the VTDAddressSpace too. It'll be used in the follow up patches. CC: QEMU Stable Signed-off-by: Peter Xu Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin (cherry picked from commit 2f764fa87d2a81812b313dd6d998e10126292653) Signed-off-by: Michael Roth --- hw/i386/intel_iommu.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index e247269659..a882894f49 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -754,9 +754,11 @@ typedef int (*vtd_page_walk_hook)(IOMMUTLBEntry *entry, void *private); * @hook_fn: hook func to be called when detected page * @private: private data to be passed into hook func * @notify_unmap: whether we should notify invalid entries + * @as: VT-d address space of the device * @aw: maximum address width */ typedef struct { + VTDAddressSpace *as; vtd_page_walk_hook hook_fn; void *private; bool notify_unmap; @@ -1463,6 +1465,7 @@ static void vtd_iotlb_page_invalidate_notify(IntelIOMMUState *s, .private = (void *)&vtd_as->iommu, .notify_unmap = true, .aw = s->aw_bits, + .as = vtd_as, }; /* @@ -2943,6 +2946,7 @@ static void vtd_iommu_replay(IOMMUMemoryRegion *iommu_mr, IOMMUNotifier *n) .private = (void *)n, .notify_unmap = false, .aw = s->aw_bits, + .as = vtd_as, }; vtd_page_walk(&ce, 0, ~0ULL, &info); From patchwork Mon Jul 23 20:16:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948011 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="h640N5GD"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZD1K1bNBz9s4Z for ; Tue, 24 Jul 2018 06:41:41 +1000 (AEST) Received: from localhost ([::1]:36460 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhheE-0004TU-PN for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 16:41:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41278) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhIu-00024v-Bn for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhIt-0003WZ-7v for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:36 -0400 Received: from mail-oi0-x243.google.com ([2607:f8b0:4003:c06::243]:46052) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhIt-0003V9-0c; Mon, 23 Jul 2018 16:19:35 -0400 Received: by mail-oi0-x243.google.com with SMTP id q11-v6so3445797oic.12; Mon, 23 Jul 2018 13:19:34 -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=WOZC3pqoGeotZ1mreXhAi+nVK6kqI0RZ7Qp3NXO0dn8=; b=h640N5GD63yTY/oc8poQ19SjC7VQX/1TtXL4sCPJHe5MwCmoDpuv80ecLqZGcHuzLT FP8Yc8+9mRHgaPMaPJrZ8TT0GOR0GZ6FDqrlZ28OMRlngSvOxA9oB57bP2IUBnot4T9F gSGLhWIvqtiTtWkYEaOIN7tarWKPTs5OMRog7ieHtfha8EmNtHaciJtwZf/GZeikbU/F wWCvbvgY7C4Y/RSk+gRzrScA0zqnv4eHsb8dwq3wu22ny+/zpnc8L24iNOmMKjGh5Uq+ PfjpWWve9cYIxFnpfk1+8oOxNUrwWE/+hAA8Pi8DCSfPc2vhigf7t0anpK3Z4awfvkaG qIGw== 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=WOZC3pqoGeotZ1mreXhAi+nVK6kqI0RZ7Qp3NXO0dn8=; b=uCIu/G9EreN0zkbpwyU6LtZQGF8Ps6slhW+Dyfp+EfSYga8zyqovjcHUwJNmgULPIT HcjXaYjy/YFdHn3QU9cnbU4m+oKa4SaKO1brqSbgSSheV/cF1wN+ko/hjnK+8YKLP2Hk Y1KrbalLitmYtmxARmAqprRFhV/seRylnMCcbE4TtfWA+C5ZeZeoHWOghp8IJOJlexc+ LtQX3u8i+LMc9S7X2ykIzNu1WPPpsS1AY6ylt+IwhK/RD3TgSVcV/B/MvLcYi01G+ftD m5y2SDIlSx8FPDpA0HgRJ53+G1mAzh4uR63YyQpYo3ho9YO22QLkvcSyncjZOCUAOwFd wuwg== X-Gm-Message-State: AOUpUlHa5bHYZdW42RXPY6m5sITOrPIscSZddbhltWCXClk48N+YfdAL 2W1e9lGKseSzMABDqXIRtTmC2YRH9eE= X-Google-Smtp-Source: AAOMgpfG+951j0L1QDgnXTlAionbGzh37lwm6oA8zAXOSc+XBs69EcRu6tGg9bH+P62apwYuOSMYkQ== X-Received: by 2002:aca:b641:: with SMTP id g62-v6mr324391oif.71.1532377173857; Mon, 23 Jul 2018 13:19:33 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id f75-v6sm17893826oig.53.2018.07.23.13.19.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:19:32 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:16:40 -0500 Message-Id: <20180723201748.25573-32-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::243 Subject: [Qemu-devel] [PATCH 31/99] intel-iommu: trace domain id during page walk 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: qemu-stable@nongnu.org, Peter Xu , "Michael S . Tsirkin" Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Peter Xu This patch only modifies the trace points. Previously we were tracing page walk levels. They are redundant since we have page mask (size) already. Now we trace something much more useful which is the domain ID of the page walking. That can be very useful when we trace more than one devices on the same system, so that we can know which map is for which domain. CC: QEMU Stable Signed-off-by: Peter Xu Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin (cherry picked from commit d118c06ebbee2d23ddf873cae4a809311aa61310) Signed-off-by: Michael Roth --- hw/i386/intel_iommu.c | 16 ++++++++++------ hw/i386/trace-events | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index a882894f49..61bb3d31e7 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -756,6 +756,7 @@ typedef int (*vtd_page_walk_hook)(IOMMUTLBEntry *entry, void *private); * @notify_unmap: whether we should notify invalid entries * @as: VT-d address space of the device * @aw: maximum address width + * @domain: domain ID of the page walk */ typedef struct { VTDAddressSpace *as; @@ -763,17 +764,18 @@ typedef struct { void *private; bool notify_unmap; uint8_t aw; + uint16_t domain_id; } vtd_page_walk_info; -static int vtd_page_walk_one(IOMMUTLBEntry *entry, int level, - vtd_page_walk_info *info) +static int vtd_page_walk_one(IOMMUTLBEntry *entry, vtd_page_walk_info *info) { vtd_page_walk_hook hook_fn = info->hook_fn; void *private = info->private; assert(hook_fn); - trace_vtd_page_walk_one(level, entry->iova, entry->translated_addr, - entry->addr_mask, entry->perm); + trace_vtd_page_walk_one(info->domain_id, entry->iova, + entry->translated_addr, entry->addr_mask, + entry->perm); return hook_fn(entry, private); } @@ -844,7 +846,7 @@ static int vtd_page_walk_level(dma_addr_t addr, uint64_t start, trace_vtd_page_walk_skip_perm(iova, iova_next); goto next; } - ret = vtd_page_walk_one(&entry, level, info); + ret = vtd_page_walk_one(&entry, info); if (ret < 0) { return ret; } @@ -856,7 +858,7 @@ static int vtd_page_walk_level(dma_addr_t addr, uint64_t start, * Translated address is meaningless, zero it. */ entry.translated_addr = 0x0; - ret = vtd_page_walk_one(&entry, level, info); + ret = vtd_page_walk_one(&entry, info); if (ret < 0) { return ret; } @@ -1466,6 +1468,7 @@ static void vtd_iotlb_page_invalidate_notify(IntelIOMMUState *s, .notify_unmap = true, .aw = s->aw_bits, .as = vtd_as, + .domain_id = domain_id, }; /* @@ -2947,6 +2950,7 @@ static void vtd_iommu_replay(IOMMUMemoryRegion *iommu_mr, IOMMUNotifier *n) .notify_unmap = false, .aw = s->aw_bits, .as = vtd_as, + .domain_id = VTD_CONTEXT_ENTRY_DID(ce.hi), }; vtd_page_walk(&ce, 0, ~0ULL, &info); diff --git a/hw/i386/trace-events b/hw/i386/trace-events index 22d44648af..ca23ba9fad 100644 --- a/hw/i386/trace-events +++ b/hw/i386/trace-events @@ -39,7 +39,7 @@ vtd_fault_disabled(void) "Fault processing disabled for context entry" vtd_replay_ce_valid(uint8_t bus, uint8_t dev, uint8_t fn, uint16_t domain, uint64_t hi, uint64_t lo) "replay valid context device %02"PRIx8":%02"PRIx8".%02"PRIx8" domain 0x%"PRIx16" hi 0x%"PRIx64" lo 0x%"PRIx64 vtd_replay_ce_invalid(uint8_t bus, uint8_t dev, uint8_t fn) "replay invalid context device %02"PRIx8":%02"PRIx8".%02"PRIx8 vtd_page_walk_level(uint64_t addr, uint32_t level, uint64_t start, uint64_t end) "walk (base=0x%"PRIx64", level=%"PRIu32") iova range 0x%"PRIx64" - 0x%"PRIx64 -vtd_page_walk_one(uint32_t level, uint64_t iova, uint64_t gpa, uint64_t mask, int perm) "detected page level 0x%"PRIx32" iova 0x%"PRIx64" -> gpa 0x%"PRIx64" mask 0x%"PRIx64" perm %d" +vtd_page_walk_one(uint16_t domain, uint64_t iova, uint64_t gpa, uint64_t mask, int perm) "domain 0x%"PRIu16" iova 0x%"PRIx64" -> gpa 0x%"PRIx64" mask 0x%"PRIx64" perm %d" vtd_page_walk_skip_read(uint64_t iova, uint64_t next) "Page walk skip iova 0x%"PRIx64" - 0x%"PRIx64" due to unable to read" vtd_page_walk_skip_perm(uint64_t iova, uint64_t next) "Page walk skip iova 0x%"PRIx64" - 0x%"PRIx64" due to perm empty" vtd_page_walk_skip_reserve(uint64_t iova, uint64_t next) "Page walk skip iova 0x%"PRIx64" - 0x%"PRIx64" due to rsrv set" From patchwork Mon Jul 23 20:16:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948002 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="YjkV1NHG"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZCtn3mLVz9s1x for ; Tue, 24 Jul 2018 06:36:01 +1000 (AEST) Received: from localhost ([::1]:36426 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhYl-0008Cu-4v for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 16:35:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41322) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhIx-00028I-9Y for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhIv-0003c6-Hi for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:39 -0400 Received: from mail-oi0-x244.google.com ([2607:f8b0:4003:c06::244]:46626) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhIv-0003bJ-AV; Mon, 23 Jul 2018 16:19:37 -0400 Received: by mail-oi0-x244.google.com with SMTP id y207-v6so3454222oie.13; Mon, 23 Jul 2018 13:19:37 -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=rAyHxefDtpGxJaBShyBX1rBK6cXw7xKm2QP+sdhWplQ=; b=YjkV1NHGNyXDgbbAYHJXFOpn30H6j09xBEzOqQ5OjspUo1/taJNlDOr4z8+urJ4wVR LCtF8eY2+zJ9EGOd/pSycvnnyDjhsmyXY/GN8rI0xbfiAS/I7K+VBW7HhDOPinwcnhmF adveOuJxx5PQqByGZC/PpqV6U9/57nxIVFDuyqxwua0gAYvvZlvwz01aCxYyCogOAoiC 81aBvwRHQ2yhprAB9wODpkwZfPqAGBbcJoPrgra8im8VciVyCOYrg8162LIz4WjetyPQ kg5W1VABPDTMvh9dIprOJ/AZfvPscV80bQ8ynjqO3EzALT+UPjRrVBjeexIiSye5iOCP Cs4A== 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=rAyHxefDtpGxJaBShyBX1rBK6cXw7xKm2QP+sdhWplQ=; b=HTgl07ZTbkcmoko8QQdkjYtEurxVj4F+Mtxr4zBgG3cd5/eM6lE0UsMIzjQMmbd3ca Huc4um1XYU8BSZCOUUa1jJOTrkRPtQoN/yBFDntU0/QBB8qPju3eywNC/l9YF8+JOYru Ut2pZKTlje1Gjqkl9oCWlHR2LOT8WlteDHyr+QhoixJrEq0+hNyDvgpqO35eV9DoNW3E El1Lbcqf0WMh52CmB7/jjQcZfPfOF9uAGBE1iYJPUaMRahWVKM5rIPtb7MSzgIAsu7QO sPuw4jZzFiDvUyf2BJmqEvBOfZsoxR1wfe1YVfmM/xHJ4F8PJ5R7UtaesvFZk6+LyUHX eJiQ== X-Gm-Message-State: AOUpUlHdkFQKVtsv1GnE5P89DlGPyypQmGxo3AKZQPgkWWY7ZQRzStFj NVfLnC3tTu7Xhq1/OCVtk/EmsxUXsac= X-Google-Smtp-Source: AAOMgpefsfi0Pqg+IPij1TvYSNisFdo8XFd2mxyS4Ty/j8ur9y8ayL6r0Ow6mCrySP1GXcSLR110pg== X-Received: by 2002:aca:5354:: with SMTP id h81-v6mr246002oib.299.1532377176082; Mon, 23 Jul 2018 13:19:36 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id o206-v6sm8218641oif.7.2018.07.23.13.19.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:19:35 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:16:41 -0500 Message-Id: <20180723201748.25573-33-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::244 Subject: [Qemu-devel] [PATCH 32/99] util: implement simple iova tree 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: qemu-stable@nongnu.org, Peter Xu , "Michael S . Tsirkin" Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Peter Xu Introduce a simplest iova tree implementation based on GTree. CC: QEMU Stable Signed-off-by: Peter Xu Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin (cherry picked from commit eecf5eedbdc0fc04f39abcf3afeedfbf21b25ca4) Signed-off-by: Michael Roth --- MAINTAINERS | 6 ++ include/qemu/iova-tree.h | 134 +++++++++++++++++++++++++++++++++++++++ util/Makefile.objs | 1 + util/iova-tree.c | 114 +++++++++++++++++++++++++++++++++ 4 files changed, 255 insertions(+) create mode 100644 include/qemu/iova-tree.h create mode 100644 util/iova-tree.c diff --git a/MAINTAINERS b/MAINTAINERS index 24b70169bc..ada7c33485 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1781,6 +1781,12 @@ F: include/sysemu/replay.h F: docs/replay.txt F: stubs/replay.c +IOVA Tree +M: Peter Xu +S: Maintained +F: include/qemu/iova-tree.h +F: util/iova-tree.c + Usermode Emulation ------------------ Overall diff --git a/include/qemu/iova-tree.h b/include/qemu/iova-tree.h new file mode 100644 index 0000000000..b061932097 --- /dev/null +++ b/include/qemu/iova-tree.h @@ -0,0 +1,134 @@ +/* + * An very simplified iova tree implementation based on GTree. + * + * Copyright 2018 Red Hat, Inc. + * + * Authors: + * Peter Xu + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + */ +#ifndef IOVA_TREE_H +#define IOVA_TREE_H + +/* + * Currently the iova tree will only allow to keep ranges + * information, and no extra user data is allowed for each element. A + * benefit is that we can merge adjacent ranges internally within the + * tree. It can save a lot of memory when the ranges are splitted but + * mostly continuous. + * + * Note that current implementation does not provide any thread + * protections. Callers of the iova tree should be responsible + * for the thread safety issue. + */ + +#include "qemu/osdep.h" +#include "exec/memory.h" +#include "exec/hwaddr.h" + +#define IOVA_OK (0) +#define IOVA_ERR_INVALID (-1) /* Invalid parameters */ +#define IOVA_ERR_OVERLAP (-2) /* IOVA range overlapped */ + +typedef struct IOVATree IOVATree; +typedef struct DMAMap { + hwaddr iova; + hwaddr translated_addr; + hwaddr size; /* Inclusive */ + IOMMUAccessFlags perm; +} QEMU_PACKED DMAMap; +typedef gboolean (*iova_tree_iterator)(DMAMap *map); + +/** + * iova_tree_new: + * + * Create a new iova tree. + * + * Returns: the tree pointer when succeeded, or NULL if error. + */ +IOVATree *iova_tree_new(void); + +/** + * iova_tree_insert: + * + * @tree: the iova tree to insert + * @map: the mapping to insert + * + * Insert an iova range to the tree. If there is overlapped + * ranges, IOVA_ERR_OVERLAP will be returned. + * + * Return: 0 if succeeded, or <0 if error. + */ +int iova_tree_insert(IOVATree *tree, DMAMap *map); + +/** + * iova_tree_remove: + * + * @tree: the iova tree to remove range from + * @map: the map range to remove + * + * Remove mappings from the tree that are covered by the map range + * provided. The range does not need to be exactly what has inserted, + * all the mappings that are included in the provided range will be + * removed from the tree. Here map->translated_addr is meaningless. + * + * Return: 0 if succeeded, or <0 if error. + */ +int iova_tree_remove(IOVATree *tree, DMAMap *map); + +/** + * iova_tree_find: + * + * @tree: the iova tree to search from + * @map: the mapping to search + * + * Search for a mapping in the iova tree that overlaps with the + * mapping range specified. Only the first found mapping will be + * returned. + * + * Return: DMAMap pointer if found, or NULL if not found. Note that + * the returned DMAMap pointer is maintained internally. User should + * only read the content but never modify or free the content. Also, + * user is responsible to make sure the pointer is valid (say, no + * concurrent deletion in progress). + */ +DMAMap *iova_tree_find(IOVATree *tree, DMAMap *map); + +/** + * iova_tree_find_address: + * + * @tree: the iova tree to search from + * @iova: the iova address to find + * + * Similar to iova_tree_find(), but it tries to find mapping with + * range iova=iova & size=0. + * + * Return: same as iova_tree_find(). + */ +DMAMap *iova_tree_find_address(IOVATree *tree, hwaddr iova); + +/** + * iova_tree_foreach: + * + * @tree: the iova tree to iterate on + * @iterator: the interator for the mappings, return true to stop + * + * Iterate over the iova tree. + * + * Return: 1 if found any overlap, 0 if not, <0 if error. + */ +void iova_tree_foreach(IOVATree *tree, iova_tree_iterator iterator); + +/** + * iova_tree_destroy: + * + * @tree: the iova tree to destroy + * + * Destroy an existing iova tree. + * + * Return: None. + */ +void iova_tree_destroy(IOVATree *tree); + +#endif diff --git a/util/Makefile.objs b/util/Makefile.objs index 728c3541db..e1c3fed4dc 100644 --- a/util/Makefile.objs +++ b/util/Makefile.objs @@ -47,4 +47,5 @@ util-obj-y += qht.o util-obj-y += range.o util-obj-y += stats64.o util-obj-y += systemd.o +util-obj-y += iova-tree.o util-obj-$(CONFIG_LINUX) += vfio-helpers.o diff --git a/util/iova-tree.c b/util/iova-tree.c new file mode 100644 index 0000000000..2d9cebfc89 --- /dev/null +++ b/util/iova-tree.c @@ -0,0 +1,114 @@ +/* + * IOVA tree implementation based on GTree. + * + * Copyright 2018 Red Hat, Inc. + * + * Authors: + * Peter Xu + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + */ + +#include +#include "qemu/iova-tree.h" + +struct IOVATree { + GTree *tree; +}; + +static int iova_tree_compare(gconstpointer a, gconstpointer b, gpointer data) +{ + const DMAMap *m1 = a, *m2 = b; + + if (m1->iova > m2->iova + m2->size) { + return 1; + } + + if (m1->iova + m1->size < m2->iova) { + return -1; + } + + /* Overlapped */ + return 0; +} + +IOVATree *iova_tree_new(void) +{ + IOVATree *iova_tree = g_new0(IOVATree, 1); + + /* We don't have values actually, no need to free */ + iova_tree->tree = g_tree_new_full(iova_tree_compare, NULL, g_free, NULL); + + return iova_tree; +} + +DMAMap *iova_tree_find(IOVATree *tree, DMAMap *map) +{ + return g_tree_lookup(tree->tree, map); +} + +DMAMap *iova_tree_find_address(IOVATree *tree, hwaddr iova) +{ + DMAMap map = { .iova = iova, .size = 0 }; + + return iova_tree_find(tree, &map); +} + +static inline void iova_tree_insert_internal(GTree *gtree, DMAMap *range) +{ + /* Key and value are sharing the same range data */ + g_tree_insert(gtree, range, range); +} + +int iova_tree_insert(IOVATree *tree, DMAMap *map) +{ + DMAMap *new; + + if (map->iova + map->size < map->iova || map->perm == IOMMU_NONE) { + return IOVA_ERR_INVALID; + } + + /* We don't allow to insert range that overlaps with existings */ + if (iova_tree_find(tree, map)) { + return IOVA_ERR_OVERLAP; + } + + new = g_new0(DMAMap, 1); + memcpy(new, map, sizeof(*new)); + iova_tree_insert_internal(tree->tree, new); + + return IOVA_OK; +} + +static gboolean iova_tree_traverse(gpointer key, gpointer value, + gpointer data) +{ + iova_tree_iterator iterator = data; + DMAMap *map = key; + + g_assert(key == value); + + return iterator(map); +} + +void iova_tree_foreach(IOVATree *tree, iova_tree_iterator iterator) +{ + g_tree_foreach(tree->tree, iova_tree_traverse, iterator); +} + +int iova_tree_remove(IOVATree *tree, DMAMap *map) +{ + DMAMap *overlap; + + while ((overlap = iova_tree_find(tree, map))) { + g_tree_remove(tree->tree, overlap); + } + + return IOVA_OK; +} + +void iova_tree_destroy(IOVATree *tree) +{ + g_tree_destroy(tree->tree); + g_free(tree); +} From patchwork Mon Jul 23 20:16:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948018 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="X0eRqO1p"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZD7701BSz9ryn for ; Tue, 24 Jul 2018 06:46:42 +1000 (AEST) Received: from localhost ([::1]:36496 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhj6-0000DN-Gc for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 16:46:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41368) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhJ0-0002Br-Kt for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhIx-0003eM-S1 for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:42 -0400 Received: from mail-oi0-x244.google.com ([2607:f8b0:4003:c06::244]:43140) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhIx-0003ds-K2; Mon, 23 Jul 2018 16:19:39 -0400 Received: by mail-oi0-x244.google.com with SMTP id b15-v6so3461425oib.10; Mon, 23 Jul 2018 13:19:39 -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=b0u/VIsBg0nxbmDRmGKlIJSuinw7IK7ykE7V/2hTJuk=; b=X0eRqO1pA1oIfsqyQdx628pQc2VuzEzFYauQ/xmHxf5tL089jVZ/tKcOFym/EZ1MF7 Gx4VpLS0itJ0fgOzHqt/+851GaocShjyD8PldbUkApqUrIek43bJw1c7o0hrZNYzJNd/ v1Zm0rhvT+/eke/lD1/Uy+9XHS+tvaSmOaKaJaV8Npm5Khvj+qqWV+CKq7Us33+leRjI dZGFOZ+83HwBonOhnMfkm/x4S0A/ES7FJm2NfmtWPACqtd1dZVnb8MO8C4OTqffS1Bcc MDMt51djPrlM8mKquLGsSbp3A4lJxiKrpxkwP/S/ML+Lynak7pX0Ulz4mK0tP3p7aItu PRhQ== 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=b0u/VIsBg0nxbmDRmGKlIJSuinw7IK7ykE7V/2hTJuk=; b=sR3063SqCUeGQgxcrGC3WuKl0Br/huwIoXlMD3TynvCqUP5JyOUF7WTI+v+dKhsdo3 Gt5pBysaea3l0lZya6iZFnREUJZRIdYKjvPHYS6niF6R1M+AhKkYVNdDPbeDCAV0GVAU 34lR4HrhtH/WmpwoGkcaLi1H5M+VNNbsmiL1LZIYI2q+9nTRnWKsQdTdz2X+jhDMUjgQ Libse9Xmm5Pib3a7GBe90vJvy+PiNQmqemPz55SsmWC5BTQ8lRp/Ho33HU07Q4MJEW4f EoUpCMfMYFB626XfzcbWaWejCGjFf+vojYZk3PY3x11Dbq3j4Iw2cKyoN1Hh0GhAtUXJ Xbog== X-Gm-Message-State: AOUpUlGYkfwgG5B0LByYNjlD6FNFryfWpuw18IUJprNx3vlzUjNqesSn vdgARIpnZcxSoraRVG+tfuD44zOrO5U= X-Google-Smtp-Source: AAOMgpe7kEBXHryhY8ajRdwb0zIb27weSRsTZMTU/VcFF8/NagkWZ5pKGQormQa7rjt9Rx6Z2S728A== X-Received: by 2002:aca:ce0f:: with SMTP id e15-v6mr308800oig.13.1532377178331; Mon, 23 Jul 2018 13:19:38 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id r81-v6sm14551350oih.28.2018.07.23.13.19.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:19:37 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:16:42 -0500 Message-Id: <20180723201748.25573-34-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::244 Subject: [Qemu-devel] [PATCH 33/99] intel-iommu: rework the page walk logic 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: qemu-stable@nongnu.org, Peter Xu , "Michael S . Tsirkin" Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Peter Xu This patch fixes a potential small window that the DMA page table might be incomplete or invalid when the guest sends domain/context invalidations to a device. This can cause random DMA errors for assigned devices. This is a major change to the VT-d shadow page walking logic. It includes but is not limited to: - For each VTDAddressSpace, now we maintain what IOVA ranges we have mapped and what we have not. With that information, now we only send MAP or UNMAP when necessary. Say, we don't send MAP notifies if we know we have already mapped the range, meanwhile we don't send UNMAP notifies if we know we never mapped the range at all. - Introduce vtd_sync_shadow_page_table[_range] APIs so that we can call in any places to resync the shadow page table for a device. - When we receive domain/context invalidation, we should not really run the replay logic, instead we use the new sync shadow page table API to resync the whole shadow page table without unmapping the whole region. After this change, we'll only do the page walk once for each domain invalidations (before this, it can be multiple, depending on number of notifiers per address space). While at it, the page walking logic is also refactored to be simpler. CC: QEMU Stable Reported-by: Jintack Lim Tested-by: Jintack Lim Signed-off-by: Peter Xu Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin (cherry picked from commit 63b88968f139b6a77f2f81e6f1eedf70c0170a85) Signed-off-by: Michael Roth --- hw/i386/intel_iommu.c | 213 +++++++++++++++++++++++++--------- hw/i386/trace-events | 3 +- include/hw/i386/intel_iommu.h | 2 + 3 files changed, 159 insertions(+), 59 deletions(-) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 61bb3d31e7..b5a09b7908 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -769,10 +769,77 @@ typedef struct { static int vtd_page_walk_one(IOMMUTLBEntry *entry, vtd_page_walk_info *info) { + VTDAddressSpace *as = info->as; vtd_page_walk_hook hook_fn = info->hook_fn; void *private = info->private; + DMAMap target = { + .iova = entry->iova, + .size = entry->addr_mask, + .translated_addr = entry->translated_addr, + .perm = entry->perm, + }; + DMAMap *mapped = iova_tree_find(as->iova_tree, &target); + + if (entry->perm == IOMMU_NONE && !info->notify_unmap) { + trace_vtd_page_walk_one_skip_unmap(entry->iova, entry->addr_mask); + return 0; + } assert(hook_fn); + + /* Update local IOVA mapped ranges */ + if (entry->perm) { + if (mapped) { + /* If it's exactly the same translation, skip */ + if (!memcmp(mapped, &target, sizeof(target))) { + trace_vtd_page_walk_one_skip_map(entry->iova, entry->addr_mask, + entry->translated_addr); + return 0; + } else { + /* + * Translation changed. Normally this should not + * happen, but it can happen when with buggy guest + * OSes. Note that there will be a small window that + * we don't have map at all. But that's the best + * effort we can do. The ideal way to emulate this is + * atomically modify the PTE to follow what has + * changed, but we can't. One example is that vfio + * driver only has VFIO_IOMMU_[UN]MAP_DMA but no + * interface to modify a mapping (meanwhile it seems + * meaningless to even provide one). Anyway, let's + * mark this as a TODO in case one day we'll have + * a better solution. + */ + IOMMUAccessFlags cache_perm = entry->perm; + int ret; + + /* Emulate an UNMAP */ + entry->perm = IOMMU_NONE; + trace_vtd_page_walk_one(info->domain_id, + entry->iova, + entry->translated_addr, + entry->addr_mask, + entry->perm); + ret = hook_fn(entry, private); + if (ret) { + return ret; + } + /* Drop any existing mapping */ + iova_tree_remove(as->iova_tree, &target); + /* Recover the correct permission */ + entry->perm = cache_perm; + } + } + iova_tree_insert(as->iova_tree, &target); + } else { + if (!mapped) { + /* Skip since we didn't map this range at all */ + trace_vtd_page_walk_one_skip_unmap(entry->iova, entry->addr_mask); + return 0; + } + iova_tree_remove(as->iova_tree, &target); + } + trace_vtd_page_walk_one(info->domain_id, entry->iova, entry->translated_addr, entry->addr_mask, entry->perm); @@ -834,45 +901,34 @@ static int vtd_page_walk_level(dma_addr_t addr, uint64_t start, */ entry_valid = read_cur | write_cur; - entry.target_as = &address_space_memory; - entry.iova = iova & subpage_mask; - entry.perm = IOMMU_ACCESS_FLAG(read_cur, write_cur); - entry.addr_mask = ~subpage_mask; - - if (vtd_is_last_slpte(slpte, level)) { - /* NOTE: this is only meaningful if entry_valid == true */ - entry.translated_addr = vtd_get_slpte_addr(slpte, info->aw); - if (!entry_valid && !info->notify_unmap) { - trace_vtd_page_walk_skip_perm(iova, iova_next); - goto next; - } - ret = vtd_page_walk_one(&entry, info); - if (ret < 0) { - return ret; - } - } else { - if (!entry_valid) { - if (info->notify_unmap) { - /* - * The whole entry is invalid; unmap it all. - * Translated address is meaningless, zero it. - */ - entry.translated_addr = 0x0; - ret = vtd_page_walk_one(&entry, info); - if (ret < 0) { - return ret; - } - } else { - trace_vtd_page_walk_skip_perm(iova, iova_next); - } - goto next; - } + if (!vtd_is_last_slpte(slpte, level) && entry_valid) { + /* + * This is a valid PDE (or even bigger than PDE). We need + * to walk one further level. + */ ret = vtd_page_walk_level(vtd_get_slpte_addr(slpte, info->aw), iova, MIN(iova_next, end), level - 1, read_cur, write_cur, info); - if (ret < 0) { - return ret; - } + } else { + /* + * This means we are either: + * + * (1) the real page entry (either 4K page, or huge page) + * (2) the whole range is invalid + * + * In either case, we send an IOTLB notification down. + */ + entry.target_as = &address_space_memory; + entry.iova = iova & subpage_mask; + entry.perm = IOMMU_ACCESS_FLAG(read_cur, write_cur); + entry.addr_mask = ~subpage_mask; + /* NOTE: this is only meaningful if entry_valid == true */ + entry.translated_addr = vtd_get_slpte_addr(slpte, info->aw); + ret = vtd_page_walk_one(&entry, info); + } + + if (ret < 0) { + return ret; } next: @@ -964,6 +1020,58 @@ static int vtd_dev_to_context_entry(IntelIOMMUState *s, uint8_t bus_num, return 0; } +static int vtd_sync_shadow_page_hook(IOMMUTLBEntry *entry, + void *private) +{ + memory_region_notify_iommu((IOMMUMemoryRegion *)private, *entry); + return 0; +} + +/* If context entry is NULL, we'll try to fetch it on our own. */ +static int vtd_sync_shadow_page_table_range(VTDAddressSpace *vtd_as, + VTDContextEntry *ce, + hwaddr addr, hwaddr size) +{ + IntelIOMMUState *s = vtd_as->iommu_state; + vtd_page_walk_info info = { + .hook_fn = vtd_sync_shadow_page_hook, + .private = (void *)&vtd_as->iommu, + .notify_unmap = true, + .aw = s->aw_bits, + .as = vtd_as, + }; + VTDContextEntry ce_cache; + int ret; + + if (ce) { + /* If the caller provided context entry, use it */ + ce_cache = *ce; + } else { + /* If the caller didn't provide ce, try to fetch */ + ret = vtd_dev_to_context_entry(s, pci_bus_num(vtd_as->bus), + vtd_as->devfn, &ce_cache); + if (ret) { + /* + * This should not really happen, but in case it happens, + * we just skip the sync for this time. After all we even + * don't have the root table pointer! + */ + trace_vtd_err("Detected invalid context entry when " + "trying to sync shadow page table"); + return 0; + } + } + + info.domain_id = VTD_CONTEXT_ENTRY_DID(ce_cache.hi); + + return vtd_page_walk(&ce_cache, addr, addr + size, &info); +} + +static int vtd_sync_shadow_page_table(VTDAddressSpace *vtd_as) +{ + return vtd_sync_shadow_page_table_range(vtd_as, NULL, 0, UINT64_MAX); +} + /* * Fetch translation type for specific device. Returns <0 if error * happens, otherwise return the shifted type to check against @@ -1296,7 +1404,7 @@ static void vtd_iommu_replay_all(IntelIOMMUState *s) VTDAddressSpace *vtd_as; QLIST_FOREACH(vtd_as, &s->vtd_as_with_notifiers, next) { - memory_region_iommu_replay_all(&vtd_as->iommu); + vtd_sync_shadow_page_table(vtd_as); } } @@ -1371,14 +1479,13 @@ static void vtd_context_device_invalidate(IntelIOMMUState *s, vtd_switch_address_space(vtd_as); /* * So a device is moving out of (or moving into) a - * domain, a replay() suites here to notify all the - * IOMMU_NOTIFIER_MAP registers about this change. + * domain, resync the shadow page table. * This won't bring bad even if we have no such * notifier registered - the IOMMU notification * framework will skip MAP notifications if that * happened. */ - memory_region_iommu_replay_all(&vtd_as->iommu); + vtd_sync_shadow_page_table(vtd_as); } } } @@ -1436,18 +1543,11 @@ static void vtd_iotlb_domain_invalidate(IntelIOMMUState *s, uint16_t domain_id) if (!vtd_dev_to_context_entry(s, pci_bus_num(vtd_as->bus), vtd_as->devfn, &ce) && domain_id == VTD_CONTEXT_ENTRY_DID(ce.hi)) { - memory_region_iommu_replay_all(&vtd_as->iommu); + vtd_sync_shadow_page_table(vtd_as); } } } -static int vtd_page_invalidate_notify_hook(IOMMUTLBEntry *entry, - void *private) -{ - memory_region_notify_iommu((IOMMUMemoryRegion *)private, *entry); - return 0; -} - static void vtd_iotlb_page_invalidate_notify(IntelIOMMUState *s, uint16_t domain_id, hwaddr addr, uint8_t am) @@ -1462,21 +1562,12 @@ static void vtd_iotlb_page_invalidate_notify(IntelIOMMUState *s, vtd_as->devfn, &ce); if (!ret && domain_id == VTD_CONTEXT_ENTRY_DID(ce.hi)) { if (vtd_as_has_map_notifier(vtd_as)) { - vtd_page_walk_info info = { - .hook_fn = vtd_page_invalidate_notify_hook, - .private = (void *)&vtd_as->iommu, - .notify_unmap = true, - .aw = s->aw_bits, - .as = vtd_as, - .domain_id = domain_id, - }; - /* * As long as we have MAP notifications registered in * any of our IOMMU notifiers, we need to sync the * shadow page table. */ - vtd_page_walk(&ce, addr, addr + size, &info); + vtd_sync_shadow_page_table_range(vtd_as, &ce, addr, size); } else { /* * For UNMAP-only notifiers, we don't need to walk the @@ -2806,6 +2897,7 @@ VTDAddressSpace *vtd_find_add_as(IntelIOMMUState *s, PCIBus *bus, int devfn) vtd_dev_as->devfn = (uint8_t)devfn; vtd_dev_as->iommu_state = s; vtd_dev_as->context_cache_entry.context_cache_gen = 0; + vtd_dev_as->iova_tree = iova_tree_new(); /* * Memory region relationships looks like (Address range shows @@ -2858,6 +2950,7 @@ static void vtd_address_space_unmap(VTDAddressSpace *as, IOMMUNotifier *n) hwaddr start = n->start; hwaddr end = n->end; IntelIOMMUState *s = as->iommu_state; + DMAMap map; /* * Note: all the codes in this function has a assumption that IOVA @@ -2902,6 +2995,10 @@ static void vtd_address_space_unmap(VTDAddressSpace *as, IOMMUNotifier *n) VTD_PCI_FUNC(as->devfn), entry.iova, size); + map.iova = entry.iova; + map.size = entry.addr_mask; + iova_tree_remove(as->iova_tree, &map); + memory_region_notify_one(n, &entry); } diff --git a/hw/i386/trace-events b/hw/i386/trace-events index ca23ba9fad..e14d06ec83 100644 --- a/hw/i386/trace-events +++ b/hw/i386/trace-events @@ -40,8 +40,9 @@ vtd_replay_ce_valid(uint8_t bus, uint8_t dev, uint8_t fn, uint16_t domain, uint6 vtd_replay_ce_invalid(uint8_t bus, uint8_t dev, uint8_t fn) "replay invalid context device %02"PRIx8":%02"PRIx8".%02"PRIx8 vtd_page_walk_level(uint64_t addr, uint32_t level, uint64_t start, uint64_t end) "walk (base=0x%"PRIx64", level=%"PRIu32") iova range 0x%"PRIx64" - 0x%"PRIx64 vtd_page_walk_one(uint16_t domain, uint64_t iova, uint64_t gpa, uint64_t mask, int perm) "domain 0x%"PRIu16" iova 0x%"PRIx64" -> gpa 0x%"PRIx64" mask 0x%"PRIx64" perm %d" +vtd_page_walk_one_skip_map(uint64_t iova, uint64_t mask, uint64_t translated) "iova 0x%"PRIx64" mask 0x%"PRIx64" translated 0x%"PRIx64 +vtd_page_walk_one_skip_unmap(uint64_t iova, uint64_t mask) "iova 0x%"PRIx64" mask 0x%"PRIx64 vtd_page_walk_skip_read(uint64_t iova, uint64_t next) "Page walk skip iova 0x%"PRIx64" - 0x%"PRIx64" due to unable to read" -vtd_page_walk_skip_perm(uint64_t iova, uint64_t next) "Page walk skip iova 0x%"PRIx64" - 0x%"PRIx64" due to perm empty" vtd_page_walk_skip_reserve(uint64_t iova, uint64_t next) "Page walk skip iova 0x%"PRIx64" - 0x%"PRIx64" due to rsrv set" vtd_switch_address_space(uint8_t bus, uint8_t slot, uint8_t fn, bool on) "Device %02x:%02x.%x switching address space (iommu enabled=%d)" vtd_as_unmap_whole(uint8_t bus, uint8_t slot, uint8_t fn, uint64_t iova, uint64_t size) "Device %02x:%02x.%x start 0x%"PRIx64" size 0x%"PRIx64 diff --git a/include/hw/i386/intel_iommu.h b/include/hw/i386/intel_iommu.h index 156f35e919..fbfedcb1c0 100644 --- a/include/hw/i386/intel_iommu.h +++ b/include/hw/i386/intel_iommu.h @@ -27,6 +27,7 @@ #include "hw/i386/ioapic.h" #include "hw/pci/msi.h" #include "hw/sysbus.h" +#include "qemu/iova-tree.h" #define TYPE_INTEL_IOMMU_DEVICE "intel-iommu" #define INTEL_IOMMU_DEVICE(obj) \ @@ -95,6 +96,7 @@ struct VTDAddressSpace { QLIST_ENTRY(VTDAddressSpace) next; /* Superset of notifier flags that this address space has */ IOMMUNotifierFlag notifier_flags; + IOVATree *iova_tree; /* Traces mapped IOVA ranges */ }; struct VTDBus { From patchwork Mon Jul 23 20:16:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948007 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ZH0xF7qi"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZCyG3x2nz9s1x for ; Tue, 24 Jul 2018 06:39:02 +1000 (AEST) Received: from localhost ([::1]:36440 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhbg-000259-4V for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 16:39:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41369) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhJ0-0002Bu-LB for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhIz-0003g8-NW for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:42 -0400 Received: from mail-oi0-x242.google.com ([2607:f8b0:4003:c06::242]:33582) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhIz-0003fo-GY; Mon, 23 Jul 2018 16:19:41 -0400 Received: by mail-oi0-x242.google.com with SMTP id l10-v6so3497781oii.0; Mon, 23 Jul 2018 13:19:41 -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=Huix2ZTfl5FfJbBo26orePVC5DcJmD3GGESAL3i3MJE=; b=ZH0xF7qihv4ZkSpgnn/Qe449CqLbsc6ZPRl+1JNGjhfACO3FQKHX1yZX/HV1UJAZv1 9UaE2QD0gy/mz8p4CG+0zfqp59qcpIj8xhUP+5b9YVYnKL+xRbj9fGiPfUp+nm0HyI1R N5bSfXQQ+/tku22GnxGZUv0nazqFjVZdYLdANfIvuklPqL2+IJgD4Y50gKhZNDbhOafH TkCTAjDm818yfYo68tNVY+V2p9JiorExHBRCGiheziD7utD9QU9SQCuz37KjriBCQojr J5H92W9rl4oywcNXXGFW6dE57wbGfNb+WLXO0C/wCyJOYkP744uBcHLd6O8AkgmoIyC6 nzoA== 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=Huix2ZTfl5FfJbBo26orePVC5DcJmD3GGESAL3i3MJE=; b=fwgkjKuTn795jRjmb0Sifhr6JLM30bP5rdFBtKBWMldZfCuFn1Y0gdfasNJYzXohet KUKQMmPpRUHyrYAJal1FrX1UQCS2KJ+j9sD4enh9h+gkkzrl3l2CmZcjP+obxFDs2ghs HsOb+ZGTkyvdXcScIeNZL54tZpiQBGzuABIYqf6IQdHx5Ubv+8Xbx9HLTK0JTmZpthoB XikghPTw1K0Q/UkHyennECvXLbvA/6/XHcXUzfFwtoQqnNrMofyjqRaBcMZ8Tr+IDZB5 BicNqUNBN6bwLV9YXbJTvr5k4bz5fKDhOiibucgXnj4LDd/DeMIl+RYGR6lIOAP2o9lq GSRg== X-Gm-Message-State: AOUpUlEs328C4tKBg3zPm5m4W01xsSYxrCUEApLR46euPeYdaH4xrqp3 w7WDz1Q6MwASfKLmdtus0Wq4DmVf5kI= X-Google-Smtp-Source: AAOMgpe0M6uGgmEEdnR73LYdDFEUFzh2CeN47Prf0tgom6cF83aMzLzyzhi7830/uz+v/Vqmeil/7Q== X-Received: by 2002:aca:ebd8:: with SMTP id j207-v6mr321730oih.206.1532377180440; Mon, 23 Jul 2018 13:19:40 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id c9-v6sm7626481oia.1.2018.07.23.13.19.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:19:39 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:16:43 -0500 Message-Id: <20180723201748.25573-35-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::242 Subject: [Qemu-devel] [PATCH 34/99] arm_gicv3_kvm: increase clroffset accordingly 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: Peter Maydell , qemu-stable@nongnu.org, Shannon Zhao Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Shannon Zhao It forgot to increase clroffset during the loop. So it only clear the first 4 bytes. Fixes: 367b9f527becdd20ddf116e17a3c0c2bbc486920 Cc: qemu-stable@nongnu.org Signed-off-by: Shannon Zhao Reviewed-by: Eric Auger Message-id: 1527047633-12368-1-git-send-email-zhaoshenglong@huawei.com Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell (cherry picked from commit 34ffacae085914fce54590ea84bae9c6ad95e2a4) Signed-off-by: Michael Roth --- hw/intc/arm_gicv3_kvm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c index ec371772b3..3536795501 100644 --- a/hw/intc/arm_gicv3_kvm.c +++ b/hw/intc/arm_gicv3_kvm.c @@ -243,6 +243,7 @@ static void kvm_dist_putbmp(GICv3State *s, uint32_t offset, if (clroffset != 0) { reg = 0; kvm_gicd_access(s, clroffset, ®, true); + clroffset += 4; } reg = *gic_bmp_ptr32(bmp, irq); kvm_gicd_access(s, offset, ®, true); From patchwork Mon Jul 23 20:16:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948015 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="KFgDTlG1"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZD4N5dCrz9s4V for ; Tue, 24 Jul 2018 06:44:20 +1000 (AEST) Received: from localhost ([::1]:36476 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhgo-0006lF-4J for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 16:44:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41438) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhJ3-0002En-Bi for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhJ2-0003j8-2T for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:45 -0400 Received: from mail-oi0-x22c.google.com ([2607:f8b0:4003:c06::22c]:39343) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhJ1-0003ie-St; Mon, 23 Jul 2018 16:19:43 -0400 Received: by mail-oi0-x22c.google.com with SMTP id d189-v6so3478804oib.6; Mon, 23 Jul 2018 13:19:43 -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=XCCrlfTWNTuOZ25P6NOioPcefqwH8d/8KKuPNtmSMek=; b=KFgDTlG1SS4lMeMUr6tqAwEGwdAUpw1WLoTlvgU04QBXDgJfOxpULCMw4mIooEZYDf PNWoJO8E96j+4lHM8XqM2ZkeX/KxGjNtY0O9SvM6Rq/mQBUjYa6tvL2DLYl4taai5gz2 IuQAeqobOxVXwTvSsd23SQh4hw8df8lDbPmG4TvunwZeERGjlAHTxfZimqx/HiCuV2KZ EtkSE0JTSswCccKW0LUS5vTk9GdVNtX3Os0jROybpKgFOvXBptcMrdn+7sF4tg3DGNAQ WNrI03qZVx15R3nKxUZ3aQOlXncKbUqXLYjBYxITNXhV+6B435dQjD3sFtUFiMhORkHr BsRw== 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=XCCrlfTWNTuOZ25P6NOioPcefqwH8d/8KKuPNtmSMek=; b=PTHakTdKDt30YmU8uNzFmYyOmDKLW4D0QBO0+OvB45G4rFN71bB/T6+lL+wA6NZqoY S2to0AaC2yGegngvdZ9IBsL3qinFuTMc70TjgbTHi+WL36BQ7SnYOF+tPMrWzdla1Sn2 WoetSpgD5i/3tHA6BYLo/JUWqYYXcfgfXlQinYwziemZBfPrJnEVCFdwnY83f19zy/xi yuu367dZRb3J+Ck1XcxwfDZjF9Mhp9eA8QHblHMFptdWeDod3BJU5wddLMRkwQrDiAFi jPwBFB/TQfRUwugNPUhcilCz8qlhB6ZvxL4A8e+0TxpkDXpVHNF0/9vA0PqDdREWyhnk YPzg== X-Gm-Message-State: AOUpUlG1kPWHqMdcA46zLYZi5RL84E4Hch+IReazExLHoHbf0lrwU/zO HF2rKzp/CCRoRB3B/qXhuP6cqnqoWr8= X-Google-Smtp-Source: AAOMgpee9RyDPrV+rwK+FWX/C+jIZTIB/y7j5n56Y1pylYSKA24zX5sdKVOzUJoXUnP2ACSn0JK+UQ== X-Received: by 2002:aca:5bd5:: with SMTP id p204-v6mr299775oib.91.1532377182665; Mon, 23 Jul 2018 13:19:42 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id q63-v6sm1771426oia.54.2018.07.23.13.19.41 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:19:41 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:16:44 -0500 Message-Id: <20180723201748.25573-36-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::22c Subject: [Qemu-devel] [PATCH 35/99] Fix libusb-1.0.22 deprecated libusb_set_debug with libusb_set_option 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: qemu-stable@nongnu.org, John Thomson , Gerd Hoffmann Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: John Thomson libusb-1.0.22 marked libusb_set_debug deprecated it is replaced with libusb_set_option(libusb_context, LIBUSB_OPTION_LOG_LEVEL, libusb_log_level); details here: https://github.com/libusb/libusb/commit/539f22e2fd916558d11ab9a66f10f461c5593168 Warning here: CC hw/usb/host-libusb.o /builds/xen/src/qemu-xen/hw/usb/host-libusb.c: In function 'usb_host_init': /builds/xen/src/qemu-xen/hw/usb/host-libusb.c:250:5: error: 'libusb_set_debug' is deprecated: Use libusb_set_option instead [-Werror=deprecated-declarations] libusb_set_debug(ctx, loglevel); ^~~~~~~~~~~~~~~~ In file included from /builds/xen/src/qemu-xen/hw/usb/host-libusb.c:40:0: /usr/include/libusb-1.0/libusb.h:1300:18: note: declared here void LIBUSB_CALL libusb_set_debug(libusb_context *ctx, int level); ^~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors make: *** [/builds/xen/src/qemu-xen/rules.mak:66: hw/usb/host-libusb.o] Error 1 make: Leaving directory '/builds/xen/src/xen/tools/qemu-xen-build' Signed-off-by: John Thomson Message-id: 20180405132046.4968-1-git@johnthomson.fastmail.com.au Signed-off-by: Gerd Hoffmann (cherry picked from commit 9d8fa0df49af16a208fa961c2968fba4daffcc07) Signed-off-by: Michael Roth --- hw/usb/host-libusb.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c index 1b0be071cc..dc0a8fe295 100644 --- a/hw/usb/host-libusb.c +++ b/hw/usb/host-libusb.c @@ -247,7 +247,11 @@ static int usb_host_init(void) if (rc != 0) { return -1; } +#if LIBUSB_API_VERSION >= 0x01000106 + libusb_set_option(ctx, LIBUSB_OPTION_LOG_LEVEL, loglevel); +#else libusb_set_debug(ctx, loglevel); +#endif #ifdef CONFIG_WIN32 /* FIXME: add support for Windows. */ #else From patchwork Mon Jul 23 20:16:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948022 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="R/QvGOVq"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZDCY1rxzz9ryn for ; Tue, 24 Jul 2018 06:50:33 +1000 (AEST) Received: from localhost ([::1]:36519 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhmo-0002wK-Na for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 16:50:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41462) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhJ5-0002FR-Bp for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhJ4-0003m9-Bc for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:47 -0400 Received: from mail-oi0-x22f.google.com ([2607:f8b0:4003:c06::22f]:39346) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhJ4-0003l5-4s; Mon, 23 Jul 2018 16:19:46 -0400 Received: by mail-oi0-x22f.google.com with SMTP id d189-v6so3478995oib.6; Mon, 23 Jul 2018 13:19:46 -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=77/Mr19kR4KMcOef0GYjYQNyN9hp5TSPMcEQAMoXKjo=; b=R/QvGOVqA5ipCUYXxbNbr9QZOhvBr59f539iIy/KQ0MPQwsY+bXi3r1fPfgptIXV0w yF+huWivmldsAB7CY39V7+K/o7Hg4U7a7NUoVUz3jUvIW/jyTUz6atvI01syC7SIFsvU ReM0W2IJJT68aHA27/UyMtumbeCgg0GIJHuC0Y7hoderkZl+Fd8OJjxmUREwl+9pgzwl QzBHKW6+i1BgbM2GNmQZv9zualWINAtaiEbDAakqRuV3DMZGpML+0Tiv2nCX+YVvmcd6 rMpokkSmhqsF70srAvJP8ev7ZjhNt5+V0WR9wbuB80lnPAVlzZbmSX3pb/RTKdFUdeq+ 8V3Q== 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=77/Mr19kR4KMcOef0GYjYQNyN9hp5TSPMcEQAMoXKjo=; b=WGme6ZPrNv0mrxv+udANvjKQcQiRiccGrAoxqrFk/2lHrC+8osi6FdpbNsH9b8Qmz3 VCNgKB+T8n4u227jIb1H9Ziif9s/RRIz7GAaZ9K8WjOo2TSAkn7LAAcBitjA6zFRxqp3 M6EbLkP/saN3F8yqjt/MiRd9iM4D1BvMDxDL1dKpvsmBkeo7ktCbemTD0/LcjyqMFoZG R/2YzA3Qwjs4rHxn4pXCxWVKKMNUQhvOlguENjKOBIpCOB9+K+Ul5W2trApFoSgZ0nm4 2n2mGcnQWX2PdNF+2DuGKPQTYC63p3RtvJXG6rD7bfB8yuHXHp39wSPo9YsuX6sgayIP HRcg== X-Gm-Message-State: AOUpUlFQoJ132KPcQUolZVBmn9RGqzyqQ/9jn/hLbJqgMLp2J1/j7kEw YzZqrSeaU5EVBqNmIcDVpamjwpbXTTI= X-Google-Smtp-Source: AAOMgpdwmPw2fl6hj+qOTcH4OqoatrGUc2uSH9Jvn4BQCnhZGIKGlemgUys12RN0+S2tL2i53KWtZw== X-Received: by 2002:aca:66a5:: with SMTP id m37-v6mr294634oik.139.1532377184931; Mon, 23 Jul 2018 13:19:44 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id m7-v6sm7925228oia.32.2018.07.23.13.19.43 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:19:43 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:16:45 -0500 Message-Id: <20180723201748.25573-37-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::22f Subject: [Qemu-devel] [PATCH 36/99] ahci: fix PxCI register race 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: John Snow , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: John Snow Fixes: https://bugs.launchpad.net/qemu/+bug/1769189 AHCI presently signals completion prior to the PxCI register being cleared to indicate completion. If a guest driver attempts to issue a new command in its IRQ handler, it might be surprised to learn there is still a command pending. In the case of Windows 10's boot driver, it will actually poll the IRQ register hoping to find out when the command is done running -- which will never happen, as there isn't a command running. Fix this: clear PxCI in ahci_cmd_done and not in the asynchronous BH. Because it now runs synchronously, we don't need to check if the command is actually done by spying on the ATA registers. We know it's done. CC: qemu-stable Reported-by: François Guerraz Tested-by: Bruce Rogers Signed-off-by: John Snow Reviewed-by: Stefan Hajnoczi Reviewed-by: Jeff Cody Message-id: 20180531004323.4611-3-jsnow@redhat.com Signed-off-by: John Snow (cherry picked from commit 5694c7eacce6b263ad7497cc1bb76aad746cfd4e) Signed-off-by: Michael Roth --- hw/ide/ahci.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index e22d7be05f..18b9a9c18b 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -532,13 +532,6 @@ static void ahci_check_cmd_bh(void *opaque) qemu_bh_delete(ad->check_bh); ad->check_bh = NULL; - if ((ad->busy_slot != -1) && - !(ad->port.ifs[0].status & (BUSY_STAT|DRQ_STAT))) { - /* no longer busy */ - ad->port_regs.cmd_issue &= ~(1 << ad->busy_slot); - ad->busy_slot = -1; - } - check_cmd(ad->hba, ad->port_no); } @@ -1425,6 +1418,12 @@ static void ahci_cmd_done(IDEDMA *dma) trace_ahci_cmd_done(ad->hba, ad->port_no); + /* no longer busy */ + if (ad->busy_slot != -1) { + ad->port_regs.cmd_issue &= ~(1 << ad->busy_slot); + ad->busy_slot = -1; + } + /* update d2h status */ ahci_write_fis_d2h(ad); From patchwork Mon Jul 23 20:16:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948027 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="gcAMrkwq"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZDJ302Dpz9ryn for ; Tue, 24 Jul 2018 06:54:27 +1000 (AEST) Received: from localhost ([::1]:36544 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhqa-0006NG-JV for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 16:54:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41519) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhJ9-0002J7-K4 for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhJ6-0003pN-9M for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:51 -0400 Received: from mail-oi0-x242.google.com ([2607:f8b0:4003:c06::242]:38981) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhJ6-0003oN-1I; Mon, 23 Jul 2018 16:19:48 -0400 Received: by mail-oi0-x242.google.com with SMTP id d189-v6so3479143oib.6; Mon, 23 Jul 2018 13:19:47 -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=cbZSqxll6sILlfbTMUK4hT7XybHqrRpj11iWLCkq8MI=; b=gcAMrkwqaccdOUx8LlP3N1/CgC9r9doGG0MugCnHIZmOmykxySmBIEHe5SM7/nNS3w thdXe+l5h0PeM3n0gI2ErB2Z4EG619KkJ3xYi9ok/FdcYu8PoPbPqRalWJzB73WOYtk0 NeqnGrcvbOqHOxdsMK1qe34/VgstX5B1IpYh2QJZZlOypt68zYOz8x+Q5Bwu6SKCMdHN 3SyCTsYxcgWja1HhFI/Lb3SM3/jpHEvQwYQvjW9whh4moYA7u76FzLKVkJlLwKpuoSdo yjZKFoLk8WkX6V2td9oTNzcwrAzQvBYDqf0PhmYqMZGMzQjkYpAuoZCTS4ZhkG9mQoHN LaAg== 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=cbZSqxll6sILlfbTMUK4hT7XybHqrRpj11iWLCkq8MI=; b=fADbk1EuTIFYahsjMxt0YgsrdeOsjaVWyGMFOfORxrXl2PVVf/r/4inb9f2w5mcnvz W1ZLvCOEvXd0gyKX57SfV4KPptFTPhYQsuSOOghU/jY0gXgDR2143yGCX9IkKkCPQ7Ht rk1Ld/tO7SWvVNI8AgvcgqnCTIyczbnz3uAqhTLATBBh4VmH1kwIQ/c+rbZ1ePitvdGA k+4E4BJDTyXCazXXtodkfVnJ7PK/YKj5wVxzoJDJjVd/P5C7779XWBvQlT84Rsz3E066 87Esed0ohy0+RBnQRzp2R4bn4FjAYP8GSpl2SYJLeYK4pvw80Lj/SaIWfDnV+HRjPX5g qu6Q== X-Gm-Message-State: AOUpUlEYnJriZD8qhVR6y93zdAQGnBC+68iqSOQ95H1XdXFYFRMCbivL 9Jv6UYHAjrQi2xHHG01CayEy5V8SWfc= X-Google-Smtp-Source: AAOMgpfAu9il7yPUZdWVSaEYv3FY14pBquR4FTQ5EsTfw9hWfh/HCqodWYMyXXBj02dkdnGOA8d/RA== X-Received: by 2002:aca:e2c7:: with SMTP id z190-v6mr330749oig.262.1532377186821; Mon, 23 Jul 2018 13:19:46 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id b3-v6sm6695291oiy.11.2018.07.23.13.19.45 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:19:45 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:16:46 -0500 Message-Id: <20180723201748.25573-38-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::242 Subject: [Qemu-devel] [PATCH 37/99] arm_gicv3_kvm: kvm_dist_get/put: skip the registers banked by GICR 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: Peter Maydell , qemu-stable@nongnu.org, Shannon Zhao Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Shannon Zhao While we skip the GIC_INTERNAL irqs, we don't change the register offset accordingly. This will overlap the GICR registers value and leave the last GIC_INTERNAL irq's registers out of update. Fix this by skipping the registers banked by GICR. Also for migration compatibility if the migration source (old version qemu) doesn't send gicd_no_migration_shift_bug = 1 to destination, then we shift the data of PPI to get the right data for SPI. Fixes: 367b9f527becdd20ddf116e17a3c0c2bbc486920 Cc: qemu-stable@nongnu.org Reviewed-by: Eric Auger Reviewed-by: Peter Maydell Signed-off-by: Shannon Zhao Message-id: 1527816987-16108-1-git-send-email-zhaoshenglong@huawei.com Signed-off-by: Peter Maydell (cherry picked from commit 910e204841954b95c051b2ee49ab0f5c735ff93c) Signed-off-by: Michael Roth --- hw/intc/arm_gicv3_common.c | 79 ++++++++++++++++++++++++++++++ hw/intc/arm_gicv3_kvm.c | 38 ++++++++++++++ include/hw/intc/arm_gicv3_common.h | 1 + 3 files changed, 118 insertions(+) diff --git a/hw/intc/arm_gicv3_common.c b/hw/intc/arm_gicv3_common.c index 7b54d52376..864b7c6515 100644 --- a/hw/intc/arm_gicv3_common.c +++ b/hw/intc/arm_gicv3_common.c @@ -27,6 +27,7 @@ #include "hw/intc/arm_gicv3_common.h" #include "gicv3_internal.h" #include "hw/arm/linux-boot-if.h" +#include "sysemu/kvm.h" static int gicv3_pre_save(void *opaque) { @@ -141,6 +142,79 @@ static const VMStateDescription vmstate_gicv3_cpu = { } }; +static int gicv3_gicd_no_migration_shift_bug_pre_load(void *opaque) +{ + GICv3State *cs = opaque; + + /* + * The gicd_no_migration_shift_bug flag is used for migration compatibility + * for old version QEMU which may have the GICD bmp shift bug under KVM mode. + * Strictly, what we want to know is whether the migration source is using + * KVM. Since we don't have any way to determine that, we look at whether the + * destination is using KVM; this is close enough because for the older QEMU + * versions with this bug KVM -> TCG migration didn't work anyway. If the + * source is a newer QEMU without this bug it will transmit the migration + * subsection which sets the flag to true; otherwise it will remain set to + * the value we select here. + */ + if (kvm_enabled()) { + cs->gicd_no_migration_shift_bug = false; + } + + return 0; +} + +static int gicv3_gicd_no_migration_shift_bug_post_load(void *opaque, + int version_id) +{ + GICv3State *cs = opaque; + + if (cs->gicd_no_migration_shift_bug) { + return 0; + } + + /* Older versions of QEMU had a bug in the handling of state save/restore + * to the KVM GICv3: they got the offset in the bitmap arrays wrong, + * so that instead of the data for external interrupts 32 and up + * starting at bit position 32 in the bitmap, it started at bit + * position 64. If we're receiving data from a QEMU with that bug, + * we must move the data down into the right place. + */ + memmove(cs->group, (uint8_t *)cs->group + GIC_INTERNAL / 8, + sizeof(cs->group) - GIC_INTERNAL / 8); + memmove(cs->grpmod, (uint8_t *)cs->grpmod + GIC_INTERNAL / 8, + sizeof(cs->grpmod) - GIC_INTERNAL / 8); + memmove(cs->enabled, (uint8_t *)cs->enabled + GIC_INTERNAL / 8, + sizeof(cs->enabled) - GIC_INTERNAL / 8); + memmove(cs->pending, (uint8_t *)cs->pending + GIC_INTERNAL / 8, + sizeof(cs->pending) - GIC_INTERNAL / 8); + memmove(cs->active, (uint8_t *)cs->active + GIC_INTERNAL / 8, + sizeof(cs->active) - GIC_INTERNAL / 8); + memmove(cs->edge_trigger, (uint8_t *)cs->edge_trigger + GIC_INTERNAL / 8, + sizeof(cs->edge_trigger) - GIC_INTERNAL / 8); + + /* + * While this new version QEMU doesn't have this kind of bug as we fix it, + * so it needs to set the flag to true to indicate that and it's necessary + * for next migration to work from this new version QEMU. + */ + cs->gicd_no_migration_shift_bug = true; + + return 0; +} + +const VMStateDescription vmstate_gicv3_gicd_no_migration_shift_bug = { + .name = "arm_gicv3/gicd_no_migration_shift_bug", + .version_id = 1, + .minimum_version_id = 1, + .pre_load = gicv3_gicd_no_migration_shift_bug_pre_load, + .post_load = gicv3_gicd_no_migration_shift_bug_post_load, + .fields = (VMStateField[]) { + VMSTATE_BOOL(gicd_no_migration_shift_bug, GICv3State), + VMSTATE_END_OF_LIST() + } +}; + static const VMStateDescription vmstate_gicv3 = { .name = "arm_gicv3", .version_id = 1, @@ -165,6 +239,10 @@ static const VMStateDescription vmstate_gicv3 = { VMSTATE_STRUCT_VARRAY_POINTER_UINT32(cpu, GICv3State, num_cpu, vmstate_gicv3_cpu, GICv3CPUState), VMSTATE_END_OF_LIST() + }, + .subsections = (const VMStateDescription * []) { + &vmstate_gicv3_gicd_no_migration_shift_bug, + NULL } }; @@ -364,6 +442,7 @@ static void arm_gicv3_common_reset(DeviceState *dev) gicv3_gicd_group_set(s, i); } } + s->gicd_no_migration_shift_bug = true; } static void arm_gic_common_linux_init(ARMLinuxBootIf *obj, diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c index 3536795501..81cbd16817 100644 --- a/hw/intc/arm_gicv3_kvm.c +++ b/hw/intc/arm_gicv3_kvm.c @@ -164,6 +164,14 @@ static void kvm_dist_get_edge_trigger(GICv3State *s, uint32_t offset, uint32_t reg; int irq; + /* For the KVM GICv3, affinity routing is always enabled, and the first 2 + * GICD_ICFGR registers are always RAZ/WI. The corresponding + * functionality is replaced by GICR_ICFGR. It doesn't need to sync + * them. So it should increase the offset to skip GIC_INTERNAL irqs. + * This matches the for_each_dist_irq_reg() macro which also skips the + * first GIC_INTERNAL irqs. + */ + offset += (GIC_INTERNAL * 2) / 8; for_each_dist_irq_reg(irq, s->num_irq, 2) { kvm_gicd_access(s, offset, ®, false); reg = half_unshuffle32(reg >> 1); @@ -181,6 +189,14 @@ static void kvm_dist_put_edge_trigger(GICv3State *s, uint32_t offset, uint32_t reg; int irq; + /* For the KVM GICv3, affinity routing is always enabled, and the first 2 + * GICD_ICFGR registers are always RAZ/WI. The corresponding + * functionality is replaced by GICR_ICFGR. It doesn't need to sync + * them. So it should increase the offset to skip GIC_INTERNAL irqs. + * This matches the for_each_dist_irq_reg() macro which also skips the + * first GIC_INTERNAL irqs. + */ + offset += (GIC_INTERNAL * 2) / 8; for_each_dist_irq_reg(irq, s->num_irq, 2) { reg = *gic_bmp_ptr32(bmp, irq); if (irq % 32 != 0) { @@ -222,6 +238,15 @@ static void kvm_dist_getbmp(GICv3State *s, uint32_t offset, uint32_t *bmp) uint32_t reg; int irq; + /* For the KVM GICv3, affinity routing is always enabled, and the + * GICD_IGROUPR0/GICD_IGRPMODR0/GICD_ISENABLER0/GICD_ISPENDR0/ + * GICD_ISACTIVER0 registers are always RAZ/WI. The corresponding + * functionality is replaced by the GICR registers. It doesn't need to sync + * them. So it should increase the offset to skip GIC_INTERNAL irqs. + * This matches the for_each_dist_irq_reg() macro which also skips the + * first GIC_INTERNAL irqs. + */ + offset += (GIC_INTERNAL * 1) / 8; for_each_dist_irq_reg(irq, s->num_irq, 1) { kvm_gicd_access(s, offset, ®, false); *gic_bmp_ptr32(bmp, irq) = reg; @@ -235,6 +260,19 @@ static void kvm_dist_putbmp(GICv3State *s, uint32_t offset, uint32_t reg; int irq; + /* For the KVM GICv3, affinity routing is always enabled, and the + * GICD_IGROUPR0/GICD_IGRPMODR0/GICD_ISENABLER0/GICD_ISPENDR0/ + * GICD_ISACTIVER0 registers are always RAZ/WI. The corresponding + * functionality is replaced by the GICR registers. It doesn't need to sync + * them. So it should increase the offset and clroffset to skip GIC_INTERNAL + * irqs. This matches the for_each_dist_irq_reg() macro which also skips the + * first GIC_INTERNAL irqs. + */ + offset += (GIC_INTERNAL * 1) / 8; + if (clroffset != 0) { + clroffset += (GIC_INTERNAL * 1) / 8; + } + for_each_dist_irq_reg(irq, s->num_irq, 1) { /* If this bitmap is a set/clear register pair, first write to the * clear-reg to clear all bits before using the set-reg to write diff --git a/include/hw/intc/arm_gicv3_common.h b/include/hw/intc/arm_gicv3_common.h index bccdfe17c6..d75b49d558 100644 --- a/include/hw/intc/arm_gicv3_common.h +++ b/include/hw/intc/arm_gicv3_common.h @@ -217,6 +217,7 @@ struct GICv3State { uint32_t revision; bool security_extn; bool irq_reset_nonsecure; + bool gicd_no_migration_shift_bug; int dev_fd; /* kvm device fd if backed by kvm vgic support */ Error *migration_blocker; From patchwork Mon Jul 23 20:16:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948012 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="VYla2jS0"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZD1V56Tqz9s4V for ; Tue, 24 Jul 2018 06:41:50 +1000 (AEST) Received: from localhost ([::1]:36462 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhheO-0004df-DO for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 16:41:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41520) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhJ9-0002J8-KC for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhJ8-0003tF-5G for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:51 -0400 Received: from mail-oi0-x244.google.com ([2607:f8b0:4003:c06::244]:35587) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhJ7-0003sv-Vc; Mon, 23 Jul 2018 16:19:50 -0400 Received: by mail-oi0-x244.google.com with SMTP id i12-v6so3498569oik.2; Mon, 23 Jul 2018 13:19:49 -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=pCk61jNpASXSU8QTX4bas5qw8IAILTpMH8w0PEvfmEA=; b=VYla2jS0+BJGVTlCGwA1kRthH1XvAUyA32HruGjIjFEBecUB3BZIc6ft3D2NFtb2el nosGYicVX/4fbYBSUKztPxEKRmkXkxE/2uT6Gquqz9QNOP5Dna3Wohf30DtnmrhdmB0u 9Crudyueg5nNpiHNYnq87he7b7Yg1OjfvRaDwClRe2oOf4/Exq8whuApszdfhyuXgrsd DCk1HlVOS6k6RL2BiqgFtfAcdFcQX6+jy05ky4+J4z/xW28KbfF6iPuyx/WjiYXsWIrz 8OhdjoS6AZkKpzkT6YwG88nyoUPKpEXu68S3Pfpd1Vw/D/EaFE4pKkB9Omei2AZ81C2M LkXA== 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=pCk61jNpASXSU8QTX4bas5qw8IAILTpMH8w0PEvfmEA=; b=FERy8G+7bJaXdPDgXlMelDBsYVatU0PhInNcEwuiTFb279ofCIODa2uixLH+LcGE1K w89cf52aOGnD4WPCY7P1nYkHvfU48xvTKMgNR55IM9XjwcmvRR9fXLWOftabJM/yswBH SYB6UvCqQKw3cz2ytNCodiQr0YZIf2LTnt+0Hwn9cNbz7XB68VBf5pHQxblYQvBRI9I8 hfbtnm41XAgBf2hrBiVJMaRnR6kOBwT18T9Rb595FnEoMFX++ACYyMmJOpUEP5VxtKdu 4inonyF6Qh4dNeUUqDkC+1CGlb2+Lcm87P4ZZjFloOjn6FiyuBhPbwhas+oI/bu8uj5S 5hkA== X-Gm-Message-State: AOUpUlHBuoSlQ5+P3/xJnWxfd0y/NAx7iNBvvSNosHNZMxsneBbmiYNJ 07Es8jBHtP2KZ3yA18opeic2ldlPRqc= X-Google-Smtp-Source: AAOMgpeaI776ucPrS5PCR9x02QRkJY9ifJSFoImF87dl0EB18FTT7LiX4u1ydkH0O0R1VcAYEmMyvA== X-Received: by 2002:aca:be56:: with SMTP id o83-v6mr270674oif.301.1532377188838; Mon, 23 Jul 2018 13:19:48 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id i204-v6sm19818274oia.41.2018.07.23.13.19.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:19:47 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:16:47 -0500 Message-Id: <20180723201748.25573-39-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::244 Subject: [Qemu-devel] [PATCH 38/99] block: Make bdrv_is_writable() public 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: qemu-stable@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Max Reitz This is a useful function for the whole block layer, so make it public. At the same time, users outside of block.c probably do not need to make use of the reopen functionality, so rename the current function to bdrv_is_writable_after_reopen() create a new bdrv_is_writable() function that just passes NULL to it for the reopen queue. Cc: qemu-stable@nongnu.org Signed-off-by: Max Reitz Message-id: 20180606193702.7113-2-mreitz@redhat.com Reviewed-by: John Snow Reviewed-by: Jeff Cody Signed-off-by: Max Reitz (cherry picked from commit cc022140972f8b6ac3973c12ccf9dd6b1d2fd200) Signed-off-by: Michael Roth --- block.c | 17 ++++++++++++++--- include/block/block.h | 1 + 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/block.c b/block.c index a2caadf0a0..9af22179ce 100644 --- a/block.c +++ b/block.c @@ -1620,13 +1620,24 @@ static int bdrv_reopen_get_flags(BlockReopenQueue *q, BlockDriverState *bs) /* Returns whether the image file can be written to after the reopen queue @q * has been successfully applied, or right now if @q is NULL. */ -static bool bdrv_is_writable(BlockDriverState *bs, BlockReopenQueue *q) +static bool bdrv_is_writable_after_reopen(BlockDriverState *bs, + BlockReopenQueue *q) { int flags = bdrv_reopen_get_flags(q, bs); return (flags & (BDRV_O_RDWR | BDRV_O_INACTIVE)) == BDRV_O_RDWR; } +/* + * Return whether the BDS can be written to. This is not necessarily + * the same as !bdrv_is_read_only(bs), as inactivated images may not + * be written to but do not count as read-only images. + */ +bool bdrv_is_writable(BlockDriverState *bs) +{ + return bdrv_is_writable_after_reopen(bs, NULL); +} + static void bdrv_child_perm(BlockDriverState *bs, BlockDriverState *child_bs, BdrvChild *c, const BdrvChildRole *role, BlockReopenQueue *reopen_queue, @@ -1664,7 +1675,7 @@ static int bdrv_check_perm(BlockDriverState *bs, BlockReopenQueue *q, /* Write permissions never work with read-only images */ if ((cumulative_perms & (BLK_PERM_WRITE | BLK_PERM_WRITE_UNCHANGED)) && - !bdrv_is_writable(bs, q)) + !bdrv_is_writable_after_reopen(bs, q)) { error_setg(errp, "Block node is read-only"); return -EPERM; @@ -1956,7 +1967,7 @@ void bdrv_format_default_perms(BlockDriverState *bs, BdrvChild *c, &perm, &shared); /* Format drivers may touch metadata even if the guest doesn't write */ - if (bdrv_is_writable(bs, reopen_queue)) { + if (bdrv_is_writable_after_reopen(bs, reopen_queue)) { perm |= BLK_PERM_WRITE | BLK_PERM_RESIZE; } diff --git a/include/block/block.h b/include/block/block.h index cdec3639a3..68a667a742 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -400,6 +400,7 @@ bool bdrv_is_read_only(BlockDriverState *bs); int bdrv_can_set_read_only(BlockDriverState *bs, bool read_only, bool ignore_allow_rdw, Error **errp); int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp); +bool bdrv_is_writable(BlockDriverState *bs); bool bdrv_is_sg(BlockDriverState *bs); bool bdrv_is_inserted(BlockDriverState *bs); void bdrv_lock_medium(BlockDriverState *bs, bool locked); From patchwork Mon Jul 23 20:16:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948017 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="rxmUoRhC"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZD6N0dZhz9ryn for ; Tue, 24 Jul 2018 06:46:04 +1000 (AEST) Received: from localhost ([::1]:36494 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhiT-0008Fl-Kf for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 16:46:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41554) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhJB-0002L8-5c for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhJA-0003vq-9x for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:53 -0400 Received: from mail-oi0-x241.google.com ([2607:f8b0:4003:c06::241]:44290) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhJA-0003vT-4E; Mon, 23 Jul 2018 16:19:52 -0400 Received: by mail-oi0-x241.google.com with SMTP id s198-v6so3460255oih.11; Mon, 23 Jul 2018 13:19:52 -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=LSW7cJQsGNP6NaUCPYsYqHrf1131Q3vBz4gLq9OQTek=; b=rxmUoRhC6BnVaEjhzF98kkAE0k1uoHfePOAmLSDrqrbl+ZdZxt+HQc/2ZOrABmTDgf FnCvktz1vxQVBKrzROriFZCr4jqKuQdP4YyECeN+TqoSAphYvAf0NfyR6U+l4/Pzbh+P BpIM0Cor/gNTdc555td5bXPwsDxW6uPreK8eS2jiRPM3Nx7iIqRxkKuFqp4EHlCReLOi XakUGuKZgo7I3VykuvZdGDdH/Qvhlo+5IhR/PRPt0FfqwvpfdVNvilCyb6Z+WOUveeQj HULvJcZs0sarQjW2ZU+4ras6SDW56Aj29hxhCNOcEnvUIp3IkAnOkp90fRVlqQFawlfS 9SxQ== 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=LSW7cJQsGNP6NaUCPYsYqHrf1131Q3vBz4gLq9OQTek=; b=Et92XzNPT7OKH4rXUiq8I0qvMbg30cjUSFh4Z9q2b1SWuvq7Jhu4hy4QXQhg+OhnZm 5skg57i+pAMJg8CHNrYIKxZwRPDAPE3oYx3zeLIzp+Gg6tPXNEQ+GFnoBGNRYkuicwb+ nlexWyAiwcbgy9rfOLnw7JfN1OnbvtQntoQk/OoLOslR9auSi8Kul09+28yUnLZB+AAM 450K8UdmzPaZCsLLjLfUbmXejZglqLTZs+bKnv6Pz4bHoT/EiXCHBH0DlAvFFcYfZmaM GaawhIK2d0aonTF0DH/OznGy1jNjseaf6Wpvf00iAwlykeLLmTedMM1tz4UNFjpzK14+ cyyg== X-Gm-Message-State: AOUpUlElufVL7FhtXPLjDW5/IyqzVASh4D0hiEYSMKnSfbF8D3WdXroZ Qqq0GDaDgPlDQ9ANdiWXtFkDkzLCmz8= X-Google-Smtp-Source: AAOMgpcXm5RccaLeneOOv88pakASAL76VfBA+DeDELqpd7BJJDPFzekgnhao/GrzhXEsROQKk38POw== X-Received: by 2002:aca:4ec6:: with SMTP id c189-v6mr329838oib.186.1532377191012; Mon, 23 Jul 2018 13:19:51 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id p132-v6sm7739726oia.31.2018.07.23.13.19.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:19:49 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:16:48 -0500 Message-Id: <20180723201748.25573-40-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::241 Subject: [Qemu-devel] [PATCH 39/99] qcow2: Do not mark inactive images corrupt 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: qemu-stable@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Max Reitz When signaling a corruption on a read-only image, qcow2 already makes fatal events non-fatal (i.e., they will not result in the image being closed, and the image header's corrupt flag will not be set). This is necessary because we cannot set the corrupt flag on read-only images, and it is possible because further corruption of read-only images is impossible. Inactive images are effectively read-only, too, so we should do the same for them. bdrv_is_writable() can tell us whether an image can actually be written to, so use its result instead of !bs->read_only. (Otherwise, the assert(!(bs->open_flags & BDRV_O_INACTIVE)) in bdrv_co_pwritev() will fail, crashing qemu.) Cc: qemu-stable@nongnu.org Signed-off-by: Max Reitz Message-id: 20180606193702.7113-3-mreitz@redhat.com Reviewed-by: John Snow Reviewed-by: Jeff Cody Signed-off-by: Max Reitz (cherry picked from commit ddf3b47ef4b5ed0bf6558d4c2c8ae130b8d8a580) Signed-off-by: Michael Roth --- block/qcow2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/qcow2.c b/block/qcow2.c index ef68772aca..a2b2e5d4cd 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -4386,7 +4386,7 @@ void qcow2_signal_corruption(BlockDriverState *bs, bool fatal, int64_t offset, char *message; va_list ap; - fatal = fatal && !bs->read_only; + fatal = fatal && bdrv_is_writable(bs); if (s->signaled_corruption && (!fatal || (s->incompatible_features & QCOW2_INCOMPAT_CORRUPT))) From patchwork Mon Jul 23 20:16:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948030 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="WXqsRMtu"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZDMG10Svz9ryn for ; Tue, 24 Jul 2018 06:57:14 +1000 (AEST) Received: from localhost ([::1]:36561 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhtH-0000NS-Nz for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 16:57:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41607) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhJD-0002Ns-GU for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhJC-0003yg-C8 for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:19:55 -0400 Received: from mail-oi0-x22b.google.com ([2607:f8b0:4003:c06::22b]:37377) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhJC-0003xu-6D; Mon, 23 Jul 2018 16:19:54 -0400 Received: by mail-oi0-x22b.google.com with SMTP id k81-v6so3474947oib.4; Mon, 23 Jul 2018 13:19:54 -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=s0wNDhDyswjhaeD8WyO9lAk7f+hfMkZUiW8OBsvTHlQ=; b=WXqsRMtutzPpvs05Y71ddEwgLJxVJm9KMXTidcPUCqpXIHoLA/xT/ljk3yJwXlzV6J zMcVN7ZmoFzQdwLMLBxKu18Hh2aCzeR/Uxnvr7y9yVfh/kLJBx4ll+WA2JepBbpneMm5 L1OyXbhwLPRE+hvtPKMdSmmfQASRf8EbfEsTq+H+BXBwx6i4LQTe2yRvR9dGQDGQpO52 WM0FvdBWIlHgYjG3Ioj1Hzay9MQq+/xqwA4lWkrvXEUacxbRGEfpcREHQdzoTd4AWeaW jKWmKoHZKwUYO6a/M7IggpDSAEzCxZrn8yy6ZqISdbCgazF2orfiKvI45OsnjbeIh/Qb Imew== 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=s0wNDhDyswjhaeD8WyO9lAk7f+hfMkZUiW8OBsvTHlQ=; b=hU6q4rCligqQMCRPJ0qxXpjlAtifvKgBpHUvHmAU3yZKT8LE7xfYbF7gOiUiT7uq5k JwqvkvrZ57KM7Xc1fbw0TUy9G9xtQv1eR18wTedHNRUo5RKBhtz1OR5WobcR7gs6RW7S i+zkX9E1a9Xui8rJg4sDrMf+oRAk7Wkrw8UIrF3HSPC7+UqM0Zy+Ju/7qd1CNgrw+OAM TDugWJodag7sdkGv54nQ3KXQ2HCG+mHT7FA2FYrhOPAUyypdWDByDvz3tIlDuT61RgFL m0jkEB13zgYAYRWvaFzU9UzJGZLDK/mZe9dupQjrrQv41kMS489VBgI0n45A4cm6OE3r sCrA== X-Gm-Message-State: AOUpUlETuHzi0sdE3gUBY6Tc2X30MvanZg9GcBvxDfWRuJjW5KYfaoar FEbnNv+HhenghO6FXOHE+nkURgzxs2Q= X-Google-Smtp-Source: AAOMgpeT8adPTuvXMnzi+jVFs6AqNuGeSp6uvVUSthuG1QRoPs0O08K1SYYf+VIXXH1FQOaa56Uifg== X-Received: by 2002:aca:90d:: with SMTP id 13-v6mr322748oij.300.1532377193008; Mon, 23 Jul 2018 13:19:53 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id d191-v6sm11785799oig.16.2018.07.23.13.19.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:19:51 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:16:49 -0500 Message-Id: <20180723201748.25573-41-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::22b Subject: [Qemu-devel] [PATCH 40/99] iotests: Add case for a corrupted inactive image 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: qemu-stable@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Max Reitz Reviewed-by: John Snow Tested-by: Jeff Cody Reviewed-by: Jeff Cody Signed-off-by: Max Reitz Message-id: 20180606193702.7113-4-mreitz@redhat.com Signed-off-by: Max Reitz (cherry picked from commit c50abd175a88cd41c2c08339de91f6f6e4a7b162) Signed-off-by: Michael Roth --- tests/qemu-iotests/060 | 30 ++++++++++++++++++++++++++++++ tests/qemu-iotests/060.out | 14 ++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/tests/qemu-iotests/060 b/tests/qemu-iotests/060 index 6c7407f499..7bdf609f3f 100755 --- a/tests/qemu-iotests/060 +++ b/tests/qemu-iotests/060 @@ -440,6 +440,36 @@ echo "{'execute': 'qmp_capabilities'} -drive if=none,node-name=drive,file="$TEST_IMG",driver=qcow2 \ | _filter_qmp | _filter_qemu_io +echo +echo "=== Testing incoming inactive corrupted image ===" +echo + +_make_test_img 64M +# Create an unaligned L1 entry, so qemu will signal a corruption when +# reading from the covered area +poke_file "$TEST_IMG" "$l1_offset" "\x00\x00\x00\x00\x2a\x2a\x2a\x2a" + +# Inactive images are effectively read-only images, so this should be a +# non-fatal corruption (which does not modify the image) +echo "{'execute': 'qmp_capabilities'} + {'execute': 'human-monitor-command', + 'arguments': {'command-line': 'qemu-io drive \"read 0 512\"'}} + {'execute': 'quit'}" \ + | $QEMU -qmp stdio -nographic -nodefaults \ + -blockdev "{'node-name': 'drive', + 'driver': 'qcow2', + 'file': { + 'driver': 'file', + 'filename': '$TEST_IMG' + }}" \ + -incoming exec:'cat /dev/null' \ + 2>&1 \ + | _filter_qmp | _filter_qemu_io + +echo +# Image should not have been marked corrupt +_img_info --format-specific | grep 'corrupt:' + # success, all done echo "*** done" rm -f $seq.full diff --git a/tests/qemu-iotests/060.out b/tests/qemu-iotests/060.out index 25d5c3938b..99234fbfc2 100644 --- a/tests/qemu-iotests/060.out +++ b/tests/qemu-iotests/060.out @@ -420,4 +420,18 @@ write failed: Input/output error {"return": ""} {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}} + +=== Testing incoming inactive corrupted image === + +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 +QMP_VERSION +{"return": {}} +qcow2: Image is corrupt: L2 table offset 0x2a2a2a00 unaligned (L1 index: 0); further non-fatal corruption events will be suppressed +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_IMAGE_CORRUPTED", "data": {"device": "", "msg": "L2 table offset 0x2a2a2a00 unaligned (L1 index: 0)", "node-name": "drive", "fatal": false}} +read failed: Input/output error +{"return": ""} +{"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}} + + corrupt: false *** done From patchwork Mon Jul 23 20:16:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948020 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="qsF+HW8X"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZDBY0tKKz9s3Z for ; Tue, 24 Jul 2018 06:49:40 +1000 (AEST) Received: from localhost ([::1]:36515 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhly-0002Hd-Ga for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 16:49:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41676) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhJI-0002Tt-OH for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhJG-00046v-JH for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:00 -0400 Received: from mail-oi0-x235.google.com ([2607:f8b0:4003:c06::235]:42539) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhJG-00045R-Cu; Mon, 23 Jul 2018 16:19:58 -0400 Received: by mail-oi0-x235.google.com with SMTP id n84-v6so3465019oib.9; Mon, 23 Jul 2018 13:19:58 -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=jXsN2Q+sxs+JhQkNlK+/daRT2a5Egg638Mhim1g4XHs=; b=qsF+HW8XdVYDpOUyw8Zm04MaxIMui/D5Ctrq/Q3i8VXQgAx3kaWJ9twdJ/sI3Y5nWx E4s5WLaeh/MdLSa4kcmEemIO88h1oEfpd15H4zE9xmNPuez1PNwLrcqzKhK0SIup0E8y h6rFZV+WOHULiTlQtmI4CuqyGlrYf8U8gWsE7lASeF/1bVb7OQ25upZkG6oLn7hkcdmW ltgIS0/Nf3ZQrDyeVgf+3AcTGqs3MOwSnPuHnNH5dl1StXQD+xJiekqez+RSoJVlyo7i GJA8H9MedXKwtCBtgj0AOLonpMV5dynXJrJTShfnsMsAB1m50J1gzQmJT4istMgjlb1V 6LBA== 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=jXsN2Q+sxs+JhQkNlK+/daRT2a5Egg638Mhim1g4XHs=; b=Y0tp1UtAq063sfuLdeiaG30Ygy6vlf7mGIuhA5+xq/OeJ+rpRx61I56+joq+iZTzsN bzIFd+lZMk8VGfZLhpT2VRWhwMoBO5z6MKRIhkB81xx+PTGNXR9GdXe1hP8kFWGV3q5T E7F7VaBjmkM0d0CuW4l7WhQ++kav0AshzrsFPuJyT3O+88Eybo+8pDsYBekMCilRB+6T DbI8t7QEa04BWcHM4BSOldQWxLa6NubezvBZkPCA0Mg2vOthu/Jx67FuCO+7yzBW5QKz IJ70gonhG0szYDrH14ogMpk9JZcDnP3OP3p0z0gbVuUS3atOBiXqRUQplyySwulPBRPN 5T+A== X-Gm-Message-State: AOUpUlFUSFkGDAdcVIBbE+wG6C84jJbMzqF8VTMmdIGCi+ajRzQS4xWY yRl0ktKq8X8Z6/QzhCGPFHlm1CDRPYw= X-Google-Smtp-Source: AAOMgpcm71oNfiEXdORaRCC+Pmv03cU2QKgo5z8CNXmy0chsrJuOqGWLHCfkuAyQwWz8/jnd6B43zw== X-Received: by 2002:aca:3c02:: with SMTP id j2-v6mr348883oia.50.1532377197182; Mon, 23 Jul 2018 13:19:57 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id i132-v6sm11471143oif.20.2018.07.23.13.19.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:19:56 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:16:50 -0500 Message-Id: <20180723201748.25573-42-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::235 Subject: [Qemu-devel] [PATCH 41/99] throttle: Fix crash on reopen 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: Alberto Garcia , qemu-stable@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Alberto Garcia The throttle block filter can be reopened, and with this it is possible to change the throttle group that the filter belongs to. The way the code does that is the following: - On throttle_reopen_prepare(): create a new ThrottleGroupMember and attach it to the new throttle group. - On throttle_reopen_commit(): detach the old ThrottleGroupMember, delete it and replace it with the new one. The problem with this is that by replacing the ThrottleGroupMember the previous value of io_limits_disabled is lost, causing an assertion failure in throttle_co_drain_end(). This problem can be reproduced by reopening a throttle node: $QEMU -monitor stdio -object throttle-group,id=tg0,x-iops-total=1000 \ -blockdev node-name=hd0,driver=qcow2,file.driver=file,file.filename=hd.qcow2 \ -blockdev node-name=root,driver=throttle,throttle-group=tg0,file=hd0,read-only=on (qemu) block_stream root block/throttle.c:214: throttle_co_drain_end: Assertion `tgm->io_limits_disabled' failed. Since we only want to change the throttle group on reopen there's no need to create a ThrottleGroupMember and discard the old one. It's easier if we simply detach it from its current group and attach it to the new one. Signed-off-by: Alberto Garcia Message-id: 20180608151536.7378-1-berto@igalia.com Signed-off-by: Max Reitz (cherry picked from commit bc33c047d1ec0b35c9cd8be62bcefae2da28654f) Signed-off-by: Michael Roth --- block/throttle.c | 54 +++++++++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 21 deletions(-) diff --git a/block/throttle.c b/block/throttle.c index 95ed06acd8..026f408aa6 100644 --- a/block/throttle.c +++ b/block/throttle.c @@ -36,9 +36,12 @@ static QemuOptsList throttle_opts = { }, }; -static int throttle_configure_tgm(BlockDriverState *bs, - ThrottleGroupMember *tgm, - QDict *options, Error **errp) +/* + * If this function succeeds then the throttle group name is stored in + * @group and must be freed by the caller. + * If there's an error then @group remains unmodified. + */ +static int throttle_parse_options(QDict *options, char **group, Error **errp) { int ret; const char *group_name; @@ -63,8 +66,7 @@ static int throttle_configure_tgm(BlockDriverState *bs, goto fin; } - /* Register membership to group with name group_name */ - throttle_group_register_tgm(tgm, group_name, bdrv_get_aio_context(bs)); + *group = g_strdup(group_name); ret = 0; fin: qemu_opts_del(opts); @@ -75,6 +77,8 @@ static int throttle_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { ThrottleGroupMember *tgm = bs->opaque; + char *group; + int ret; bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, false, errp); @@ -84,7 +88,14 @@ static int throttle_open(BlockDriverState *bs, QDict *options, bs->supported_write_flags = bs->file->bs->supported_write_flags; bs->supported_zero_flags = bs->file->bs->supported_zero_flags; - return throttle_configure_tgm(bs, tgm, options, errp); + ret = throttle_parse_options(options, &group, errp); + if (ret == 0) { + /* Register membership to group with name group_name */ + throttle_group_register_tgm(tgm, group, bdrv_get_aio_context(bs)); + g_free(group); + } + + return ret; } static void throttle_close(BlockDriverState *bs) @@ -160,35 +171,36 @@ static void throttle_attach_aio_context(BlockDriverState *bs, static int throttle_reopen_prepare(BDRVReopenState *reopen_state, BlockReopenQueue *queue, Error **errp) { - ThrottleGroupMember *tgm; + int ret; + char *group = NULL; assert(reopen_state != NULL); assert(reopen_state->bs != NULL); - reopen_state->opaque = g_new0(ThrottleGroupMember, 1); - tgm = reopen_state->opaque; - - return throttle_configure_tgm(reopen_state->bs, tgm, reopen_state->options, - errp); + ret = throttle_parse_options(reopen_state->options, &group, errp); + reopen_state->opaque = group; + return ret; } static void throttle_reopen_commit(BDRVReopenState *reopen_state) { - ThrottleGroupMember *old_tgm = reopen_state->bs->opaque; - ThrottleGroupMember *new_tgm = reopen_state->opaque; + BlockDriverState *bs = reopen_state->bs; + ThrottleGroupMember *tgm = bs->opaque; + char *group = reopen_state->opaque; + + assert(group); - throttle_group_unregister_tgm(old_tgm); - g_free(old_tgm); - reopen_state->bs->opaque = new_tgm; + if (strcmp(group, throttle_group_get_name(tgm))) { + throttle_group_unregister_tgm(tgm); + throttle_group_register_tgm(tgm, group, bdrv_get_aio_context(bs)); + } + g_free(reopen_state->opaque); reopen_state->opaque = NULL; } static void throttle_reopen_abort(BDRVReopenState *reopen_state) { - ThrottleGroupMember *tgm = reopen_state->opaque; - - throttle_group_unregister_tgm(tgm); - g_free(tgm); + g_free(reopen_state->opaque); reopen_state->opaque = NULL; } From patchwork Mon Jul 23 20:16:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948025 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Z9k4fasw"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZDG503bXz9ryn for ; Tue, 24 Jul 2018 06:52:45 +1000 (AEST) Received: from localhost ([::1]:36534 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhow-0004mj-N4 for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 16:52:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41691) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhJJ-0002Us-Km for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhJI-0004BP-KF for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:01 -0400 Received: from mail-oi0-x22e.google.com ([2607:f8b0:4003:c06::22e]:40344) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhJI-0004A3-FD; Mon, 23 Jul 2018 16:20:00 -0400 Received: by mail-oi0-x22e.google.com with SMTP id w126-v6so3475030oie.7; Mon, 23 Jul 2018 13:20:00 -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=G6JoazjMed40MVxyj1L+YCMC0uKoKnoH67yK7zwbZaE=; b=Z9k4faswsPaL+Q3hv0Qn0WsN3rRSV3u9I1JYoG9rIgagYoGIG+z75HmQb1WSOyyUHY 7RnHqBroImGxYOZkXikuChgl+I0cj+l8+qFnQhDbjQY5QTrYKKHaZRnRlv9ODceCGeyo 7CFh7pgbzAi5BkBkla0UPSJF4H+5nRkgtRYRTSFIUsKYwDYUwsomBJuVE4/x99HrBFa7 Td2L5b2zppM2nSo/x9u/qaluAWi7GxJfhKBGIdehAvO78InKXkPdhlv5x7vbkOxKUWmM OygGZtf+aAlN5TqONcIGLDpZt2eavLE3pfREpXnUIspMMSK1tkeW9A/ZZlCPmNf3Zfji Hz7Q== 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=G6JoazjMed40MVxyj1L+YCMC0uKoKnoH67yK7zwbZaE=; b=gsX8eBwK2vyxFUMUqynWSRLM4gRVhyS/3VU2CAevApYQad/MynssAkBq5S+FIBQSEC aUNtn2rs4AzLJp9AsV83+5fwvXx6Jq3af6VFcM0PqbP6a6aGg9yonBY2Jw5IpCK5Cm9V 7vpvQ9yppe4DJTz9INIFXBv5BCHIy3ffQ1i65vO38Qb4FKRWfzGLUuyySq/kuH2zKo2W 2dVqgKnR+A3hc6S15HvMhhagzHF5XvkJs8gyVULXX/GtKPpRzr5E01XGUhg7nf4jZD6+ Kav3qHcbXV2I9EJZDyu8Lu++EJr4A5KRvefP18eSad0FjMs/u1S6JeFBQ7IKqxeD0OFJ FRdg== X-Gm-Message-State: AOUpUlE1ZvhmRXELf7X6E5qm+dWp3JtwaKt/SWn7Kwz9S06kR4xDQ81D vurSSBiSTO5oO9EuZOLPPKSGscCVxOQ= X-Google-Smtp-Source: AAOMgpf1zugu830ldBewTUNYskQiBdPoD1uj79O6iGnq4zn4FFK1q4jDP317N3AFM5yBsSRaghevlg== X-Received: by 2002:aca:f5d1:: with SMTP id t200-v6mr340273oih.12.1532377199227; Mon, 23 Jul 2018 13:19:59 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id d191-v6sm11786229oig.16.2018.07.23.13.19.57 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:19:58 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:16:51 -0500 Message-Id: <20180723201748.25573-43-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::22e Subject: [Qemu-devel] [PATCH 42/99] i386: define the 'ssbd' CPUID feature bit (CVE-2018-3639) 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: qemu-stable@nongnu.org, Eduardo Habkost , Konrad Rzeszutek Wilk Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Daniel P. Berrangé New microcode introduces the "Speculative Store Bypass Disable" CPUID feature bit. This needs to be exposed to guest OS to allow them to protect against CVE-2018-3639. Signed-off-by: Daniel P. Berrangé Reviewed-by: Konrad Rzeszutek Wilk Signed-off-by: Konrad Rzeszutek Wilk Message-Id: <20180521215424.13520-2-berrange@redhat.com> Signed-off-by: Eduardo Habkost (cherry picked from commit d19d1f965904a533998739698020ff4ee8a103da) Signed-off-by: Michael Roth --- target/i386/cpu.c | 2 +- target/i386/cpu.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index a20fe26573..2f5263e22f 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -510,7 +510,7 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "spec-ctrl", NULL, - NULL, NULL, NULL, NULL, + NULL, NULL, NULL, "ssbd", }, .cpuid_eax = 7, .cpuid_needs_ecx = true, .cpuid_ecx = 0, diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 1b219fafc4..970ab96e54 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -684,6 +684,7 @@ typedef uint32_t FeatureWordArray[FEATURE_WORDS]; #define CPUID_7_0_EDX_AVX512_4VNNIW (1U << 2) /* AVX512 Neural Network Instructions */ #define CPUID_7_0_EDX_AVX512_4FMAPS (1U << 3) /* AVX512 Multiply Accumulation Single Precision */ #define CPUID_7_0_EDX_SPEC_CTRL (1U << 26) /* Speculation Control */ +#define CPUID_7_0_EDX_SPEC_CTRL_SSBD (1U << 31) /* Speculative Store Bypass Disable */ #define KVM_HINTS_DEDICATED (1U << 0) From patchwork Mon Jul 23 20:16:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948028 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Kz+1+baf"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZDKK0mTgz9s4V for ; Tue, 24 Jul 2018 06:55:32 +1000 (AEST) Received: from localhost ([::1]:36549 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhre-0007Lw-7w for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 16:55:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41725) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhJL-0002XJ-OG for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhJK-0004FO-Ey for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:03 -0400 Received: from mail-oi0-x241.google.com ([2607:f8b0:4003:c06::241]:38112) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhJK-0004EQ-8z; Mon, 23 Jul 2018 16:20:02 -0400 Received: by mail-oi0-x241.google.com with SMTP id v8-v6so3477908oie.5; Mon, 23 Jul 2018 13:20: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 :mime-version:content-transfer-encoding; bh=gzwlOawH4PtkHsI9A42W5MxYylvHtLdDYFtEu9+yvuM=; b=Kz+1+bafhSSvAkt4ygDGGQfNWE+pYtKqPWdas9kA7UaxOOh1+1YNGv4wnWlSPlenaE 2nXY/MUVr8Yl9SVn1pcMQ9RfgkyMTDm8+GfLst+dCX8Tp79D4nlrkNC4Mn+TEsjm0Ip2 jeqHh9VXeWOlMmRsZECDt9wrCGxfwJOPETfG87LG12pPiJbhGJyt6hVIWZJZ0RQgXRk8 sOOkYGFwHNO7FRvqt5OFg/KPNlI/E/vITIuRAPvfjmaydAZSx0nL+j9E26nqeEOn7E3i lXN2r0cfaMSkZR1JIfMm0ElgqhCi/Hv8Pn4nHKD034IR8Z6YPJPJ2PuqpJUeJvbkMzHc oX8Q== 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=gzwlOawH4PtkHsI9A42W5MxYylvHtLdDYFtEu9+yvuM=; b=ObrTmNV5o2jpAv+1Z2TzLmgPr2aXcRe4L5nxAmhytBRdBV1FyIdYZMx/IX6QLQHoEJ 0mIUnIN5TkvlUGu/WhJvLWr/m/0CnuhSgUkwfq3rwFF7hKln7OsWNO+yxvtitGtyZxeO djF40xYDv9eUb7NgbVhR/1XZugfEBoOdcwiL5FyB6hRgD2qzXSFAS54XSUwQ4gz+iOus qfKGJxGrIMovkV8P9lJICXQgecOxm+zsLBP3ouvq0hRW2vTKVe+cHESfYGEHMCOdcZ5D FDKKaeDEzL0aAx2CCjxKRLU1FP5gvSsmiNF7DCdVd5JJdgyKMcOQxJSmww3YFtNTjbc5 Anug== X-Gm-Message-State: AOUpUlFQvWtE3Xya+4aro9NmO0N8FuOEx/rUw0ihQmFYgOFZMzNBmGBg qxqEbR01fgbMOPJjoFljC3TMEMBglk0= X-Google-Smtp-Source: AAOMgpfjFew52bFMS6AshpTVToGu3cqh+0BaothCOlAPEnxTKoHXmRjRq4NGf4EqrQ5GbDTP8yWL/g== X-Received: by 2002:aca:4ac6:: with SMTP id x189-v6mr289980oia.211.1532377201181; Mon, 23 Jul 2018 13:20:01 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id r81-v6sm14553095oih.28.2018.07.23.13.19.59 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:20:00 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:16:52 -0500 Message-Id: <20180723201748.25573-44-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::241 Subject: [Qemu-devel] [PATCH 43/99] i386: Define the Virt SSBD MSR and handling of it (CVE-2018-3639) 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: qemu-stable@nongnu.org, Eduardo Habkost , Konrad Rzeszutek Wilk Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Konrad Rzeszutek Wilk "Some AMD processors only support a non-architectural means of enabling speculative store bypass disable (SSBD). To allow a simplified view of this to a guest, an architectural definition has been created through a new CPUID bit, 0x80000008_EBX[25], and a new MSR, 0xc001011f. With this, a hypervisor can virtualize the existence of this definition and provide an architectural method for using SSBD to a guest. Add the new CPUID feature, the new MSR and update the existing SSBD support to use this MSR when present." (from x86/speculation: Add virtualized speculative store bypass disable support in Linux). Signed-off-by: Konrad Rzeszutek Wilk Reviewed-by: Daniel P. Berrangé Signed-off-by: Daniel P. Berrangé Message-Id: <20180521215424.13520-4-berrange@redhat.com> Signed-off-by: Eduardo Habkost (cherry picked from commit cfeea0c021db6234c154dbc723730e81553924ff) Signed-off-by: Michael Roth --- target/i386/cpu.h | 2 ++ target/i386/kvm.c | 16 ++++++++++++++-- target/i386/machine.c | 20 ++++++++++++++++++++ 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 970ab96e54..75e821cefe 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -351,6 +351,7 @@ typedef enum X86Seg { #define MSR_IA32_FEATURE_CONTROL 0x0000003a #define MSR_TSC_ADJUST 0x0000003b #define MSR_IA32_SPEC_CTRL 0x48 +#define MSR_VIRT_SSBD 0xc001011f #define MSR_IA32_TSCDEADLINE 0x6e0 #define FEATURE_CONTROL_LOCKED (1<<0) @@ -1150,6 +1151,7 @@ typedef struct CPUX86State { uint32_t pkru; uint64_t spec_ctrl; + uint64_t virt_ssbd; /* End of state preserved by INIT (dummy marker). */ struct {} end_init_save; diff --git a/target/i386/kvm.c b/target/i386/kvm.c index 6c49954e68..19e6aa320d 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -92,6 +92,7 @@ static bool has_msr_hv_stimer; static bool has_msr_hv_frequencies; static bool has_msr_xss; static bool has_msr_spec_ctrl; +static bool has_msr_virt_ssbd; static bool has_msr_smi_count; static uint32_t has_architectural_pmu_version; @@ -1218,6 +1219,9 @@ static int kvm_get_supported_msrs(KVMState *s) case MSR_IA32_SPEC_CTRL: has_msr_spec_ctrl = true; break; + case MSR_VIRT_SSBD: + has_msr_virt_ssbd = true; + break; } } } @@ -1706,6 +1710,10 @@ static int kvm_put_msrs(X86CPU *cpu, int level) if (has_msr_spec_ctrl) { kvm_msr_entry_add(cpu, MSR_IA32_SPEC_CTRL, env->spec_ctrl); } + if (has_msr_virt_ssbd) { + kvm_msr_entry_add(cpu, MSR_VIRT_SSBD, env->virt_ssbd); + } + #ifdef TARGET_X86_64 if (lm_capable_kernel) { kvm_msr_entry_add(cpu, MSR_CSTAR, env->cstar); @@ -2077,8 +2085,9 @@ static int kvm_get_msrs(X86CPU *cpu) if (has_msr_spec_ctrl) { kvm_msr_entry_add(cpu, MSR_IA32_SPEC_CTRL, 0); } - - + if (has_msr_virt_ssbd) { + kvm_msr_entry_add(cpu, MSR_VIRT_SSBD, 0); + } if (!env->tsc_valid) { kvm_msr_entry_add(cpu, MSR_IA32_TSC, 0); env->tsc_valid = !runstate_is_running(); @@ -2444,6 +2453,9 @@ static int kvm_get_msrs(X86CPU *cpu) case MSR_IA32_SPEC_CTRL: env->spec_ctrl = msrs[i].data; break; + case MSR_VIRT_SSBD: + env->virt_ssbd = msrs[i].data; + break; case MSR_IA32_RTIT_CTL: env->msr_rtit_ctrl = msrs[i].data; break; diff --git a/target/i386/machine.c b/target/i386/machine.c index bd2d82e91b..f0a835c292 100644 --- a/target/i386/machine.c +++ b/target/i386/machine.c @@ -893,6 +893,25 @@ static const VMStateDescription vmstate_msr_intel_pt = { } }; +static bool virt_ssbd_needed(void *opaque) +{ + X86CPU *cpu = opaque; + CPUX86State *env = &cpu->env; + + return env->virt_ssbd != 0; +} + +static const VMStateDescription vmstate_msr_virt_ssbd = { + .name = "cpu/virt_ssbd", + .version_id = 1, + .minimum_version_id = 1, + .needed = virt_ssbd_needed, + .fields = (VMStateField[]){ + VMSTATE_UINT64(env.virt_ssbd, X86CPU), + VMSTATE_END_OF_LIST() + } +}; + VMStateDescription vmstate_x86_cpu = { .name = "cpu", .version_id = 12, @@ -1015,6 +1034,7 @@ VMStateDescription vmstate_x86_cpu = { &vmstate_spec_ctrl, &vmstate_mcg_ext_ctl, &vmstate_msr_intel_pt, + &vmstate_msr_virt_ssbd, NULL } }; From patchwork Mon Jul 23 20:16:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948021 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="HHk/xHwM"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZDBY3WVpz9s4V for ; Tue, 24 Jul 2018 06:49:41 +1000 (AEST) Received: from localhost ([::1]:36516 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhlz-0002II-4Q for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 16:49:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41770) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhJN-0002ZR-OO for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhJM-0004Il-Lk for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:05 -0400 Received: from mail-oi0-x230.google.com ([2607:f8b0:4003:c06::230]:45703) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhJM-0004Hv-GC; Mon, 23 Jul 2018 16:20:04 -0400 Received: by mail-oi0-x230.google.com with SMTP id q11-v6so3448472oic.12; Mon, 23 Jul 2018 13:20: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 :mime-version:content-transfer-encoding; bh=s+S+3OYqsGsKJ9Vr3Y7eOdQkdK5PtR3kkG62VO6As1I=; b=HHk/xHwMHRbYYCVEACAHA8rEVlVP7wqLKXrUfbRuAmyGM0PWGJNCT0i6yvsHbVwnnC S+xLQtKK6yXzYGVUpCmxyuSVtQ0lE1mUXiA5MrOm1QcjLPQuKrECbeVJetE/+UCXQ/Cw QVEVB4TkdBuCRvvpVhx+m25D9zXX1LhwX88B9YTwaehYzfGe+/Uz9sk71OUZw6dA4r+C 2dXL9eLurBNNOV5GOqBhM1Yse8yVplAibgEqKNg5sVNCYrYjO+h1Z/AG46gWOOB6eNSc WayP/pOAheZmPGiOnRqxsl0Euqgkl3j4fG+H/dqFAmGkNmrUirZBCu4Xdbk2/ekEzpor sILA== 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=s+S+3OYqsGsKJ9Vr3Y7eOdQkdK5PtR3kkG62VO6As1I=; b=hHh5Wmovjq62hZQh1BSSnHWq1AGMhjES/j2GOFpdFP+feQNVz4kgAVO0Y5Cl6HTpLL KbkIVW7cxDevXxN1mFX8MpW8Sk2K727RUZNwmjtKiShZImOTfFz/rTlyNvBoD8KDunz2 OU7Gnk38xCKI+sVKw8OLivUj9cPEl8cqkBUx8ibjRIk7w6UTiJzxKXA7Luf9uoV8NhY2 DOjoYlMQTRoQncz4EhGMWV0uQ3RQVsr8odQIa2PA9Tm5BLYj3Nkz0WRr3d7VXm3MynY4 RehbQAPiWgfEz3QCBsJsrPTRl6XKtNfrZCCb5E7L5n29NL8944N80ynKTlrdNf+RHYm8 QZXw== X-Gm-Message-State: AOUpUlHpVxoAaxSJe2Z3bM2RgPW5PUtvBTHL3ggLdXrHmWT3V9+jn2I5 oAmmAZmYMaITyvpPqD/GqikYHXsKiNY= X-Google-Smtp-Source: AAOMgpf3sS6j62UvvSOTf3slM8dWIPctf/DEPqzoVSEJL/FQmFSMUX9TlKAWaxhbyAIcONFZqoea3w== X-Received: by 2002:aca:578b:: with SMTP id l133-v6mr276467oib.329.1532377203321; Mon, 23 Jul 2018 13:20:03 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id d191-v6sm11786532oig.16.2018.07.23.13.20.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:20:02 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:16:53 -0500 Message-Id: <20180723201748.25573-45-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::230 Subject: [Qemu-devel] [PATCH 44/99] i386: define the AMD 'virt-ssbd' CPUID feature bit (CVE-2018-3639) 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: qemu-stable@nongnu.org, Eduardo Habkost , Konrad Rzeszutek Wilk Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Konrad Rzeszutek Wilk AMD Zen expose the Intel equivalant to Speculative Store Bypass Disable via the 0x80000008_EBX[25] CPUID feature bit. This needs to be exposed to guest OS to allow them to protect against CVE-2018-3639. Signed-off-by: Konrad Rzeszutek Wilk Reviewed-by: Daniel P. Berrangé Signed-off-by: Daniel P. Berrangé Message-Id: <20180521215424.13520-3-berrange@redhat.com> Signed-off-by: Eduardo Habkost (cherry picked from commit 403503b162ffc33fb64cfefdf7b880acf41772cd) Signed-off-by: Michael Roth --- target/i386/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 2f5263e22f..2e305ab689 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -541,7 +541,7 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = { "ibpb", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, + NULL, "virt-ssbd", NULL, NULL, NULL, NULL, NULL, NULL, }, .cpuid_eax = 0x80000008, From patchwork Mon Jul 23 20:16:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948026 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ln+E0vP/"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZDGX5kRBz9s3Z for ; Tue, 24 Jul 2018 06:53:08 +1000 (AEST) Received: from localhost ([::1]:36535 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhpK-00058B-DZ for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 16:53:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41851) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhJS-0002d2-GT for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhJO-0004Mf-RV for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:10 -0400 Received: from mail-oi0-x242.google.com ([2607:f8b0:4003:c06::242]:36723) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhJO-0004M3-MA; Mon, 23 Jul 2018 16:20:06 -0400 Received: by mail-oi0-x242.google.com with SMTP id n21-v6so3493205oig.3; Mon, 23 Jul 2018 13:20:06 -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=oFetfdEOU0uKduTpnbpl0Jkjyaf3a5ZwXgwo2CKFotE=; b=ln+E0vP/YCdfFdbNpFXpZwhwymXuPoCih14hMdCw5bNrwdhpUtrxcYbnheXJiI4gn6 awZchvPeNHjFCltnkSQo1uC1PRclMAdwFjFHvtD1vrdwV8DMAwVfNH514OtWTmwfxGwJ 1epUkDom4mX2UEbzrckoJUt7zABYybb8pgw7xNfNWJw5WnIHeu8BZGpqOR4Sclr4Z0C4 izWXyfcA6yGKDjpNHT9fF1D0zGuuJEx3Dd/ilpKhgK6hJwX9ZF688Zddrsk+AKo7W+Bc Rif5g45+kerlJrActRLYtOJ4knv/cZt6pra+EvOEgzS+5qx3Wh50BKzOAyszcOEBDJP8 fF+w== 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=oFetfdEOU0uKduTpnbpl0Jkjyaf3a5ZwXgwo2CKFotE=; b=so3PmpHttgQXgNUgxXAZRt36Vymu81C7US1c/AC9h4PhaZZyrsJmXkkMHlCqyzW+Xf JyxQIJlJDpfdhByf+fL+I7S/5LTZdaLcuSpz1SWJFzSX/uqr5RpzcgyQWlF/ELCIBTNi 2Cd7gfSwMecrgxa6jYqZvGyx+jF5Pqb3bN2Cg+DDowatMxCjsWNkZcHPbnlx1stuMhkP 2kMpZHFZVOv5w/YZDOB5Lhw0w4ieLjnWSE3gKbLI95n5gMgm+o7iawGfVjFCklGji1zM VH2h/QCiuD6omO/ZyIcmSmxUFmDDcMeQzkT404lHMygGofSfIdGap04awTf+r0b3m+Xs V6Mg== X-Gm-Message-State: AOUpUlHlpZDqjIYr9TQ874kPC+X91JZz0MEeakqyIZrrbN3ALwRuvoSr JKWr0mx7dWj0Az500u0Od5pBWPsdfJ4= X-Google-Smtp-Source: AAOMgpdYBosOvo0luNCXyya73/W4PVlKePRnkG9syWPICQbeAaiy8RGvly0T7I/BFmE3eQm18gIWOQ== X-Received: by 2002:aca:d4d7:: with SMTP id l206-v6mr317891oig.52.1532377205600; Mon, 23 Jul 2018 13:20:05 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id v202-v6sm9028501oie.47.2018.07.23.13.20.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:20:04 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:16:54 -0500 Message-Id: <20180723201748.25573-46-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::242 Subject: [Qemu-devel] [PATCH 45/99] tap: set vhostfd passed from qemu cli to non-blocking 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: Jason Wang , Brijesh Singh , qemu-stable@nongnu.org, "Michael S . Tsirkin" Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Brijesh Singh A guest boot hangs while probing the network interface when iommu_platform=on is used. The following qemu cli hangs without this patch: # $QEMU \ -netdev tap,fd=3,id=hostnet0,vhost=on,vhostfd=4 3<>/dev/tap67 4<>/dev/host-net \ -device virtio-net-pci,netdev=hostnet0,id=net0,iommu_platform=on,disable-legacy=on \ ... Commit: c471ad0e9bd46 (vhost_net: device IOTLB support) took care of setting vhostfd to non-blocking when QEMU opens /dev/host-net but if the fd is passed from qemu cli then we need to ensure that fd is set to non-blocking. Fixes: c471ad0e9bd46 ("vhost_net: device IOTLB support") Cc: qemu-stable@nongnu.org Cc: Michael S. Tsirkin Cc: Jason Wang Signed-off-by: Brijesh Singh Signed-off-by: Jason Wang (cherry picked from commit d542800d1edc62f63f8a29cfa6bdd1a9536ae11c) Signed-off-by: Michael Roth --- net/tap.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/tap.c b/net/tap.c index 2b3a36f9b5..89c4e19162 100644 --- a/net/tap.c +++ b/net/tap.c @@ -40,6 +40,7 @@ #include "qemu-common.h" #include "qemu/cutils.h" #include "qemu/error-report.h" +#include "qemu/sockets.h" #include "net/tap.h" @@ -693,6 +694,7 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer, } return; } + qemu_set_nonblock(vhostfd); } else { vhostfd = open("/dev/vhost-net", O_RDWR); if (vhostfd < 0) { From patchwork Mon Jul 23 20:16:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948032 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="HM4+p+/6"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZDNW3DCtz9ryn for ; Tue, 24 Jul 2018 06:58:19 +1000 (AEST) Received: from localhost ([::1]:36566 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhuL-0001Gt-3G for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 16:58:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41855) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhJS-0002d7-J9 for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhJR-0004Q9-5K for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:10 -0400 Received: from mail-oi0-x232.google.com ([2607:f8b0:4003:c06::232]:43123) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhJQ-0004Pl-VJ; Mon, 23 Jul 2018 16:20:09 -0400 Received: by mail-oi0-x232.google.com with SMTP id b15-v6so3463936oib.10; Mon, 23 Jul 2018 13:20:08 -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=tsbcI48Kf1Rydg5LkaqGpCpV2o8JVbjZE0kuCXx4IIs=; b=HM4+p+/6HHbajWWtalla/fr2EwQC2dKbhUb+tQVNLXIeyjRYv83GWg+PPfARcMRolm Meg/xKmivoYcUs3ZnJUAHv3nLIcvhZD6BnTT02VP7EaTAgV0WdlZzdnS24IoHS9BiJUi EtOkcT5cbcD9OnWq05KeLvaA+FQARN81zHAC0ODoXoavfJpEP8JiBtbSJAzySjt7WEtn f6ct6269CEP5L4DFF1R9G2FD+ZZDnSI5gUW5k77WHb44nf5ONgalwRgU7Sx+f1SPUi4e Em38sqCbDXWkiE36lw0hTlOWk1pbkN6wNEaaM3UdIfC1jIZovNA0LRY9fMp3Xpd50k4r vCAQ== 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=tsbcI48Kf1Rydg5LkaqGpCpV2o8JVbjZE0kuCXx4IIs=; b=d4Fg8qtWSiD2iv7hyrnlaVtQEickyXnhMp6K9n08r8/xrf9SuFV8Tuj5feEurOln7A g7DOtESOwMyyjNClgqzA/hj4x5lofdT4L6DwRtoiaYKDvsXQYUjIrEBf48T17HWDMdQ4 CneXzUN+KmIoux9PBn65hn5mMu81Dr8yfbCCV+ynlEJAyoYUanieIRzDtzCObcEh4yW/ ZJsbnLTBnQXdUIgQhRUGIt24PzrRPVeMh3x9bTT4Q5dDjrilu1ObAJ8m1eMKEdfx0hZc bKAY2UK8tbbJYNKNvfwBpzR1PAHoPjFp7jOHl+gmO6U2GeEzfAGYn99zuLu87foPtu8P xmFg== X-Gm-Message-State: AOUpUlGvzl/bIDREi40I2ZO0MWo+T7hyo7du1FmUBiPEd+NNCSdeMPB8 o/eOffqI2gXVqNmOvo61r00NLpC+nO4= X-Google-Smtp-Source: AAOMgpdi5OkNDvs1NRD1PjRmVMzNKy3lWdJ4HUWWNxg6Tzy6qxqmMbpW7qCGpM0+E+Vbz0Lld+FytQ== X-Received: by 2002:aca:7517:: with SMTP id q23-v6mr280391oic.352.1532377207836; Mon, 23 Jul 2018 13:20:07 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id q124-v6sm7912273oif.8.2018.07.23.13.20.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:20:06 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:16:55 -0500 Message-Id: <20180723201748.25573-47-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::232 Subject: [Qemu-devel] [PATCH 46/99] vhost-user: delete net client if necessary 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: linzhecheng , Jason Wang , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: linzhecheng As qemu_new_net_client create new ncs but error happens later, ncs will be left in global net_clients list and we can't use them any more, so we need to cleanup them. Cc: qemu-stable@nongnu.org Signed-off-by: linzhecheng Signed-off-by: Jason Wang (cherry picked from commit c67daf4a24442d1bb404a11a6a54dc45ea10f234) Conflicts: net/vhost-user.c * drop functional dep on 4d0cf552 Signed-off-by: Michael Roth --- net/vhost-user.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/net/vhost-user.c b/net/vhost-user.c index e0f16c895b..62745c06dd 100644 --- a/net/vhost-user.c +++ b/net/vhost-user.c @@ -299,7 +299,7 @@ static int net_vhost_user_init(NetClientState *peer, const char *device, s = DO_UPCAST(VhostUserState, nc, nc); if (!qemu_chr_fe_init(&s->chr, chr, &err)) { error_report_err(err); - return -1; + goto err; } } @@ -309,7 +309,7 @@ static int net_vhost_user_init(NetClientState *peer, const char *device, do { if (qemu_chr_fe_wait_connected(&s->chr, &err) < 0) { error_report_err(err); - return -1; + goto err; } qemu_chr_fe_set_handlers(&s->chr, NULL, NULL, net_vhost_user_event, NULL, nc0->name, NULL, @@ -319,6 +319,13 @@ static int net_vhost_user_init(NetClientState *peer, const char *device, assert(s->vhost_net); return 0; + +err: + if (nc0) { + qemu_del_net_client(nc0); + } + + return -1; } static Chardev *net_vhost_claim_chardev( From patchwork Mon Jul 23 20:16:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948029 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="WAljWmdD"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZDKl1GvKz9ryn for ; Tue, 24 Jul 2018 06:55:55 +1000 (AEST) Received: from localhost ([::1]:36557 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhs0-0007jj-JO for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 16:55:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41895) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhJU-0002g6-8V for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhJT-0004SH-8i for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:12 -0400 Received: from mail-oi0-x243.google.com ([2607:f8b0:4003:c06::243]:46631) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhJT-0004S3-2t; Mon, 23 Jul 2018 16:20:11 -0400 Received: by mail-oi0-x243.google.com with SMTP id y207-v6so3457122oie.13; Mon, 23 Jul 2018 13:20:11 -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=Tu8r4wisGpHHAloiCJc+Q0opauUgffx/w08W9MSO9Qw=; b=WAljWmdDK8hvGLARJHffllJXoZp+4SbHveon9IRuMJEIieWmbE/v+mPmgzaFtBVtoX PdTBzo1kq17OQcY2vxoVkRnmpUEcuALj1Bgacp2gBJFE8oH8ORCW7jj6eZI39Uy1jD4o RGrbJYI3ROPzC1IwpupR++rntB56uBzxMpVoB7mSHCRi7NswORdTrziYVpEVEP9SOb+T Cru0zFbQxWmEi6K3H1Uzc/n+1D5quacgw4uK/6ocbkZkFL/lxlUsE8mBTqRN5dkMPu4p wIJbEeYbZ5XjsHWd/UnZDzSefuNZHygfDR/o00QSbRB+SGwqUlOaEgdBWx6eJ6qRWHbj Bc9w== 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=Tu8r4wisGpHHAloiCJc+Q0opauUgffx/w08W9MSO9Qw=; b=k0CEQSI5NhpU8UPSTW0DY+bTiOhgJ4xHkN5nO7FYkFh/rWFZNEDznLzsq/Yrsjdpn1 JVaCZtmqeRUoK1wEuOE4sqKmikAD2TU6DjOCGiGB5HlmSJGUATADuG9s3jHiDpO9/L2I oSQWYlSg0gCsnvjmIbLabSX43WOdVIsmKO8IcmRrCrdJRlIcYjQGLqUJYxmgsum1M6oI RpbA0Le34lTbfAhSFURjzATKRznp2rkf7EtBn6zZfY8JHiAaSjN0N+cGdHIUPBFgTYVn LXLlxXsCVR2iAGgtfLtp64JZpC4xkcVl/nyx6Jx455OnQeyMi+Fbu374XkhE0kBQRbSY EkOg== X-Gm-Message-State: AOUpUlFrsAWQ7qDVYWe4mWHibGw+NLkysrw1zdRfZ6OfD2gM+oIGlqI5 jZeISz91oJOp1Z3v4+wIjQ1RDng9mJg= X-Google-Smtp-Source: AAOMgpf9SLaM/BM+yFCFgIpPUCs/Sdf8XLPlR0uNtfDMPRxdrVwth2cX8BGKQTVmljhxsJJtfCBFsA== X-Received: by 2002:aca:400b:: with SMTP id n11-v6mr306331oia.150.1532377209867; Mon, 23 Jul 2018 13:20:09 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id m62-v6sm26385502oik.30.2018.07.23.13.20.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:20:08 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:16:56 -0500 Message-Id: <20180723201748.25573-48-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::243 Subject: [Qemu-devel] [PATCH 47/99] qemu-img: Fix assert when mapping unaligned raw file 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: Kevin Wolf , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Eric Blake Commit a290f085 exposed a latent bug in qemu-img map introduced during the conversion of block status to be byte-based. Earlier in commit 5e344dd8, the internal interface get_block_status() switched to take byte-based parameters, but still called a sector-based block layer function; as such, rounding was added in the lone caller to obey the contract. However, commit 237d78f8 changed get_block_status() to truly be byte-based, at which point rounding to sector boundaries can result in calling bdrv_block_status() with 'bytes == 0' (a coding error) when the boundary between data and a hole falls mid-sector (true for the past-EOF implicit hole present in POSIX files). Fix things by removing the rounding that is now no longer necessary. See also https://bugzilla.redhat.com/1589738 Fixes: 237d78f8 Reported-by: Dan Kenigsberg Reported-by: Nir Soffer Reported-by: Maor Lipchuk CC: qemu-stable@nongnu.org Signed-off-by: Eric Blake Signed-off-by: Kevin Wolf (cherry picked from commit e0b371ed5e2db079051139136fd0478728b6a58f) Signed-off-by: Michael Roth --- qemu-img.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qemu-img.c b/qemu-img.c index b422fda6f3..a8e2b53dc6 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -2827,7 +2827,7 @@ static int img_map(int argc, char **argv) int64_t n; /* Probe up to 1 GiB at a time. */ - n = QEMU_ALIGN_DOWN(MIN(1 << 30, length - offset), BDRV_SECTOR_SIZE); + n = MIN(1 << 30, length - offset); ret = get_block_status(bs, offset, n, &next); if (ret < 0) { From patchwork Mon Jul 23 20:16:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948019 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Zb6aoQOP"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZDBB1s8Yz9ryn for ; Tue, 24 Jul 2018 06:49:22 +1000 (AEST) Received: from localhost ([::1]:36510 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhlf-00023j-S4 for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 16:49:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41949) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhJX-0002jH-46 for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhJV-0004V4-Me for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:15 -0400 Received: from mail-oi0-x22a.google.com ([2607:f8b0:4003:c06::22a]:42531) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhJV-0004U8-E4; Mon, 23 Jul 2018 16:20:13 -0400 Received: by mail-oi0-x22a.google.com with SMTP id n84-v6so3466530oib.9; Mon, 23 Jul 2018 13:20:13 -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=p5kya8yCUzL/d+K3PRMaoVTOi9axYhdgFIYDALsksuY=; b=Zb6aoQOPKvhk3S7vAwUrwmh7azuU5aURYR5PwUsOURmQftxbK8dl+0gLz35BXyNvmk XfzUaRT8ZXh3cH2AhSxVpf5n6ruDJVF33i6tN6bWAtKhZBxwWtjIk7aDViuiG18E4zhG a93C2NtnYz8OjjuBCgEIvXy7lCX+Vi7srNMzpMgURHi05jwROqzQQjU5xl0eMjOsOZRR 1U3r/2hLWEVt5mcj3iEmr2+jSbk2e3WuO52BWjTfK6y/HILVRxhVwCJPm/wpfr5hr4Ue Q8sPQ1tw077ewPJwxWhGRBQfCdLK9NiRW7gkPDxqwUTx2BhiJ3dViZ/wakT/o5vQQNMl 06Qg== 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=p5kya8yCUzL/d+K3PRMaoVTOi9axYhdgFIYDALsksuY=; b=n+KWtUvJcksrVwy5bk8u61bQYPa3JjWGgx4qEeHjZA22bjnFisZqG8CocFPLjZvN+U J87SV51Yp6cSaEWaN4KvelBxZxpMgY1eE1J6t42q1/VWSXZxmNuksC68IboYiIdnhSZT R83L6wWXYrkT45/JnzszHjjmysuzS6If9tsPTInBEoaoYELjE0Fp890dpL9g+8O0oWvF VvFlafxyYACvB9fVfy9p+4Rn/758JNJMb5IupRA7n4BDInS5uxbWjBIVOZE7BzFWfl86 I3nDp0ruIT4WDrkvAQWYrzxtYPpJgl2ZgrErObeGRKWuogKm935uSO0v39ugtUY+Old4 e62Q== X-Gm-Message-State: AOUpUlGrj9adfPJjFKLkZb/yeIyr6t+JTYCqeDCrqVlI7Ms/J6sOnlM4 lJtQeWO4u6g75URLslskyp78DAwOsJI= X-Google-Smtp-Source: AAOMgpf6cyorfhX4tbtvcQ8j6Fj538Xt5GeTX1WhigwQCIuFV8Rq6EnU8/sbyVI6m5t1me82y3MFOQ== X-Received: by 2002:aca:171a:: with SMTP id j26-v6mr279490oii.277.1532377212170; Mon, 23 Jul 2018 13:20:12 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id r10-v6sm7204365oif.37.2018.07.23.13.20.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:20:11 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:16:57 -0500 Message-Id: <20180723201748.25573-49-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::22a Subject: [Qemu-devel] [PATCH 48/99] iotests: Add test 221 to catch qemu-img map regression 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: Kevin Wolf , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Eric Blake Although qemu-img creates aligned files (by rounding up), it must also gracefully handle files that are not sector-aligned. Test that the bug fixed in the previous patch does not recur. It's a bit annoying that we can see the (implicit) hole past the end of the file on to the next sector boundary, so if we ever reach the point where we report a byte-accurate size rather than our current behavior of always rounding up, this test will probably need a slight modification. Signed-off-by: Eric Blake Signed-off-by: Kevin Wolf (cherry picked from commit c6a9d2f6f9bc0c163b3a3073126464a2446bad5f) Conflicts: tests/qemu-iotests/group * drop context dep on tests not present in 2.12 Signed-off-by: Michael Roth --- tests/qemu-iotests/221 | 60 ++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/221.out | 16 ++++++++++ tests/qemu-iotests/group | 1 + 3 files changed, 77 insertions(+) create mode 100755 tests/qemu-iotests/221 create mode 100644 tests/qemu-iotests/221.out diff --git a/tests/qemu-iotests/221 b/tests/qemu-iotests/221 new file mode 100755 index 0000000000..41c4e4bdf8 --- /dev/null +++ b/tests/qemu-iotests/221 @@ -0,0 +1,60 @@ +#!/bin/bash +# +# Test qemu-img vs. unaligned images +# +# Copyright (C) 2018 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +seq="$(basename $0)" +echo "QA output created by $seq" + +here="$PWD" +status=1 # failure is the default! + +_cleanup() +{ + _cleanup_test_img +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter + +_supported_fmt raw +_supported_proto file +_supported_os Linux + +echo +echo "=== Check mapping of unaligned raw image ===" +echo + +_make_test_img 43009 # qemu-img create rounds size up +$QEMU_IMG map --output=json "$TEST_IMG" | _filter_qemu_img_map + +truncate --size=43009 "$TEST_IMG" # so we resize it and check again +$QEMU_IMG map --output=json "$TEST_IMG" | _filter_qemu_img_map + +$QEMU_IO -c 'w 43008 1' "$TEST_IMG" | _filter_qemu_io # writing also rounds up +$QEMU_IMG map --output=json "$TEST_IMG" | _filter_qemu_img_map + +truncate --size=43009 "$TEST_IMG" # so we resize it and check again +$QEMU_IMG map --output=json "$TEST_IMG" | _filter_qemu_img_map + +# success, all done +echo '*** done' +rm -f $seq.full +status=0 diff --git a/tests/qemu-iotests/221.out b/tests/qemu-iotests/221.out new file mode 100644 index 0000000000..a9c0190aad --- /dev/null +++ b/tests/qemu-iotests/221.out @@ -0,0 +1,16 @@ +QA output created by 221 + +=== Check mapping of unaligned raw image === + +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=43009 +[{ "start": 0, "length": 43520, "depth": 0, "zero": true, "data": false, "offset": OFFSET}] +[{ "start": 0, "length": 43520, "depth": 0, "zero": true, "data": false, "offset": OFFSET}] +wrote 1/1 bytes at offset 43008 +1 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +[{ "start": 0, "length": 40960, "depth": 0, "zero": true, "data": false, "offset": OFFSET}, +{ "start": 40960, "length": 2049, "depth": 0, "zero": false, "data": true, "offset": OFFSET}, +{ "start": 43009, "length": 511, "depth": 0, "zero": true, "data": false, "offset": OFFSET}] +[{ "start": 0, "length": 40960, "depth": 0, "zero": true, "data": false, "offset": OFFSET}, +{ "start": 40960, "length": 2049, "depth": 0, "zero": false, "data": true, "offset": OFFSET}, +{ "start": 43009, "length": 511, "depth": 0, "zero": true, "data": false, "offset": OFFSET}] +*** done diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index 52a80f3f9e..fc10a72192 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -212,3 +212,4 @@ 211 rw auto quick 212 rw auto quick 213 rw auto quick +221 rw auto quick From patchwork Mon Jul 23 20:16:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948024 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="jj3FGeng"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZDFb1VDbz9ryn for ; Tue, 24 Jul 2018 06:52:19 +1000 (AEST) Received: from localhost ([::1]:36530 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhoW-0004UO-SY for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 16:52:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42006) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhJa-0002nP-I9 for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhJX-0004a5-V4 for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:18 -0400 Received: from mail-oi0-x236.google.com ([2607:f8b0:4003:c06::236]:38211) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhJX-0004YK-Hr; Mon, 23 Jul 2018 16:20:15 -0400 Received: by mail-oi0-x236.google.com with SMTP id v8-v6so3479099oie.5; Mon, 23 Jul 2018 13:20:15 -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=ruUlhOHSjmk6vIvU6TnBO/dR9LR2hmjWRxSNwnk8CnE=; b=jj3FGeng1oudZDTaqMB+2A+EzRPaTcVIDmsSAdXyJ7T/ZRWYS6Zb+CTDxh4ybHzIlx SHKCu9TF8nOD3FtxxkE9QmrSdUyJswb4Ff34JbgmGmIzWoFx6v5tQU0KSwGQYfz8EF6P Bi6JtBgt6H4YztrdJSvlPVxeEbjwdx4uO6MosMusceTHS9QDGwjIkuWjAEbDmn6IS/1e /D2CbptpXDjlsdHI4ugENI8UPEfk3x5TtuTRLvWx7s9qXIVgwqSwPPb/mrbgfn/jaHNP z/zk7ahXtjrP+ynAIt/dgKH0LC9ecBifRCLnRktR8WIumYCboO3mREJYfWhEY4CiDr0z DVMQ== 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=ruUlhOHSjmk6vIvU6TnBO/dR9LR2hmjWRxSNwnk8CnE=; b=HH/IsdZYd1AZRrpkNzOUb9Gcskyri2/HgrmQWtld73YXxdOEfNOtZqF/ZQB7t9fsqy JDzYdRLZb26+WwjFbvNiP3lQe80laxlmDk1s0evQCk3r/fEpNp1HqlmgQuNrwBUkRMC1 Z6jxSx+adAxxuwNl87VAaIVD/xDcv+S4LnbSGIR0Zhwrxov7MBfYh0sdYobxS8NJ179l 2N8GrPZEeyPqmVKyuuRFtZCqaScD4g79o7NoWqJSw7BoaPv2FuB2g5xif5FkY4kpUf6T z5QQfZY00eLZTWQ/+hNLRXoST4reYwJl/mjm5cps7TAMw08n0dccg8HFGiufrtcXyCB4 Q73Q== X-Gm-Message-State: AOUpUlEFvQ9iHyjDYNfHYaQPw/5z3oLKp1t7AGL+Axqz7ovgo9a9cPy+ G+JZALOsnjAYdIUxK1hMe3laDbE88Uw= X-Google-Smtp-Source: AAOMgpeYpPIjtYKloULauCXUADK2X50p2iKd+tjHNJujzK0QgYeHQU5NaRauSIaQ5D0aZDUbe9jc6A== X-Received: by 2002:aca:a12:: with SMTP id 18-v6mr289552oik.292.1532377214388; Mon, 23 Jul 2018 13:20:14 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id i3-v6sm8783514oiy.12.2018.07.23.13.20.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:20:13 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:16:58 -0500 Message-Id: <20180723201748.25573-50-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::236 Subject: [Qemu-devel] [PATCH 49/99] arm_gicv3_kvm: kvm_dist_get/put_priority: skip the registers banked by GICR_IPRIORITYR 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: Peter Maydell , qemu-stable@nongnu.org, Shannon Zhao Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Shannon Zhao While for_each_dist_irq_reg loop starts from GIC_INTERNAL, it forgot to offset the date array and index. This will overlap the GICR registers value and leave the last GIC_INTERNAL irq's registers out of update. Fixes: 367b9f527becdd20ddf116e17a3c0c2bbc486920 Cc: qemu-stable@nongnu.org Reviewed-by: Peter Maydell Reviewed-by: Eric Auger Signed-off-by: Shannon Zhao Signed-off-by: Peter Maydell (cherry picked from commit 1dcf3675196a1cec616ce71b067d9498590a60a6) Signed-off-by: Michael Roth --- hw/intc/arm_gicv3_kvm.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c index 81cbd16817..bc6fa415b2 100644 --- a/hw/intc/arm_gicv3_kvm.c +++ b/hw/intc/arm_gicv3_kvm.c @@ -135,7 +135,14 @@ static void kvm_dist_get_priority(GICv3State *s, uint32_t offset, uint8_t *bmp) uint32_t reg, *field; int irq; - field = (uint32_t *)bmp; + /* For the KVM GICv3, affinity routing is always enabled, and the first 8 + * GICD_IPRIORITYR registers are always RAZ/WI. The corresponding + * functionality is replaced by GICR_IPRIORITYR. It doesn't need to + * sync them. So it needs to skip the field of GIC_INTERNAL irqs in bmp and + * offset. + */ + field = (uint32_t *)(bmp + GIC_INTERNAL); + offset += (GIC_INTERNAL * 8) / 8; for_each_dist_irq_reg(irq, s->num_irq, 8) { kvm_gicd_access(s, offset, ®, false); *field = reg; @@ -149,7 +156,14 @@ static void kvm_dist_put_priority(GICv3State *s, uint32_t offset, uint8_t *bmp) uint32_t reg, *field; int irq; - field = (uint32_t *)bmp; + /* For the KVM GICv3, affinity routing is always enabled, and the first 8 + * GICD_IPRIORITYR registers are always RAZ/WI. The corresponding + * functionality is replaced by GICR_IPRIORITYR. It doesn't need to + * sync them. So it needs to skip the field of GIC_INTERNAL irqs in bmp and + * offset. + */ + field = (uint32_t *)(bmp + GIC_INTERNAL); + offset += (GIC_INTERNAL * 8) / 8; for_each_dist_irq_reg(irq, s->num_irq, 8) { reg = *field; kvm_gicd_access(s, offset, ®, true); From patchwork Mon Jul 23 20:16:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948036 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="dij2mt0l"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZDRt52yfz9ryn for ; Tue, 24 Jul 2018 07:01:14 +1000 (AEST) Received: from localhost ([::1]:36592 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhx9-0003xq-9U for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 17:01:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42013) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhJb-0002oB-CR for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhJZ-0004cj-Vf for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:18 -0400 Received: from mail-oi0-x242.google.com ([2607:f8b0:4003:c06::242]:38987) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhJZ-0004br-Fs; Mon, 23 Jul 2018 16:20:17 -0400 Received: by mail-oi0-x242.google.com with SMTP id d189-v6so3481800oib.6; Mon, 23 Jul 2018 13:20:17 -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=ULEYDd03Iqz//9xbBei+cgWESGqVvyhuWWzmfuiHCVU=; b=dij2mt0lfJsXeZm6c7aUcTHNjYJNFcZjcgCln+hlXkDJcNenggb6HVJSdoO03eoD/e GbJ6+YtDQkrD0tuz2VnFT9zSp8Nc685hkLIGevIzeW7eH2sQ3S9Wsp4ShXrzbHKSHQJr OIcWM2sVjEcJilPoJeYmRIsBE/GtrQA3hSXRU+V3yFWm2QeVc6y1aAlYe8S317hQXhxv bShADbrlJuNP5ShYB/TFFeukiPyUrN45dY3lVjcw2HLG4DQJ9dBCIUYK0nDJ7ipFqWyt CAVTbtjwHjmOExSvsqMvNE4nwFb20SDEVc/Qt7KZOkex8ks8lQ9uzhZ5D8lo8m9ymAMM QOog== 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=ULEYDd03Iqz//9xbBei+cgWESGqVvyhuWWzmfuiHCVU=; b=LUA8UnL93HA9eJCMh6LjmOtOOfxSAtmnFf32e5Gd9tAzy1sN4za4cy4VlcWsFfLiKr A+Gty6neCKLv99KYk4Hht2GuuZUkH9idkpS4NIbC/hyHej4fqJQ3cqik43TwuXghi8RJ PFQjW5eS7KCamsZ53CmeNE/8eLTJ2kslm5A8IIWFYX7g6Ytos/ReSl2nB4Z5XrZ5Gxnv vxk3jPlm8g60iHecfEiJjdzbq2n/dGrnVIuRlFWJHXWcwCHQlnYbl0t/u+1tEt4+uMS3 anrXiCzwBJXYWmXmnC4dbtA0vGalxBtpFCyRbZEb/6fFgowQXc/jm/nAOCVX8Go0lc1p Bpnw== X-Gm-Message-State: AOUpUlFyiouQPUAYWylYpavXoBOPuXWCI/dRNtZ1J1nBPya9yuUu/xaN +1lnQto7PH/wfPITPMUckao4OjHe6ok= X-Google-Smtp-Source: AAOMgpfHZPBTDCqtQJffJ17MnanMlwUX0P1wWEsa2zUuJzzdHfGkdkV3Wgq50w0ZkxHlFhA2sFrzvg== X-Received: by 2002:aca:4cd2:: with SMTP id z201-v6mr314896oia.318.1532377216265; Mon, 23 Jul 2018 13:20:16 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id 10-v6sm6887109oip.29.2018.07.23.13.20.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:20:15 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:16:59 -0500 Message-Id: <20180723201748.25573-51-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::242 Subject: [Qemu-devel] [PATCH 50/99] usb: correctly handle Zero Length Packets 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: Gerd Hoffmann , qemu-stable@nongnu.org, =?utf-8?q?P?= =?utf-8?q?hilippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé USB Specification Revision 2.0, §5.5.3: The Data stage of a control transfer from an endpoint to the host is complete when the endpoint does one of the following: • Has transferred exactly the amount of data specified during the Setup stage • Transfers a packet with a payload size less than wMaxPacketSize or transfers a zero-length packet" hw/usb/redirect.c:802:9: warning: Declared variable-length array (VLA) has zero size uint8_t buf[size]; ^~~~~~~~~~~ ~~~~ Reported-by: Clang Static Analyzer Signed-off-by: Philippe Mathieu-Daudé Message-id: 20180604151421.23385-2-f4bug@amsat.org Signed-off-by: Gerd Hoffmann (cherry picked from commit bf78fb1c1b61a819a47f7a1dbecf9934b9f32a0d) Signed-off-by: Michael Roth --- hw/usb/redirect.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c index 65a9196c1a..58e8f7f5bd 100644 --- a/hw/usb/redirect.c +++ b/hw/usb/redirect.c @@ -795,7 +795,7 @@ static void usbredir_handle_bulk_data(USBRedirDevice *dev, USBPacket *p, usbredirparser_peer_has_cap(dev->parser, usb_redir_cap_32bits_bulk_length)); - if (ep & USB_DIR_IN) { + if (ep & USB_DIR_IN || size == 0) { usbredirparser_send_bulk_packet(dev->parser, p->id, &bulk_packet, NULL, 0); } else { From patchwork Mon Jul 23 20:17:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948039 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="fYxoK2nL"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZDTv1pbvz9ryn for ; Tue, 24 Jul 2018 07:02:59 +1000 (AEST) Received: from localhost ([::1]:36605 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhyq-0005O3-Qe for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 17:02:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42088) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhJf-0002tH-GO for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhJe-0004g8-Cw for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:23 -0400 Received: from mail-oi0-x244.google.com ([2607:f8b0:4003:c06::244]:38117) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhJd-0004fm-U5; Mon, 23 Jul 2018 16:20:22 -0400 Received: by mail-oi0-x244.google.com with SMTP id v8-v6so3479693oie.5; Mon, 23 Jul 2018 13:20:21 -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=7x67H7eAhqWAh/LarvuZ2h8gIlqziD8gqtE10KXQacA=; b=fYxoK2nLO/xLTb9w6JgeciQo/NSI1lBpi9m3DZVqDpCP2xp/mPYJkfti1EJlGxjU2/ H7roYDGD+rxdPwuhgJz2pa1HKragfZvnf/M2Mxw4mivo38cBQ2AIskYVoVOo0G1hyjos CyyQSv8dxrhvVt4E7+op32wrnsgiH6yijUowXjWAIsIxzw0XUZGenIfk4+D98z8JrTJj SjHgM2T5j4rXfeEp0nJ/IFOB5VqgzHTLx5JsjUQxixEvKBQBwgT7uQr5G60M/g3OYrlJ 2TQ9jJTJSpMvFClj823xMTU0pdvvWv7bucyDG1oBqAW2y8qxZ6ZAPCLj/0j3atfdibt/ Nz3g== 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=7x67H7eAhqWAh/LarvuZ2h8gIlqziD8gqtE10KXQacA=; b=NKdNC1x2lcUSxTkhgzTopXNlGKeu71v3nfre1K9Byq0DDVOHaxQub3XX4ONyJKdPZU t05cPoKTflwELwCYC7T35E3ulAwfRdcQ58cgQo923yrChA+A3Dnngay96YSYyphRu+6X VxJ7N6lqGiDnKUIFaTQG5/r7UEmxOI96GjDFX63Haqg7u6nXvRkECt49uBmdObLmSjDu 2xrSdXOrQIDSiIsLigp2VgWGTsb0LsbH6g8KTkQNox/wVGKLHOSSxbtux+3SXGQa0HSF kA4vx2By6dv0pyzM0/3ygsolqmTaW4i8XpomhzVlV5v05AuBF5hLFXusutzqCuLxKbSO vJrg== X-Gm-Message-State: AOUpUlGstbR4pxnqvI6rRKq7pAx4z+II/+i8Rn0Y/czOhUL3rbrE1fHH YzER19Mztylrw67YW7vGrva1JW8jM4A= X-Google-Smtp-Source: AAOMgpd5isNC6H0jH1ja78cM1R+OuavqFrVhXiVXmtBzA8hLNYAXDvwiVt1xfsST5P9vPUP10WvpgQ== X-Received: by 2002:aca:b256:: with SMTP id b83-v6mr289574oif.235.1532377220725; Mon, 23 Jul 2018 13:20:20 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id e204-v6sm2757327oif.21.2018.07.23.13.20.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:20:19 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:17:00 -0500 Message-Id: <20180723201748.25573-52-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::244 Subject: [Qemu-devel] [PATCH 51/99] usb/dev-mtp: Fix use of uninitialized values 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: Gerd Hoffmann , qemu-stable@nongnu.org, =?utf-8?q?P?= =?utf-8?q?hilippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé This fixes: hw/usb/dev-mtp.c:971:5: warning: 4th function call argument is an uninitialized value trace_usb_mtp_op_get_partial_object(s->dev.addr, o->handle, o->path, c->argv[1], c->argv[2]); ^~~~~~~~~~ and: hw/usb/dev-mtp.c:981:12: warning: Assigned value is garbage or undefined offset = c->argv[1]; ^ ~~~~~~~~~~ Reported-by: Clang Static Analyzer Signed-off-by: Philippe Mathieu-Daudé Message-id: 20180604151421.23385-3-f4bug@amsat.org Signed-off-by: Gerd Hoffmann (cherry picked from commit 62713a2e50f653162387451034f1a2490e87be88) Signed-off-by: Michael Roth --- hw/usb/dev-mtp.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c index 6ecf70a79b..c50d0bc15e 100644 --- a/hw/usb/dev-mtp.c +++ b/hw/usb/dev-mtp.c @@ -1017,12 +1017,16 @@ static MTPData *usb_mtp_get_object(MTPState *s, MTPControl *c, static MTPData *usb_mtp_get_partial_object(MTPState *s, MTPControl *c, MTPObject *o) { - MTPData *d = usb_mtp_data_alloc(c); + MTPData *d; off_t offset; + if (c->argc <= 2) { + return NULL; + } trace_usb_mtp_op_get_partial_object(s->dev.addr, o->handle, o->path, c->argv[1], c->argv[2]); + d = usb_mtp_data_alloc(c); d->fd = open(o->path, O_RDONLY); if (d->fd == -1) { usb_mtp_data_free(d); From patchwork Mon Jul 23 20:17:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948046 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="iEeEVhSe"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZDb672Wxz9s29 for ; Tue, 24 Jul 2018 07:07:30 +1000 (AEST) Received: from localhost ([::1]:36632 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhi3E-0002wD-J5 for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 17:07:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42148) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhJk-0002we-D5 for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhJh-0004ht-3i for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:28 -0400 Received: from mail-oi0-x233.google.com ([2607:f8b0:4003:c06::233]:39356) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhJg-0004h5-CV; Mon, 23 Jul 2018 16:20:24 -0400 Received: by mail-oi0-x233.google.com with SMTP id d189-v6so3482468oib.6; Mon, 23 Jul 2018 13:20:24 -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=aCrv7zeIBjjc2qT2uEGSz+lqDokwTYED+su3U1iCYzE=; b=iEeEVhSeVu8vb5D/8u8zxPg/qLi4Tg56Et+SdZwti8edWC1G/hpuxTHqokvtm7nmbr gjJaje8Pb68OkkI4PNsD02Syrp9dq0ts96wH8qi9ZBwHbCxa83FQB7eHtd8J6zC0PNEV wf5KNbGyvq7QvLNl57L02bWX+3TGLhGPrQKhsh3brHu9o2qZSnFJTj61atnVXX+aU2/g wItFpD+L3f+69/wkJgRU2TbEN+KX8IpXI/T6wzdnaRKCAcVpL3SaSjK6xrpzzLIMreMR L0jJ3OP6b2tH5iM5TYf636JPtbognYnKLkvxxu4L1kYaJssKgEsBhqX4v/1FzhUOWhzU JW4A== 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=aCrv7zeIBjjc2qT2uEGSz+lqDokwTYED+su3U1iCYzE=; b=U2BrtJUY9bvoQ7pBnioz6K3ClHDxctT3gezvseE5ApkFv+W+tKLASAHC5+uFoOD3FC jB8OSFvMIa5IStOygHgVojHPSuT/lmwnHMKBh3Smb7T+uqwzbuX4yRMugwOEwQGdNm5T 6IShdXjqCecWZ8tWn/X7t7xt8J46renZl9cMBg89iwp2XFu1Si5e06K7uxAqgHmkd0JK glktfayIP4tSpUAXlvko6wa40N+ojG7wg0d7ob5vvMndwbyeolxWexjjH/QMyANM1rfe i1Bb3UJWgioIH0RegZOjwBFpqvW4GLjiCRxgdEW1yRLAU4jRB9OZ72aTEg2ylo7UJ5p/ qrFg== X-Gm-Message-State: AOUpUlGv6H0KTA3ZVOiqVgIW5AxPP4yJuoZrTNsilZKLVZr//zeu6gdX gg9Wa8jLOVL3fux90syUZU+dJaoDnrs= X-Google-Smtp-Source: AAOMgpfJwBY64XHfX3Btag/phUbKbHrKFmQcOjVlEF8oK9l0VhvGkeJg1ky9N0zzp3uZymAB3GLhWw== X-Received: by 2002:aca:856:: with SMTP id 83-v6mr254074oii.333.1532377222997; Mon, 23 Jul 2018 13:20:22 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id s124-v6sm6810178oia.51.2018.07.23.13.20.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:20:21 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:17:01 -0500 Message-Id: <20180723201748.25573-53-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::233 Subject: [Qemu-devel] [PATCH 52/99] vnc: fix use-after-free 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: qemu-stable@nongnu.org, Gerd Hoffmann Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Gerd Hoffmann When vnc_client_read() return value is -1 vs is not valid any more. Fixes: d49b87f0d1e0520443a990fc610d0f02bc63c556 Reported-by: Philippe Mathieu-Daudé Signed-off-by: Gerd Hoffmann Reviewed-by: Marc-André Lureau Reviewed-by: Daniel P. Berrangé Reviewed-by: Philippe Mathieu-Daudé Tested-by: Marc-André Lureau Tested-by: Philippe Mathieu-Daudé Message-id: 20180420084820.3873-1-kraxel@redhat.com (cherry picked from commit 1bc3117abad28d6465ecdb2c944b22943df0e4f3) Signed-off-by: Michael Roth --- ui/vnc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ui/vnc.c b/ui/vnc.c index e164eb798c..5526e54f48 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -1539,13 +1539,14 @@ gboolean vnc_client_io(QIOChannel *ioc G_GNUC_UNUSED, VncState *vs = opaque; if (condition & G_IO_IN) { if (vnc_client_read(vs) < 0) { - goto end; + /* vs is free()ed here */ + return TRUE; } } if (condition & G_IO_OUT) { vnc_client_write(vs); } -end: + if (vs->disconnecting) { if (vs->ioc_tag != 0) { g_source_remove(vs->ioc_tag); From patchwork Mon Jul 23 20:17:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948044 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="EW234pbT"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZDYM5BnKz9ryn for ; Tue, 24 Jul 2018 07:05:58 +1000 (AEST) Received: from localhost ([::1]:36621 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhi1i-0001bi-64 for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 17:05:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42149) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhJk-0002wf-D7 for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhJi-0004ix-Kc for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:28 -0400 Received: from mail-oi0-x22d.google.com ([2607:f8b0:4003:c06::22d]:33578) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhJi-0004id-9R; Mon, 23 Jul 2018 16:20:26 -0400 Received: by mail-oi0-x22d.google.com with SMTP id l10-v6so3502204oii.0; Mon, 23 Jul 2018 13:20:26 -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=2NCI05YrlmA0ejKuml36wSlszTeWhz3k1PhwBumEZuI=; b=EW234pbTvBmSKMMoorCLyQovnVr/cm5d+yu6RRA2vCIGOIeRF2Lg9kxxpOO+MLtkt8 gKs1a++cUsx3wWByAK41KhhVTwB1vQZezY/+oqhwxGy8TxPGD/x2Px0flfRQOg0Amr5g HxvtBuz3z/mcR4iRsDC7sphz08AsCv4qFdFDxPrUDsL8Xcr6OXlNM2+6aYMFqMM5Po2P PkaUI0MOPSY3PYXBOrueU8P3Hb9LVk6AjEnGSWeInaKXsyzdTnOWCt5AE2lhfWH6VKDW HztC6Y81ofafjA4dt1scGm4aJkKv7ensTIiIrhU6oTMFirHcAs7hCHkcdHcSUqeFauYa 3ZPQ== 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=2NCI05YrlmA0ejKuml36wSlszTeWhz3k1PhwBumEZuI=; b=qLJAggoV0JKhpEfTw2Bn+4xBe9D05Zdvs3F9A59WN0lLC0i/j2+UfbHFJuMIKRzXFg YG+rjWOq0Wz7DnyvCC0Q3UUqU3D1KFQdb1YzNjr1bH38fRZm/6gx7uIIr6pwVaAbEtGX RzNiaLNS6ldCFQXIsN/z79FyZWJyq41j6X1knSg1mopB5gbrg5EytKBcnHbLw9OyaD3/ Xe5Jd04cBoEAi0SnRGkE43vOB10xbwx7m9flOU3jxujGhrvxjH6nJ7yMVYBUA2+gdE52 sFV1AOf6uDD/fFR2/PmVguUAjUma6UdrgqsZ422v51IhBJcKtwNHVEb1FPjdelZaMaDp +PTA== X-Gm-Message-State: AOUpUlEo5+DrUOGIwjEks1CklI4ZL9BjzVVjKY70Y/Z/0+7bD9I4mH2s 5lwxkcGTb3DE+jjX2kXVhWEUYDzZ7Po= X-Google-Smtp-Source: AAOMgpe3+51AzWCwQn9MNXJ8qavCJw/zVe6kOd2antnT8dJkVwpEJpSPrcZnW2HglxQ02mDC1EaX+Q== X-Received: by 2002:aca:d5d3:: with SMTP id m202-v6mr283303oig.93.1532377225098; Mon, 23 Jul 2018 13:20:25 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id u18-v6sm6620552oiv.10.2018.07.23.13.20.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:20:24 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:17:02 -0500 Message-Id: <20180723201748.25573-54-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::22d Subject: [Qemu-devel] [PATCH 53/99] block/mirror: honor ratelimit again 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: Kevin Wolf , Liang Li , qemu-stable@nongnu.org, Stefan Hajnoczi , Jeff Cody Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Stefan Hajnoczi Commit b76e4458b1eb3c32e9824fe6aa51f67d2b251748 ("block/mirror: change the semantic of 'force' of block-job-cancel") accidentally removed the ratelimit in the mirror job. Reintroduce the ratelimit but keep the block-job-cancel force=true behavior that was added in commit b76e4458b1eb3c32e9824fe6aa51f67d2b251748. Note that block_job_sleep_ns() returns immediately when the job is cancelled. Therefore it's safe to unconditionally call block_job_sleep_ns() - a cancelled job does not sleep. This commit fixes the non-deterministic qemu-iotests 185 output. The test relies on the ratelimit to make the job sleep until the 'quit' command is processed. Previously the job could complete before the 'quit' command was received since there was no ratelimit. Cc: Liang Li Cc: Jeff Cody Cc: Kevin Wolf Signed-off-by: Stefan Hajnoczi Message-id: 20180424123527.19168-1-stefanha@redhat.com Signed-off-by: Jeff Cody (cherry picked from commit ddc4115efdfa6619689fe18871aa2d37890b3463) Signed-off-by: Michael Roth --- block/mirror.c | 8 +++++--- tests/qemu-iotests/185.out | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/block/mirror.c b/block/mirror.c index 820f512c7b..9436a8d5ee 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -868,12 +868,14 @@ static void coroutine_fn mirror_run(void *opaque) } ret = 0; + + if (s->synced && !should_complete) { + delay_ns = (s->in_flight == 0 && cnt == 0 ? SLICE_TIME : 0); + } trace_mirror_before_sleep(s, cnt, s->synced, delay_ns); + block_job_sleep_ns(&s->common, delay_ns); if (block_job_is_cancelled(&s->common) && s->common.force) { break; - } else if (!should_complete) { - delay_ns = (s->in_flight == 0 && cnt == 0 ? SLICE_TIME : 0); - block_job_sleep_ns(&s->common, delay_ns); } s->last_pause_ns = qemu_clock_get_ns(QEMU_CLOCK_REALTIME); } diff --git a/tests/qemu-iotests/185.out b/tests/qemu-iotests/185.out index 2c4b04de73..992162f418 100644 --- a/tests/qemu-iotests/185.out +++ b/tests/qemu-iotests/185.out @@ -36,9 +36,9 @@ Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 backing_file=TEST_DIR/t.q {"return": {}} Formatting 'TEST_DIR/t.qcow2.copy', fmt=qcow2 size=67108864 cluster_size=65536 lazy_refcounts=off refcount_bits=16 {"return": {}} -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_READY", "data": {"device": "disk", "len": 4194304, "offset": 4194304, "speed": 65536, "type": "mirror"}} {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_READY", "data": {"device": "disk", "len": 4194304, "offset": 4194304, "speed": 65536, "type": "mirror"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "disk", "len": 4194304, "offset": 4194304, "speed": 65536, "type": "mirror"}} === Start backup job and exit qemu === From patchwork Mon Jul 23 20:17:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948031 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="YQTJPmPJ"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZDN42pygz9s3Z for ; Tue, 24 Jul 2018 06:57:56 +1000 (AEST) Received: from localhost ([::1]:36564 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhty-0000xC-1e for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 16:57:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42182) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhJl-0002y1-Hs for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhJk-0004k1-Mr for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:29 -0400 Received: from mail-oi0-x243.google.com ([2607:f8b0:4003:c06::243]:38990) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhJk-0004jc-HC; Mon, 23 Jul 2018 16:20:28 -0400 Received: by mail-oi0-x243.google.com with SMTP id d189-v6so3482790oib.6; Mon, 23 Jul 2018 13:20:28 -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=B2Xe/MYL9HdquHUy7rdn5+WCA/XvHWA8evaGwtKwy6M=; b=YQTJPmPJuMuAJcWdrj82sZDuQVdERMC7LRsDv0J3Y3hnJz16ZkBsPOzZWiWMnSJ0Oi puJanFB+FddhJzV1q/hy37SPYNJ+8wf7GIYXtGPHHZQ7pSqth767+ngMDjRpI1BsgX4a 4UCv8oKv3Ll6RM1xgZuA1wzW7zwO678hUBN+uK8S9/EP7I8Y80HH8GNtrsE6VrOwy0D9 v+nYZxaGW/EE/qPp//hvjS4L+Pdz87zQUPa1u7zve4nD95R5321wrir948V189RQXSD8 AYqtRALOFkh4m8XJUsVoWGOITZAWxA2i8HnyinEc5VI+AqNidTTwn5RDeWDdWAoU1vud aHeA== 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=B2Xe/MYL9HdquHUy7rdn5+WCA/XvHWA8evaGwtKwy6M=; b=cHhKf9ys49O8TWnJfc1bUhfmEOWS0jLLWDRvXWxuUQY+74BVTfMx6w0XQQ4/+XIht7 BpOvwHOH+K+e56WX+v46bicily3iqhkkXIlesnBw5u5WWe9KmM0yfe7oPLyny5VqOb8z 55zKzcHsJY8e48bcpnq5SbvVcZlN5OBIvKKbcyvWRG7eZuiCAg66VCf40ZmOZpzAUA4g eDuEpwRrFpOp5l4GB64dYfMiMjxQ9qIva/V7PxHX06O3Lk6zSW2HbfDpHLSugayIAOty QxYtRONMzH7PP8KnkRQbcKsp2XaCiS+EECZGHOzvG0slSKCAp9fJz+YJR/GdFTBeWN6A UIoQ== X-Gm-Message-State: AOUpUlE8ijna86VTg/qvWMcDk/YCHh+Hl2bJdUtKEGloccxYgM1tqcor ueiPK/65lP85g3RP8jltPg4s5ZvycFo= X-Google-Smtp-Source: AAOMgpeHiopESvv1Tx3eFsHTtqOm8BO7aK6oIJVTLXb2HcokR5mPCNulKg8S2aQs70MSgCRhq7wtlQ== X-Received: by 2002:aca:b702:: with SMTP id h2-v6mr326185oif.66.1532377227408; Mon, 23 Jul 2018 13:20:27 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id d5-v6sm7175889oia.57.2018.07.23.13.20.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:20:26 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:17:03 -0500 Message-Id: <20180723201748.25573-55-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::243 Subject: [Qemu-devel] [PATCH 54/99] cpus: tcg: fix never exiting loop on unplug 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: Paolo Bonzini , qemu-stable@nongnu.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Cédric Le Goater Commit 9b0605f9837b ("cpus: tcg: unregister thread with RCU, fix exiting of loop on unplug") changed the exit condition of the loop in the vCPU thread function but forgot to remove the beginning 'while (1)' statement. The resulting code : while (1) { ... } while (!cpu->unplug || cpu_can_run(cpu)); is a sequence of two distinct two while() loops, the first not exiting in case of an unplug event. Remove the first while (1) to fix CPU unplug. Signed-off-by: Cédric Le Goater Message-Id: <20180425131828.15604-1-clg@kaod.org> Cc: qemu-stable@nongnu.org Fixes: 9b0605f9837b68fd56c7fc7c96a3a1a3b983687d Signed-off-by: Paolo Bonzini Signed-off-by: Cédric Le Goater (cherry picked from commit 54961aac190df28d311802364d19e18d5cda8bab) Signed-off-by: Michael Roth --- cpus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpus.c b/cpus.c index 38eba8bff3..e1d94038fd 100644 --- a/cpus.c +++ b/cpus.c @@ -1648,7 +1648,7 @@ static void *qemu_tcg_cpu_thread_fn(void *arg) /* process any pending work */ cpu->exit_request = 1; - while (1) { + do { if (cpu_can_run(cpu)) { int r; qemu_mutex_unlock_iothread(); From patchwork Mon Jul 23 20:17:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948035 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="tK5AZkpT"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZDQf6cFxz9ryn for ; Tue, 24 Jul 2018 07:00:10 +1000 (AEST) Received: from localhost ([::1]:36578 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhw8-00035C-BS for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 17:00:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42234) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhJn-00030e-El for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhJm-0004la-Ks for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:31 -0400 Received: from mail-oi0-x230.google.com ([2607:f8b0:4003:c06::230]:39354) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhJm-0004lE-FR; Mon, 23 Jul 2018 16:20:30 -0400 Received: by mail-oi0-x230.google.com with SMTP id d189-v6so3482968oib.6; Mon, 23 Jul 2018 13:20:30 -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=mHJgjdp2Vil9qIKDIe2fzj/mFOiua4IISQrnc8448ik=; b=tK5AZkpTZEHgKcLtAvwbV91f+Csb3vTf9Om5UkYq3X1r3UonAMUrtqA6CCbzlQTUs/ ymBluLpEAarr58Yavn8zg+3/HFJkpy8X30ALabOr+eCGwYhIyAZh6tjtzIv24oFnMAPq +vfiXONj8SgfkKTip5nLaROYhbtl3LRBrxsGwIx+yysQWoL5Xok59E0Srchtp6eqQFWW 6LePfb9s3ChoPAxjtU01v9J6tQ/Cov23dOlnA+eMj9tkWQmsKKI/ZwP7wUVwqekIICSJ FR7VhSjq4yTAHj/0ytlLwzgZa5J8sji6f7TjklV954WbtaAXzM81Ee0PD3LUQLvniOr2 1fJQ== 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=mHJgjdp2Vil9qIKDIe2fzj/mFOiua4IISQrnc8448ik=; b=OLUN8jAfM4YafuTpp1+VFgR2SiO3IDZzmGSSZ11TH7c6aWzRIjIuFuxacbhLL5zN4B i4/Orr3hzDb2lVGNG2q7Lk7Q7YDSKkPYZnbpUAfxCH37lOjIYx04wOWpphhvOvA3NrVE 67LHd0JnqsP0y6U5VFVxNNFWLhhFLPxi9UVm7+xzGNh1lQMTOppNQ+7Zmgon5DPX4VF3 iakQIqtUK7hL4TcY6hn/r5QLThFuQ9R7neyTOh8a1Xu5ctyFdhppuJuxdyr1cm4kXF6S /2k0urJ0wMAFqhdaRrpKejYDqw9LCQgkSXYzMiur9rbRxOXVhLOhzMBGOhmaJZf/Tbp4 wi7g== X-Gm-Message-State: AOUpUlFQz8aAsiF/b0ClpLoisJw1psfZ9h+z8WP3LuXRi2c0K1SQb6Gc gViEpTaT2izPTzM9rrEZ0O4Cur4+qsg= X-Google-Smtp-Source: AAOMgpcwKMEcR+xS5v2MtoAMupZvG/5IJ1OStAEMeOUnU6a0SPq0a7OVf2h71t2MohEFZftTXqo7jA== X-Received: by 2002:aca:abc6:: with SMTP id u189-v6mr304207oie.61.1532377229352; Mon, 23 Jul 2018 13:20:29 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id n6-v6sm9331253oib.27.2018.07.23.13.20.27 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:20:28 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:17:04 -0500 Message-Id: <20180723201748.25573-56-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::230 Subject: [Qemu-devel] [PATCH 55/99] nbd/client: fix nbd_negotiate_simple_meta_context 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: Vladimir Sementsov-Ogievskiy , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Vladimir Sementsov-Ogievskiy Initialize received variable. Otherwise, is is possible for server to answer without any contexts, but we will set context_id to something random (received_id is not initialized too) and return 1, which is wrong. To solve it, just initialize received to false. Initialize received_id too, just to make all possible checkers happy. Bug was introduced in 78a33ab58782efdb206de14 "nbd: BLOCK_STATUS for standard get_block_status function: client part" with the whole function. Signed-off-by: Vladimir Sementsov-Ogievskiy Message-Id: <20180427142002.21930-2-vsementsov@virtuozzo.com> Reviewed-by: Eric Blake CC: qemu-stable@nongnu.org Signed-off-by: Eric Blake (cherry picked from commit 89aa0d87634e2cb98517509dc8bdb876f26ecf8b) Signed-off-by: Michael Roth --- nbd/client.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nbd/client.c b/nbd/client.c index 3523c863fe..232ff4f46d 100644 --- a/nbd/client.c +++ b/nbd/client.c @@ -619,8 +619,8 @@ static int nbd_negotiate_simple_meta_context(QIOChannel *ioc, { int ret; NBDOptionReply reply; - uint32_t received_id; - bool received; + uint32_t received_id = 0; + bool received = false; uint32_t export_len = strlen(export); uint32_t context_len = strlen(context); uint32_t data_len = sizeof(export_len) + export_len + From patchwork Mon Jul 23 20:17:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948038 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="A0Xqk0Ir"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZDSB3dwYz9ryn for ; Tue, 24 Jul 2018 07:01:30 +1000 (AEST) Received: from localhost ([::1]:36594 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhxQ-0004CK-4d for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 17:01:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42291) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhJp-000352-Df for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhJo-0004no-Lh for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:33 -0400 Received: from mail-oi0-x243.google.com ([2607:f8b0:4003:c06::243]:38991) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhJo-0004mx-GD; Mon, 23 Jul 2018 16:20:32 -0400 Received: by mail-oi0-x243.google.com with SMTP id d189-v6so3483148oib.6; Mon, 23 Jul 2018 13:20:32 -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=pCq8sAqdtI4nyjBJlEXAu9mUe3sKLCYPjSfPiiWudy0=; b=A0Xqk0IrbyJzaGg0fGd+AkhbHb9fWO7YcJXKbJxtwQHJFptNynb4+zjpHmWrJroy2B 3iUCmE+hXISzOm89PbjS9wQDkJcV7Z0Y7T3z8BTvHthKcT35/fdjrwDrwE8gqbmZ2kNg e9CEPgaaUEgA+l6YfL4wgIEd03wn9bz7hWM7WvUHHmRbfX45xEDbZQ4bGVuUBA7dM/gu /8+zRhtGu7Va7rlAbWm2vwDo66fkRcEYRNfDA6Anc0AwLVegrL2uz9lHGLm8dK0A42Mx rD19cJRqLyx51HANOD17zIWRqQkA6OWt8qe/zPHEfKjprKXsvnHXtUnwEMq2AxZRcx1E gL1g== 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=pCq8sAqdtI4nyjBJlEXAu9mUe3sKLCYPjSfPiiWudy0=; b=KMzHBpZ4Xnt3FIjDOAYM2lk4CpveJI0ng6oSsLw7kmWZHBcKbUhPG/Rl+LVnZrG3Ff lwzLurN+chLAyPL/4DoeO4m0xEFzIqojCwLYvZzz5OSaTMSdbYcWak6uVYlZM9CxxegQ dCJm7Z3atIdS+Tn3oW6fCwFt0516tX5HGasS1KN7a3t+tMWav/8nb3E316oJLdnrMpua xfmEdmbYl4PPUCDu2VYcqUNuhbQ7+xwrAMhYAKdp4iaQVNW3RDbQp7TzllK7TRPVB/ME YC8Y5eJiOd7xFS/c4KupxODkt/BVYCDrFtzX6ngYmtJ6/uBdYBUn8iTNa5Zfck4UL2go qiQg== X-Gm-Message-State: AOUpUlECc3EbrER+z5l5cHYkTWszRoPGaBdlFJGrN9wy9ymgktWoAHGw 8cmVQnD2+zi5FzLvwrROe3X191hgU8Y= X-Google-Smtp-Source: AAOMgpdi4mU0fmM5o49iehioSs5apWBNWtUkKJhAPK5/X4+tPNc7eKbWYPzSA7czDZpG5LEQO6PjcQ== X-Received: by 2002:aca:af11:: with SMTP id y17-v6mr291971oie.274.1532377231390; Mon, 23 Jul 2018 13:20:31 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id v5-v6sm1201957oix.36.2018.07.23.13.20.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:20:30 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:17:05 -0500 Message-Id: <20180723201748.25573-57-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::243 Subject: [Qemu-devel] [PATCH 56/99] migration/block-dirty-bitmap: fix memory leak in dirty_bitmap_load_bits 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: Vladimir Sementsov-Ogievskiy , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Vladimir Sementsov-Ogievskiy Release buf on error path too. Bug was introduced in b35ebdf076d697bc "migration: add postcopy migration of dirty bitmaps" with the whole function. Signed-off-by: Vladimir Sementsov-Ogievskiy Message-Id: <20180427142002.21930-3-vsementsov@virtuozzo.com> Reviewed-by: Eric Blake CC: qemu-stable@nongnu.org Signed-off-by: Eric Blake (cherry picked from commit 16a2227893dc1d5cad78ed376ad1d7e300978fbe) Signed-off-by: Michael Roth --- migration/block-dirty-bitmap.c | 1 + 1 file changed, 1 insertion(+) diff --git a/migration/block-dirty-bitmap.c b/migration/block-dirty-bitmap.c index dd04f102d8..8819aabe3a 100644 --- a/migration/block-dirty-bitmap.c +++ b/migration/block-dirty-bitmap.c @@ -600,6 +600,7 @@ static int dirty_bitmap_load_bits(QEMUFile *f, DirtyBitmapLoadState *s) ret = qemu_get_buffer(f, buf, buf_size); if (ret != buf_size) { error_report("Failed to read bitmap bits"); + g_free(buf); return -EIO; } From patchwork Mon Jul 23 20:17:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948051 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="YWSRITgp"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZDfk6V5Yz9s3Z for ; Tue, 24 Jul 2018 07:10:38 +1000 (AEST) Received: from localhost ([::1]:36652 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhi6G-0005nG-Fl for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 17:10:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42358) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhJt-000397-Gp for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhJr-0004qU-7Q for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:37 -0400 Received: from mail-oi0-x22d.google.com ([2607:f8b0:4003:c06::22d]:40348) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhJr-0004qB-1z; Mon, 23 Jul 2018 16:20:35 -0400 Received: by mail-oi0-x22d.google.com with SMTP id w126-v6so3478066oie.7; Mon, 23 Jul 2018 13:20:34 -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=/GJkBe1r4wQptuy97THglNYn4b/4p6mfnUmhtPMpMHI=; b=YWSRITgpCHIMTzphmcReurutL6ik2bL5EHIi/oX+Qy3dG4rnJztGdJYxSiekKHwsaM 7L0mG2x6Jw7Yv96sE/G9oOySRXQ9EnNxm7oaOLCMOB94d3sMGnTbwh5I5sI8SHEsmtLQ IWqopcPU8eeR76yg5o+idbAYFDiyF6ygB9eU0HHaVE2RjYlm0FxDsb9rqi75ggfS6FgT EWBpwHURJk6WKed/b12nY+xQqhcGOv+9ZAFbkS3Im8ukhUGW50UMUTRJehTa0rOb3DaH wCqwrY3CEG7FpP7H6+dvOJWyeM3bogt8pTuwtT/M3zhX5BJg5CQgFSuuOh3ai5EGVI9E MVcA== 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=/GJkBe1r4wQptuy97THglNYn4b/4p6mfnUmhtPMpMHI=; b=qZNCl+sH/peEaT+12zprM5lLq9bTAocjnqSsK20WPOksp74mReVwiU8z5Hb/ySurOY /hzdm4iCNW/VGK/0thCnCcgN2tl5xyhaiH5kYtdwbHacpGImlvbMh8M4TKucNpMyNazW 9z0X4kMKdcbvVgvEFFfh9xmCuDcFPrYbEhsjzgxaPmwn6+OHf8otoadnPH2bNshoJZ5L prkffrWwUgFEbCSTU+vJxhz+mc2VeYlRRK5tk3l1gTlCTb1w+5qRLNOZ7F1eg0ECXpnq 3If+M/tS1/Mu+WuwgZ/ihNb/J4T8FRPoTr+KhIj8W86YcrlPSIQvQdRcXepJmYYS5Oon J5vg== X-Gm-Message-State: AOUpUlG0Zisby3CI+AUECjs76awCWY9vv+Wvl6JqOKbzJYMLpu7y5XTB fJN5vjUPFCZwjrooqGM0M8glCrECFUZc0w== X-Google-Smtp-Source: AAOMgpefX36DTncIZoMaiajUJoiPXoyxRN3DYGZpLDD6BhSUGfTRM6s45Qg15Jkf06W+4M2wavTrvw== X-Received: by 2002:aca:e6cd:: with SMTP id d196-v6mr324201oih.94.1532377233866; Mon, 23 Jul 2018 13:20:33 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id m62-v6sm26387051oik.30.2018.07.23.13.20.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:20:32 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:17:06 -0500 Message-Id: <20180723201748.25573-58-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::22d Subject: [Qemu-devel] [PATCH 57/99] qapi: fill in CpuInfoFast.arch in query-cpus-fast 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: Laszlo Ersek , Cornelia Huck , qemu-stable@nongnu.org, Viktor VM Mihajlovski , Markus Armbruster Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Laszlo Ersek * Commit ca230ff33f89 added the @arch field to @CpuInfoFast, but it failed to set the new field in qmp_query_cpus_fast(), when TARGET_S390X was not defined. The updated @query-cpus-fast example in "qapi-schema.json" showed "arch":"x86" only because qmp_query_cpus_fast() calls g_malloc0() to allocate @CpuInfoFast, and the CPU_INFO_ARCH_X86 enum constant is generated with value 0. All @arch values other than @s390 implied the @CpuInfoOther sub-struct for @CpuInfoFast -- at the time of writing the patch --, thus no fields other than @arch needed to be set when TARGET_S390X was not defined. Set @arch now, by copying the corresponding assignments from qmp_query_cpus(). * Commit 25fa194b7b11 added the @riscv enum constant to @CpuInfoArch (used in both @CpuInfo and @CpuInfoFast -- the return types of the @query-cpus and @query-cpus-fast commands, respectively), and assigned, in both return structures, the @CpuInfoRISCV sub-structure to the new enum value. However, qmp_query_cpus_fast() would not populate either the @arch field or the @CpuInfoRISCV sub-structure, when TARGET_RISCV was defined; only qmp_query_cpus() would. Assign @CpuInfoOther to the @riscv enum constant in @CpuInfoFast, and populate only the @arch field in qmp_query_cpus_fast(). Getting CPU state without interrupting KVM is an exceptional thing that only S390X does currently. Quoting Cornelia Huck , "s390x is exceptional in that it has state in QEMU that is actually interesting for upper layers and can be retrieved without performance penalty". See also . Cc: Cornelia Huck Cc: Eric Blake Cc: Markus Armbruster Cc: Viktor VM Mihajlovski Cc: qemu-stable@nongnu.org Fixes: ca230ff33f89bf7102cbfbc2328716da6750aaed Fixes: 25fa194b7b11901561532e435beb83d046899f7a Signed-off-by: Laszlo Ersek Reviewed-by: Eric Blake Reviewed-by: Cornelia Huck Reviewed-by: Markus Armbruster Message-Id: <20180427192852.15013-2-lersek@redhat.com> Signed-off-by: Markus Armbruster (cherry picked from commit 96054f56396eaa0b9b5c681fc3e42a0004b17ade) Signed-off-by: Michael Roth --- cpus.c | 16 +++++++++++++++- qapi/misc.json | 2 +- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/cpus.c b/cpus.c index e1d94038fd..6fa701e423 100644 --- a/cpus.c +++ b/cpus.c @@ -2218,11 +2218,25 @@ CpuInfoFastList *qmp_query_cpus_fast(Error **errp) info->value->props = props; } -#if defined(TARGET_S390X) +#if defined(TARGET_I386) + info->value->arch = CPU_INFO_ARCH_X86; +#elif defined(TARGET_PPC) + info->value->arch = CPU_INFO_ARCH_PPC; +#elif defined(TARGET_SPARC) + info->value->arch = CPU_INFO_ARCH_SPARC; +#elif defined(TARGET_MIPS) + info->value->arch = CPU_INFO_ARCH_MIPS; +#elif defined(TARGET_TRICORE) + info->value->arch = CPU_INFO_ARCH_TRICORE; +#elif defined(TARGET_S390X) s390_cpu = S390_CPU(cpu); env = &s390_cpu->env; info->value->arch = CPU_INFO_ARCH_S390; info->value->u.s390.cpu_state = env->cpu_state; +#elif defined(TARGET_RISCV) + info->value->arch = CPU_INFO_ARCH_RISCV; +#else + info->value->arch = CPU_INFO_ARCH_OTHER; #endif if (!cur_item) { head = cur_item = info; diff --git a/qapi/misc.json b/qapi/misc.json index 5636f4a149..104d013adb 100644 --- a/qapi/misc.json +++ b/qapi/misc.json @@ -573,7 +573,7 @@ 'mips': 'CpuInfoOther', 'tricore': 'CpuInfoOther', 's390': 'CpuInfoS390', - 'riscv': 'CpuInfoRISCV', + 'riscv': 'CpuInfoOther', 'other': 'CpuInfoOther' } } ## From patchwork Mon Jul 23 20:17:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948040 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ZZ19ESyF"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZDVH6NWgz9ryn for ; Tue, 24 Jul 2018 07:03:19 +1000 (AEST) Received: from localhost ([::1]:36609 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhzB-0005i0-BI for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 17:03:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42379) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhJu-0003Ad-JI for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhJt-0004rW-K1 for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:38 -0400 Received: from mail-oi0-x22f.google.com ([2607:f8b0:4003:c06::22f]:34563) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhJt-0004rI-Dv; Mon, 23 Jul 2018 16:20:37 -0400 Received: by mail-oi0-x22f.google.com with SMTP id 13-v6so3505790ois.1; Mon, 23 Jul 2018 13:20:37 -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=5/hLiQrUtX4DP48kiLIpTEF5NgdxyUdRCA9tb0HzHH8=; b=ZZ19ESyFhxR94l7E34KKrwV/jLRNFd6zNHMnqcoHYfbF6Vg7i23Q0x2M9hmDFhyJJ9 RyM4szm93nuAnz1jynI4ZKge6IgMintRECjj9zYfNWOehGavW6PYqwYOn7ctqYaQvAri 52JobMj3+AAy9WjSdB5Ry7naQTWXO4+58UE/P2Kjh78JXq/HwSF9tpNiSdZrIFWzZGrP zURr4ecGHPFuSShpT1bJTds3dkSv6i4dUr+pqu6hJyFAJhehxX8z60l1gas0ujJ6EKQV iyKQIgXYIQnsGez9pWlHDN0dSio//fJYGEgCYd+uIUiQ4AHqcE7BhxGtSyFtskE11keL /7Dg== 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=5/hLiQrUtX4DP48kiLIpTEF5NgdxyUdRCA9tb0HzHH8=; b=ovF48TH/IizulB+2LghvtzGENImdLzEUxivHspvxAgYlk5Nx60jOfHo78mb3YIJr22 YUFnxO0GjcsEd4nw2bmA+lcnNXpztIYgBhffsUwbSgmt99ZDCF8xMwF87vEWWzOJfvum dh7XfGaIei0ekfWljm/nMTp0bNH2K9UUJQT+Edx7rxLWiNZnijBiD5selAEzmbbO2bBX v965NIi+iiJJMMFhWGHqYText3A732NaqjJhYHGiTXLQl/ogK27uLP3M+FigsW/Qo8Q5 Uo0dBVNpJH6FR79FyUM+eQRPR/wwMD6+VCZp7ah0sxForv/Ooy/S7fhGucbqcw/TIqDR /gvQ== X-Gm-Message-State: AOUpUlGduliZ4htpK+mWh6bigj/71cSgQ5zhSUVs12wMV5WNUQU4OwkZ 362GqxN2lBUl//I6Zk+aP9UY2W+a2789mg== X-Google-Smtp-Source: AAOMgpeXdGV2MryByXaAKAAYJLqrxmDCfDHXyz6CwIQlYVp7VzTA5tXcT/j1goLxQuvaakh2bA/pcg== X-Received: by 2002:aca:305:: with SMTP id 5-v6mr340255oid.84.1532377236295; Mon, 23 Jul 2018 13:20:36 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id r81-v6sm14555505oih.28.2018.07.23.13.20.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:20:35 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:17:07 -0500 Message-Id: <20180723201748.25573-59-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::22f Subject: [Qemu-devel] [PATCH 58/99] block/mirror: Make cancel always cancel pre-READY 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: Jeff Cody , qemu-stable@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Max Reitz Commit b76e4458b1eb3c32e9824fe6aa51f67d2b251748 made the mirror block job respect block-job-cancel's @force flag: With that flag set, it would now always really cancel, even post-READY. Unfortunately, it had a side effect: Without that flag set, it would now never cancel, not even before READY. Considering that is an incompatible change and not noted anywhere in the commit or the description of block-job-cancel's @force parameter, this seems unintentional and we should revert to the previous behavior, which is to immediately cancel the job when block-job-cancel is called before source and target are in sync (i.e. before the READY event). Cc: qemu-stable@nongnu.org Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1572856 Reported-by: Yanan Fu Signed-off-by: Max Reitz Reviewed-by: Eric Blake Message-id: 20180501220509.14152-2-mreitz@redhat.com Reviewed-by: Jeff Cody Signed-off-by: Jeff Cody (cherry picked from commit eb36639f7bbc16055e551593b81365e8ae3b0b05) Signed-off-by: Michael Roth --- block/mirror.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/block/mirror.c b/block/mirror.c index 9436a8d5ee..99da9c0858 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -874,7 +874,9 @@ static void coroutine_fn mirror_run(void *opaque) } trace_mirror_before_sleep(s, cnt, s->synced, delay_ns); block_job_sleep_ns(&s->common, delay_ns); - if (block_job_is_cancelled(&s->common) && s->common.force) { + if (block_job_is_cancelled(&s->common) && + (!s->synced || s->common.force)) + { break; } s->last_pause_ns = qemu_clock_get_ns(QEMU_CLOCK_REALTIME); From patchwork Mon Jul 23 20:17:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948045 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Jkcx0Vld"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZDYk1HGdz9s29 for ; Tue, 24 Jul 2018 07:06:18 +1000 (AEST) Received: from localhost ([::1]:36626 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhi23-0001vX-Pu for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 17:06:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42430) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhJx-0003DU-8U for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhJv-0004sk-LQ for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:41 -0400 Received: from mail-oi0-x233.google.com ([2607:f8b0:4003:c06::233]:46743) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhJv-0004sN-E8; Mon, 23 Jul 2018 16:20:39 -0400 Received: by mail-oi0-x233.google.com with SMTP id y207-v6so3459640oie.13; Mon, 23 Jul 2018 13:20:39 -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=jShd1MOGW/97a1gW2dElQ0j8rNPMc1QIfTmRNLgO79w=; b=Jkcx0VlduGQl43jpkQfz+8NYVMbNt0EKmJQdkTtHAW0JgS8m7g4apiQUpd0Y8a6/Mv CyZH6BH66PCeqvSNoyAYZI3oFYMirWDMcrvJqku4tLI062FlRZVs7b8bMfzqzjoYIbor y1tWLNQJa55fWKHVno4OJu2qo4Og7QReqkmviKDhGEDWtvEXAgOVGgC3drbXWVKSdy8A 4ER285Cjy/LE9WFb3BUFok9dWwpGBX3BmmJjAT9JGhyeVnWezUceMdGAax9Wo81h3R3F ODxjCPUEDKy4iTt026DHU5+wKJyMIAVTweh0n+zVlz1NntKpW+oITg20jo7Y3i16DNMK zRZw== 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=jShd1MOGW/97a1gW2dElQ0j8rNPMc1QIfTmRNLgO79w=; b=gyxphaGgJgBbiOIjoCtAWfhQTshoOQtoPdpYr5DjZDWRAG5x8yOIcL2N3VeCeB1cTA eJu3xE2JKZcEZLm4Q0YLq7HF8gfYoBg3kMzq121r1dzm7/PrrKE+s+F7ehcucWbURTmr +QufuCPipV3yxMaYUUYqfIRyGm76K1qoqtEZylVjmMgnlExLJVwQme4y30Rwuk9hvH3u dDykPwDSz+EUypyMb51DWeyuB6WqnqmN815WdECeIeL4tbWcG348NviPVj5QFP9vFaCO ZOIbmXTLP4QR1wbI8F7oL5GBLBlbIiR4DqA4a83K0dpTRgfvP4LVahHNSA5rDnjxcESY PVhw== X-Gm-Message-State: AOUpUlE76uK7Rm+Tq8C1F3IGgGBUVGLpTMWtFjsvexMsHZ6cGOuEHiZj aiFa2aIMJLVlLhYockqd52UZdykReNv7Vg== X-Google-Smtp-Source: AAOMgpdA3jHuMn6TSwiQjxbAwc4YKrMs8Iga/v1ef5BcpQtZJbdw4MG+YI4bF0J4v/xLy3GC4G/XDw== X-Received: by 2002:aca:a56:: with SMTP id 83-v6mr317980oik.57.1532377238200; Mon, 23 Jul 2018 13:20:38 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id 5-v6sm7388234oix.58.2018.07.23.13.20.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:20:37 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:17:08 -0500 Message-Id: <20180723201748.25573-60-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::233 Subject: [Qemu-devel] [PATCH 59/99] iotests: Add test for cancelling a mirror job 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: Jeff Cody , qemu-stable@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Max Reitz We already have an extensive mirror test (041) which does cover cancelling a mirror job, especially after it has emitted the READY event. However, it does not check what exact events are emitted after block-job-cancel is executed. More importantly, it does not use throttling to ensure that it covers the case of block-job-cancel before READY. It would be possible to add this case to 041, but considering it is already our largest test file, it makes sense to create a new file for these cases. Signed-off-by: Max Reitz Message-id: 20180501220509.14152-3-mreitz@redhat.com Signed-off-by: Jeff Cody (cherry picked from commit dc885fff972c447f51572afc4c921a26b880731b) Conflicts: tests/qemu-iotests/group * fix minor conflicts with test groups Signed-off-by: Michael Roth --- tests/qemu-iotests/218 | 138 +++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/218.out | 30 ++++++++ tests/qemu-iotests/group | 1 + 3 files changed, 169 insertions(+) create mode 100644 tests/qemu-iotests/218 create mode 100644 tests/qemu-iotests/218.out diff --git a/tests/qemu-iotests/218 b/tests/qemu-iotests/218 new file mode 100644 index 0000000000..92c331b6fb --- /dev/null +++ b/tests/qemu-iotests/218 @@ -0,0 +1,138 @@ +#!/usr/bin/env python +# +# This test covers what happens when a mirror block job is cancelled +# in various phases of its existence. +# +# Note that this test only checks the emitted events (i.e. +# BLOCK_JOB_COMPLETED vs. BLOCK_JOB_CANCELLED), it does not compare +# whether the target is in sync with the source when the +# BLOCK_JOB_COMPLETED event occurs. This is covered by other tests +# (such as 041). +# +# Copyright (C) 2018 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# Creator/Owner: Max Reitz + +import iotests +from iotests import log + +iotests.verify_platform(['linux']) + + +# Launches the VM, adds two null-co nodes (source and target), and +# starts a blockdev-mirror job on them. +# +# Either both or none of speed and buf_size must be given. + +def start_mirror(vm, speed=None, buf_size=None): + vm.launch() + + ret = vm.qmp('blockdev-add', + node_name='source', + driver='null-co', + size=1048576) + assert ret['return'] == {} + + ret = vm.qmp('blockdev-add', + node_name='target', + driver='null-co', + size=1048576) + assert ret['return'] == {} + + if speed is not None: + ret = vm.qmp('blockdev-mirror', + job_id='mirror', + device='source', + target='target', + sync='full', + speed=speed, + buf_size=buf_size) + else: + ret = vm.qmp('blockdev-mirror', + job_id='mirror', + device='source', + target='target', + sync='full') + + assert ret['return'] == {} + + +log('') +log('=== Cancel mirror job before convergence ===') +log('') + +log('--- force=false ---') +log('') + +with iotests.VM() as vm: + # Low speed so it does not converge + start_mirror(vm, 65536, 65536) + + log('Cancelling job') + log(vm.qmp('block-job-cancel', device='mirror', force=False)) + + log(vm.event_wait('BLOCK_JOB_CANCELLED'), + filters=[iotests.filter_qmp_event]) + +log('') +log('--- force=true ---') +log('') + +with iotests.VM() as vm: + # Low speed so it does not converge + start_mirror(vm, 65536, 65536) + + log('Cancelling job') + log(vm.qmp('block-job-cancel', device='mirror', force=True)) + + log(vm.event_wait('BLOCK_JOB_CANCELLED'), + filters=[iotests.filter_qmp_event]) + + +log('') +log('=== Cancel mirror job after convergence ===') +log('') + +log('--- force=false ---') +log('') + +with iotests.VM() as vm: + start_mirror(vm) + + log(vm.event_wait('BLOCK_JOB_READY'), + filters=[iotests.filter_qmp_event]) + + log('Cancelling job') + log(vm.qmp('block-job-cancel', device='mirror', force=False)) + + log(vm.event_wait('BLOCK_JOB_COMPLETED'), + filters=[iotests.filter_qmp_event]) + +log('') +log('--- force=true ---') +log('') + +with iotests.VM() as vm: + start_mirror(vm) + + log(vm.event_wait('BLOCK_JOB_READY'), + filters=[iotests.filter_qmp_event]) + + log('Cancelling job') + log(vm.qmp('block-job-cancel', device='mirror', force=True)) + + log(vm.event_wait('BLOCK_JOB_CANCELLED'), + filters=[iotests.filter_qmp_event]) diff --git a/tests/qemu-iotests/218.out b/tests/qemu-iotests/218.out new file mode 100644 index 0000000000..7dbf78e682 --- /dev/null +++ b/tests/qemu-iotests/218.out @@ -0,0 +1,30 @@ + +=== Cancel mirror job before convergence === + +--- force=false --- + +Cancelling job +{u'return': {}} +{u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'device': u'mirror', u'type': u'mirror', u'speed': 65536, u'len': 1048576, u'offset': 65536}, u'event': u'BLOCK_JOB_CANCELLED'} + +--- force=true --- + +Cancelling job +{u'return': {}} +{u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'device': u'mirror', u'type': u'mirror', u'speed': 65536, u'len': 1048576, u'offset': 65536}, u'event': u'BLOCK_JOB_CANCELLED'} + +=== Cancel mirror job after convergence === + +--- force=false --- + +{u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'device': u'mirror', u'type': u'mirror', u'speed': 0, u'len': 1048576, u'offset': 1048576}, u'event': u'BLOCK_JOB_READY'} +Cancelling job +{u'return': {}} +{u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'device': u'mirror', u'type': u'mirror', u'speed': 0, u'len': 1048576, u'offset': 1048576}, u'event': u'BLOCK_JOB_COMPLETED'} + +--- force=true --- + +{u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'device': u'mirror', u'type': u'mirror', u'speed': 0, u'len': 1048576, u'offset': 1048576}, u'event': u'BLOCK_JOB_READY'} +Cancelling job +{u'return': {}} +{u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'device': u'mirror', u'type': u'mirror', u'speed': 0, u'len': 1048576, u'offset': 1048576}, u'event': u'BLOCK_JOB_CANCELLED'} diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index fc10a72192..6bb961f4a4 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -212,4 +212,5 @@ 211 rw auto quick 212 rw auto quick 213 rw auto quick +218 rw auto quick 221 rw auto quick From patchwork Mon Jul 23 20:17:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948042 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="S6BeCgiB"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZDX42hlBz9ryn for ; Tue, 24 Jul 2018 07:04:52 +1000 (AEST) Received: from localhost ([::1]:36616 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhi0g-00078g-0r for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 17:04:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42459) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhJy-0003F9-SZ for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhJx-0004uA-UJ for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:42 -0400 Received: from mail-oi0-x230.google.com ([2607:f8b0:4003:c06::230]:43126) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhJx-0004tk-Ou; Mon, 23 Jul 2018 16:20:41 -0400 Received: by mail-oi0-x230.google.com with SMTP id b15-v6so3466858oib.10; Mon, 23 Jul 2018 13:20:41 -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=rlKboz4z72+ISy/gALo19ELGOLmC9GOfsjOKdbEnSsQ=; b=S6BeCgiBPq2P4U4AIEd1hceALn8UL90GRJmhzE5V6sK9BC8nDx3YDHD7F+W/9+NHz0 wHCo47y44PEss9ykY/JoWfXPvM3YuEmjCG2/ZOavAL71j4F6mP0PlPQhs86q1ylF3TqU 8UUV2u4neQFnmE5APdojKkCMXtn10NKdwmtPwA2pOQLqIiT/7RFtn8Dg4QXAQc9BStpo hnDTdIC/WkSu8Rka0XO6Y+4vvVZejRp8PyrjyesrOlZA6Un+lDsy6l276ok77r/2g+B4 n1R1S0rwKBy9hF6bhHWANNmUasXhEFi4JSftpMNrd66n8s8UkCei6vRY0r2CS4OkLYCy +kwQ== 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=rlKboz4z72+ISy/gALo19ELGOLmC9GOfsjOKdbEnSsQ=; b=Jwfi/0LO4SPdS1pFij71Zky7GPF3nX5xQ7WZMy0Yc/IL2R0nqLAK8Infv4K6EKUOlG OlrTpraAv3iIM/UkTqT9fxZ+Zx3pvgPhZsQDbQEg05Rz45MQH7IxardzanYJPkzgyS8I QCtDZBD/8VWU/P0vWA0I3qCWjy3y+c8koYQ8vflb2TrD+/Hll+eT0OOHuHDbpO/TU2rb 40WYt3i5+HvzbUnJNeUud1sOd4wmEbsqtFj1+7790CNOohyLDXpSr6MPtb7GMX0d7BsG kJs7HDryk/p1s9ZIH6HnN37DgBtkQA0OYCLXHhSh/CKDGdwOBaufwySewX6M7DUSE/Dy +r2g== X-Gm-Message-State: AOUpUlH3JXoph0eFUjGRnK3VU8S0BbElM20ccqFtjKqplT+EBguReZP+ qBEILOLUEhBnt2mYKl0kkyQVNjG+sGyF7w== X-Google-Smtp-Source: AAOMgpfNQKOqVhkmM+/BdPqVH3p+jjePRMTYt1D3eb0Sml6mSw7/3FEv2vtHPYewrdaKCIOg9ssr5A== X-Received: by 2002:aca:c78c:: with SMTP id x134-v6mr328815oif.8.1532377240624; Mon, 23 Jul 2018 13:20:40 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id q18-v6sm1082473oic.18.2018.07.23.13.20.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:20:39 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:17:09 -0500 Message-Id: <20180723201748.25573-61-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::230 Subject: [Qemu-devel] [PATCH 60/99] riscv: spike: allow base == 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: KONRAD Frederic , Michael Clark , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: KONRAD Frederic The sanity check on base doesn't allow htif to be mapped @0. Check if the symbol exists instead so we can map it where we want. Reviewed-by: Michael Clark Signed-off-by: KONRAD Frederic Signed-off-by: Michael Clark Message-Id: <1525360636-18229-2-git-send-email-frederic.konrad@adacore.com> (cherry picked from commit 17b9751e85b9989cc841ed387794d7f1e8aa5e46) Signed-off-by: Michael Roth --- hw/riscv/riscv_htif.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hw/riscv/riscv_htif.c b/hw/riscv/riscv_htif.c index 3e17f30251..be252ec8cc 100644 --- a/hw/riscv/riscv_htif.c +++ b/hw/riscv/riscv_htif.c @@ -41,17 +41,20 @@ } while (0) static uint64_t fromhost_addr, tohost_addr; +static int address_symbol_set; void htif_symbol_callback(const char *st_name, int st_info, uint64_t st_value, - uint64_t st_size) + uint64_t st_size) { if (strcmp("fromhost", st_name) == 0) { + address_symbol_set |= 1; fromhost_addr = st_value; if (st_size != 8) { error_report("HTIF fromhost must be 8 bytes"); exit(1); } } else if (strcmp("tohost", st_name) == 0) { + address_symbol_set |= 2; tohost_addr = st_value; if (st_size != 8) { error_report("HTIF tohost must be 8 bytes"); @@ -248,7 +251,7 @@ HTIFState *htif_mm_init(MemoryRegion *address_space, MemoryRegion *main_mem, qemu_chr_fe_init(&s->chr, chr, &error_abort); qemu_chr_fe_set_handlers(&s->chr, htif_can_recv, htif_recv, htif_event, htif_be_change, s, NULL, true); - if (base) { + if (address_symbol_set == 3) { memory_region_init_io(&s->mmio, NULL, &htif_mm_ops, s, TYPE_HTIF_UART, size); memory_region_add_subregion(address_space, base, &s->mmio); From patchwork Mon Jul 23 20:17:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948050 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="cwxW36dP"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZDfX25KXz9s3Z for ; Tue, 24 Jul 2018 07:10:28 +1000 (AEST) Received: from localhost ([::1]:36651 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhi65-0005OB-OE for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 17:10:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42529) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhK3-0003GK-AD for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhK2-0004wf-8X for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:47 -0400 Received: from mail-oi0-x242.google.com ([2607:f8b0:4003:c06::242]:35593) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhK2-0004wP-3w; Mon, 23 Jul 2018 16:20:46 -0400 Received: by mail-oi0-x242.google.com with SMTP id i12-v6so3503600oik.2; Mon, 23 Jul 2018 13:20:46 -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=qT0VzO6qFP1dEdZdGAjHL8GINSxz9i+wbXD76nGovx8=; b=cwxW36dPWFYw/VtPPq9h6/jgnjP+fxkJEyGJhJc2NAmPDxsn4dAalw0eiw23FAvXx2 zraOk8r95nY8OU6Iu8gh8qilqQfZq7WYwjKZqatv+L3z253tz0ZyBY3Pr7DjLPxnsqsh K4eauqlxFrTTCSTJlq4g/1QOzW2VRCwVh9r8g6s/wzz161L3+GOCa+llsrxkVjcxRlqj DOE756RKdd+ZJE3hH3R8VnN1jGmt535XAQ+JpbAFM/Y5PhaHVydH8Vw5Ec/3zLQzmPyv o5f9fVl7v8j/Kbkgh5YhcyP0kZRx41E21Sbg/LZgz4o5r99DN64zJ1W2g+885RRRLBQo B2Ig== 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=qT0VzO6qFP1dEdZdGAjHL8GINSxz9i+wbXD76nGovx8=; b=DL730mPQM01b95BBhnbf19y+9PFhwTZLl2Ht2cpO1UicYwIYBoVxW+8o1tNVtxs+Y9 7vXJ8+kAgK/VaFAVzIyKbO71lXneeKIgjBpcR5v8Mqv5xyJESNPaAX7oSP/ZzcLMjTBg IryRJ67e3WLwVoyCGcKEqJPoFrSPooWpzE6k4MwsvVUtGHCzkwx6yMX2Eu16xS9v39ri erhAyfmWkGAY6jUPMLR+Qi3AuuA5RXjqRbd2xlLvlkcDDR3l/IbfJvDR8aLoFfGD3OHU sFpFE/aLnKHPRbdCWOb2w1GzGqFtAFWYfFjODxxFOakN4w5Kq/VAKXVm2hqE+Ad+bgj9 SoVw== X-Gm-Message-State: AOUpUlG3MoG5q8whmZ9P5gTVHzUW3cFfdsRiUHpfoGHrXZH99aRebqmC mAjIdoIGNtMO16vACcziaavLm3X/KsWXIQ== X-Google-Smtp-Source: AAOMgpd9PiyYW7VWwFvufDCz6U7prnRBpHo5NssZZTLwu8BZZ/1Pftrlp4lTy2WU624a0kUp8Fo0Ag== X-Received: by 2002:aca:6c4f:: with SMTP id h76-v6mr308093oic.214.1532377244908; Mon, 23 Jul 2018 13:20:44 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id y85-v6sm10626087oie.25.2018.07.23.13.20.43 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:20:43 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:17:10 -0500 Message-Id: <20180723201748.25573-62-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::242 Subject: [Qemu-devel] [PATCH 61/99] riscv: htif: increase the priority of the htif subregion 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: KONRAD Frederic , Michael Clark , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: KONRAD Frederic The htif device is supposed to be mapped over an other subregion. So increase its priority to one to avoid any conflict. Here is the output of info mtree: Before: (qemu) info mtree address-space: memory 0000000000000000-ffffffffffffffff (prio 0, i/o): system 0000000000000000-000000000000000f (prio 0, i/o): riscv.htif.uart 0000000000000000-0000000000011fff (prio 0, ram): riscv.spike.bootrom 0000000002000000-000000000200ffff (prio 0, i/o): riscv.sifive.clint 0000000080000000-0000000087ffffff (prio 0, ram): riscv.spike.ram address-space: I/O 0000000000000000-000000000000ffff (prio 0, i/o): io address-space: cpu-memory-0 0000000000000000-ffffffffffffffff (prio 0, i/o): system 0000000000000000-000000000000000f (prio 0, i/o): riscv.htif.uart 0000000000000000-0000000000011fff (prio 0, ram): riscv.spike.bootrom 0000000002000000-000000000200ffff (prio 0, i/o): riscv.sifive.clint 0000000080000000-0000000087ffffff (prio 0, ram): riscv.spike.ram After: (qemu) info mtree address-space: memory 0000000000000000-ffffffffffffffff (prio 0, i/o): system 0000000000000000-000000000000000f (prio 1, i/o): riscv.htif.uart 0000000000000000-0000000000011fff (prio 0, ram): riscv.spike.bootrom 0000000002000000-000000000200ffff (prio 0, i/o): riscv.sifive.clint 0000000080000000-0000000087ffffff (prio 0, ram): riscv.spike.ram address-space: I/O 0000000000000000-000000000000ffff (prio 0, i/o): io address-space: cpu-memory-0 0000000000000000-ffffffffffffffff (prio 0, i/o): system 0000000000000000-000000000000000f (prio 1, i/o): riscv.htif.uart 0000000000000000-0000000000011fff (prio 0, ram): riscv.spike.bootrom 0000000002000000-000000000200ffff (prio 0, i/o): riscv.sifive.clint 0000000080000000-0000000087ffffff (prio 0, ram): riscv.spike.ram Reviewed-by: Michael Clark Signed-off-by: KONRAD Frederic Signed-off-by: Michael Clark Message-Id: <1525360636-18229-3-git-send-email-frederic.konrad@adacore.com> (cherry picked from commit 6fad7d1893f6ea926063067af957009bc320406f) Signed-off-by: Michael Roth --- hw/riscv/riscv_htif.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/riscv/riscv_htif.c b/hw/riscv/riscv_htif.c index be252ec8cc..f73512941f 100644 --- a/hw/riscv/riscv_htif.c +++ b/hw/riscv/riscv_htif.c @@ -253,8 +253,9 @@ HTIFState *htif_mm_init(MemoryRegion *address_space, MemoryRegion *main_mem, htif_be_change, s, NULL, true); if (address_symbol_set == 3) { memory_region_init_io(&s->mmio, NULL, &htif_mm_ops, s, - TYPE_HTIF_UART, size); - memory_region_add_subregion(address_space, base, &s->mmio); + TYPE_HTIF_UART, size); + memory_region_add_subregion_overlap(address_space, base, + &s->mmio, 1); } return s; From patchwork Mon Jul 23 20:17:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948049 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ra9lWKlT"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZDf56SHLz9s29 for ; Tue, 24 Jul 2018 07:10:05 +1000 (AEST) Received: from localhost ([::1]:36647 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhi5j-00052Y-FH for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 17:10:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42585) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhK5-0003IX-Fo for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhK4-0004zu-Eq for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:49 -0400 Received: from mail-oi0-x241.google.com ([2607:f8b0:4003:c06::241]:37279) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhK4-0004zQ-92; Mon, 23 Jul 2018 16:20:48 -0400 Received: by mail-oi0-x241.google.com with SMTP id k81-v6so3479879oib.4; Mon, 23 Jul 2018 13:20:48 -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=wftTN7C1RQmcZIvig4W3x+qttIO4fwbtikiMRlzpnWM=; b=ra9lWKlTbtwGLMdXNeLETsYCLF6mFVCAUeE/lXuVrwlk4dlruvJ4Y4cg6ux9ZiHW1f yW/CuAGMYs75YSXCZQ0r9rPZWsQwmxkUraTt8c2rEs3x3S3vXvUhqGXbxSF5FGkfHq9t PQjlpj3yCOzZ8D0iTtAz28QqtMHwCOxweZ7oBrYLgJWfl/SubGYV13/gXFm5hYhkLrtj 0nKFsYGd7NIny4mY1Sap7mt1ZrqftAwS1Q7uw1S61mo1HY8GvS0TVBSm/Wnzd7rXFXMg SURLWrwPvs66mOB+CrdgWLnbGl0BsNBT9XLK7kIPIaGavUi/jHs31P7ie2TBSF4NP2LG 6ybw== 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=wftTN7C1RQmcZIvig4W3x+qttIO4fwbtikiMRlzpnWM=; b=Jx0+nAXklbS9tzpjwuHCG9Dw56bntS3BN+G0ZaceUxBS6LiD35BJ6P6ug+JagRf4Kq 3kxe7u2jo4f4rJnsfSAVf2yeKEMmVKRGU7KSDW1+lyBRIzdkkuWVp1ImvvmLlhIpdax6 8eFD7tMmcp31ltdkS+AHHaUzfdLLBQDLE5qz+m9a0dErpcbrE5HNXwww03nYpUz4XtTl 2sIOC+p6RHZsotZy15SxMxCLfuYSIwtttsa8MRuj4psyl0UXOddnwVTShpdQJ6+zCq3+ h1suj/Fivo1CSLNl69LRqUK5FFxtiSW6kGq2gFZQyX5sQbwesontFw2Ua31JPcbKkMam sA3Q== X-Gm-Message-State: AOUpUlG3N6710HeFj2wfDRjkqOflYnh7zxY5oauSURDBTcGQGeE5xaxn L/h8KKiRJuhQN9Ao84VVKCSza/jwu2uLoQ== X-Google-Smtp-Source: AAOMgpegcI9mjRUQrLkcPp4A2bvn4Y5OCpPOw6KshtQEAfUce+kUYjyfpltTcWf+XwYw3bSMGiNMUA== X-Received: by 2002:aca:34d6:: with SMTP id b205-v6mr277868oia.77.1532377247124; Mon, 23 Jul 2018 13:20:47 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id v202-v6sm9030607oie.47.2018.07.23.13.20.45 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:20:46 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:17:11 -0500 Message-Id: <20180723201748.25573-63-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::241 Subject: [Qemu-devel] [PATCH 62/99] riscv: requires libfdt 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: KONRAD Frederic , Michael Clark , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: KONRAD Frederic When compiling on a machine without libfdt installed the configure script should try to get libfdt from the git or should die because otherwise CONFIG_LIBFDT is not set and the build process end in an error in the link phase.. eg: hw/riscv/virt.o: In function `riscv_virt_board_init': qemu/src/hw/riscv/virt.c:317: undefined reference to `qemu_fdt_setprop_cell' qemu/src/hw/riscv/virt.c:319: undefined reference to `qemu_fdt_setprop_cell' qemu/src/hw/riscv/virt.c:345: undefined reference to `qemu_fdt_dumpdtb' collect2: error: ld returned 1 exit status make[1]: *** [qemu-system-riscv64] Error 1 make: *** [subdir-riscv64-softmmu] Error 2 Cc: qemu-stable@nongnu.org Reviewed-by: Bastian Koppelmann Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Michael Clark Signed-off-by: KONRAD Frederic Signed-off-by: Michael Clark Message-Id: <1525360636-18229-4-git-send-email-frederic.konrad@adacore.com> (cherry picked from commit a666409f0df5dce113a5bd2c4c144a0792f2a4a3) Signed-off-by: Michael Roth --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 44bf1fef04..457684a7e6 100755 --- a/configure +++ b/configure @@ -3734,7 +3734,7 @@ fi fdt_required=no for target in $target_list; do case $target in - aarch64*-softmmu|arm*-softmmu|ppc*-softmmu|microblaze*-softmmu|mips64el-softmmu) + aarch64*-softmmu|arm*-softmmu|ppc*-softmmu|microblaze*-softmmu|mips64el-softmmu|riscv*-softmmu) fdt_required=yes ;; esac From patchwork Mon Jul 23 20:17:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948052 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="jwNGbniv"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZDjJ2KJ4z9s3N for ; Tue, 24 Jul 2018 07:12:52 +1000 (AEST) Received: from localhost ([::1]:36666 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhi8P-00084z-U2 for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 17:12:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42629) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhK7-0003Kt-AG for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhK6-00051I-9v for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:51 -0400 Received: from mail-oi0-x22b.google.com ([2607:f8b0:4003:c06::22b]:41660) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhK6-000510-4q; Mon, 23 Jul 2018 16:20:50 -0400 Received: by mail-oi0-x22b.google.com with SMTP id k12-v6so3466682oiw.8; Mon, 23 Jul 2018 13:20:50 -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=zfNUWA2FT5JnALSz8JjIUuLr9sPx3kKVNCmRIeDr+04=; b=jwNGbniv3DEBY7SjHp6p1sB+bV0jeq+o0ncdlA+4Av6APxtCEwMXzs8Cmyeqsoaq+i bfZp92Rh40eEQdfwseq/fph7MzS70lRJNIe0Ecl99VGrIf5qQSVYC67KBebGAA84bTyz QJu1OxI7m5IsDhuOrrX8eWs53g6voXx0+oXBiK4Fn7ZaECTHuglWqAJWJ4wn3tDp7rDS GLSchx6H0EtDbUq0veAEhBxAPNFNZC/+v0COzXtZy4Ide8W8GLrPED8CeSdA0I08Ok+M yUVl2Mnu1+tzSeO4xzW4ar6J8FH5gN7aBk0ig1vRquzNIGAC+yP+oFi80C1hMJBSLyu2 db4Q== 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=zfNUWA2FT5JnALSz8JjIUuLr9sPx3kKVNCmRIeDr+04=; b=iH3ahOt1JhJ0FyuGu48dGSBt65eDwmWqOdqKrz9kyz3frPfCzCJQK7IS4skCdWuJrs fim9SLJjUho3NvZf5qgZeeIbHKG+VgkrkxC+3oBcs8ga7/YVFgmm096QQYeMWNi1DVv+ 3Cup9U/kRvfdNqQdL0LpsgK+OkC5cBSBe8yXPmmDDVgbgp2sBCSabA5a33NgKdX+81Vt JWnU1MtTdypYwkooCqxhFfqyiI1Nq/3EE9/KN9CVOuY+Fs2Arr3xodO6tAu/gB1EC8aQ IUlio9uVx1o99x7fnhFw0qtRTDTXHCp6YMaL/VyG+bvQKmgY/YO9JzHRO8Of/egqEFVx irfg== X-Gm-Message-State: AOUpUlHFEdVRrAnq44Pro2nffs4Mi7JD7Gjl8K55huyWuni28ijNBRnK kq37MsioNUmG7dhGM6aPcy92lC7BNr2ehg== X-Google-Smtp-Source: AAOMgpfFtrqHP8CcpV1Vr3MJUPr/VDHmKouQG1jpuFZytGfhr9U/vTsf2QngQKE7pHuiE8Ll1iAJfQ== X-Received: by 2002:aca:698c:: with SMTP id e134-v6mr332052oic.302.1532377249031; Mon, 23 Jul 2018 13:20:49 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id x5-v6sm7419935oix.3.2018.07.23.13.20.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:20:48 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:17:12 -0500 Message-Id: <20180723201748.25573-64-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::22b Subject: [Qemu-devel] [PATCH 63/99] nbd/client: Relax handling of large NBD_CMD_BLOCK_STATUS reply 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: qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Eric Blake The NBD spec is proposing a relaxation of NBD_CMD_BLOCK_STATUS where a server may have the final extent per context give a length beyond the original request, if it can easily prove that subsequent bytes have the same status, on the grounds that a client can take advantage of this information for fewer block status requests. Since qemu 2.12 as a client always sends NBD_CMD_FLAG_REQ_ONE, and rejects a server that sends extra length, the upstream NBD spec will probably limit this behavior to clients that don't request REQ_ONE semantics; but it doesn't hurt to relax qemu to always be permissive of this server behavior, even if it continues to use REQ_ONE. CC: qemu-stable@nongnu.org Signed-off-by: Eric Blake Message-Id: <20180503222626.1303410-1-eblake@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy (cherry picked from commit acfd8f7a5f92e703d2d046cbe3d510008a697194) Signed-off-by: Michael Roth --- block/nbd-client.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/block/nbd-client.c b/block/nbd-client.c index e7caf49fbb..8d69eaaa32 100644 --- a/block/nbd-client.c +++ b/block/nbd-client.c @@ -259,14 +259,18 @@ static int nbd_parse_blockstatus_payload(NBDClientSession *client, if (extent->length == 0 || (client->info.min_block && !QEMU_IS_ALIGNED(extent->length, - client->info.min_block)) || - extent->length > orig_length) - { + client->info.min_block))) { error_setg(errp, "Protocol error: server sent status chunk with " "invalid length"); return -EINVAL; } + /* The server is allowed to send us extra information on the final + * extent; just clamp it to the length we requested. */ + if (extent->length > orig_length) { + extent->length = orig_length; + } + return 0; } From patchwork Mon Jul 23 20:17:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948054 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ZQ2c32K5"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZDkr4DY7z9s3Z for ; Tue, 24 Jul 2018 07:14:12 +1000 (AEST) Received: from localhost ([::1]:36677 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhi9i-0000k3-5b for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 17:14:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42675) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhKB-0003Q0-QU for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhK8-00052K-JM for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:55 -0400 Received: from mail-oi0-x243.google.com ([2607:f8b0:4003:c06::243]:38122) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhK8-000520-E7; Mon, 23 Jul 2018 16:20:52 -0400 Received: by mail-oi0-x243.google.com with SMTP id v8-v6so3482212oie.5; Mon, 23 Jul 2018 13:20:52 -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=OppfwWBPBz1GOM6QzTsx+TJsOuHI0ZxTseXqqx+wcA4=; b=ZQ2c32K5DisfX8WtGp11hAc3GBl+GgTjjOKh/Pdp7wH24qrdv7n2+54827dkDfx3qE iWX9QtNQgarObXvVc9bcfp1OgfPvEwnNAehY+642ELLkuM1tSNVzyOxNAau9CP1RoY0u W5mGIQitc4sD8BfipuIYlWx11A5+/NZWb4MK+Vv79B+VTu1S14N5uqzyiUZ3WYq1dINV ztqQry3h3YcWihb132qo1QVIP8km65CnUxcrfKeDnVuN4WnTbzqXbcMsfCXbyU6gdqNL Mr00X/njU5okT/yQrmSt9rokBK7da9gwFr24stjpvl8DsWFFaGb0Hs1D7eyzvzdxZDNS GQdw== 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=OppfwWBPBz1GOM6QzTsx+TJsOuHI0ZxTseXqqx+wcA4=; b=e8XohEm7oTFgehRxtz5WxIZgjozKRTcygU65eMR8VVMsjnXqDp6CdId1geS/V5B3S8 SqmatwRaShv2uS0n802+IJq7+B9xz3qkSojHwpvVwUwozCQsU39nDjb4jqNM1v88NpeF 1TqlkTlVpRUOQ6jyNyqbjQxAvA732QXwNZGQE6VPG89RR7zU/I6PynduMFIVDRnFdfLc jX7kVlLf1/nNwWGDIdrABk+9TL98KQzHf2OU1iGmrdF0VxCbLpX6dIGMgH5C3IjZXn+w R+QPa+541y1yCGh1MOrZaM1jBwhQ5jp6ymdVQRy5YLr5m7Djood0std7bKL6yo2MuJXJ rT0w== X-Gm-Message-State: AOUpUlEhwMgbCZ55WZnORu8kwUZ/JwiiHUl3nhjwMtDjboUA0QxBj9y0 DUO/VYu2zioi7JC7h81BJYM46/YeesgyZg== X-Google-Smtp-Source: AAOMgpfuXxShBuNsO2lOwbaABRyiyw4FAWpiWu5J0RgpaWB9dmoRNZwfX937ihn95D26WpVnlP8LkQ== X-Received: by 2002:aca:3b89:: with SMTP id i131-v6mr302123oia.109.1532377251221; Mon, 23 Jul 2018 13:20:51 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id o65-v6sm7411173oia.35.2018.07.23.13.20.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:20:50 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:17:13 -0500 Message-Id: <20180723201748.25573-65-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::243 Subject: [Qemu-devel] [PATCH 64/99] tcg/i386: Fix dup_vec in non-AVX2 codepath 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: Peter Maydell , Richard Henderson , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell The VPUNPCKLD* instructions are all "non-destructive source", indicated by "NDS" in the encoding string in the x86 ISA manual. This means that they take two source operands, one of which is encoded in the VEX.vvvv field. We were incorrectly treating them as if they were destructive-source and passing 0 as the 'v' argument of tcg_out_vex_modrm(). This meant we were always using %xmm0 as one of the source operands, causing incorrect results if the register allocator happened to want to use something else. For instance the input AArch64 insn: DUP v26.16b, w21 which becomes TCG IR ops: dup_vec v128,e8,tmp2,x21 st_vec v128,e8,tmp2,env,$0xa40 was assembled to: 0x607c568c: c4 c1 7a 7e 86 e8 00 00 vmovq 0xe8(%r14), %xmm0 0x607c5694: 00 0x607c5695: c5 f9 60 c8 vpunpcklbw %xmm0, %xmm0, %xmm1 0x607c5699: c5 f9 61 c9 vpunpcklwd %xmm1, %xmm0, %xmm1 0x607c569d: c5 f9 70 c9 00 vpshufd $0, %xmm1, %xmm1 0x607c56a2: c4 c1 7a 7f 8e 40 0a 00 vmovdqu %xmm1, 0xa40(%r14) 0x607c56aa: 00 when the vpunpcklwd insn should be "%xmm1, %xmm1, %xmm1". This resulted in our incorrectly setting the output vector to q26=0000320000003200:0000320000003200 when given an input of x21 == 0000000002803200 rather than the expected all-zeroes. Pass the correct source register number to tcg_out_vex_modrm() for these insns. Fixes: 770c2fc7bb70804a Cc: qemu-stable@nongnu.org Signed-off-by: Peter Maydell Message-Id: <20180504153431.5169-1-peter.maydell@linaro.org> Signed-off-by: Richard Henderson (cherry picked from commit 7eb30ef0ba2eb59e7430d4848ae8d4bf4e50f768) Signed-off-by: Michael Roth --- tcg/i386/tcg-target.inc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tcg/i386/tcg-target.inc.c b/tcg/i386/tcg-target.inc.c index d7e59e79c5..5357909fff 100644 --- a/tcg/i386/tcg-target.inc.c +++ b/tcg/i386/tcg-target.inc.c @@ -854,11 +854,11 @@ static void tcg_out_dup_vec(TCGContext *s, TCGType type, unsigned vece, switch (vece) { case MO_8: /* ??? With zero in a register, use PSHUFB. */ - tcg_out_vex_modrm(s, OPC_PUNPCKLBW, r, 0, a); + tcg_out_vex_modrm(s, OPC_PUNPCKLBW, r, a, a); a = r; /* FALLTHRU */ case MO_16: - tcg_out_vex_modrm(s, OPC_PUNPCKLWD, r, 0, a); + tcg_out_vex_modrm(s, OPC_PUNPCKLWD, r, a, a); a = r; /* FALLTHRU */ case MO_32: @@ -867,7 +867,7 @@ static void tcg_out_dup_vec(TCGContext *s, TCGType type, unsigned vece, tcg_out8(s, 0); break; case MO_64: - tcg_out_vex_modrm(s, OPC_PUNPCKLQDQ, r, 0, a); + tcg_out_vex_modrm(s, OPC_PUNPCKLQDQ, r, a, a); break; default: g_assert_not_reached(); From patchwork Mon Jul 23 20:17:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948058 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Oza78fsP"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZDp732QVz9s3N for ; Tue, 24 Jul 2018 07:17:03 +1000 (AEST) Received: from localhost ([::1]:36703 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhiCT-0003YU-0b for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 17:17:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42677) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhKB-0003Q4-St for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhKA-00056V-QR for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:55 -0400 Received: from mail-oi0-x241.google.com ([2607:f8b0:4003:c06::241]:42734) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhKA-00055l-L5; Mon, 23 Jul 2018 16:20:54 -0400 Received: by mail-oi0-x241.google.com with SMTP id n84-v6so3469947oib.9; Mon, 23 Jul 2018 13:20:54 -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=xmopYi/nNf6wdml7iVdwwr/MlVD9CKCWQdp5ypLE2TI=; b=Oza78fsPzFXGvZgyyzN1ZGhAyTX4tX4NFhFJBaSRVhsCJEkMGOlUG2sCl0UU7HPnFN hCE98e6fMLSUGphJxqobhcRq4CrB2tm9mLcsBtMTLWZQXON0csMbJiVNPfMnrprzFwUX sQfiwPozqtNC4WLAUXwYg8lHg7FTMCGo8T6eA53VXg4ouKcb0X3CXKUqBvqCVOjiH1cZ 6hmsYzojHIeLTNOlX/UfN+9iANwLj+qkc4HsFiIYyzGglCQysQTWWqirc4NkcijWGjt4 7TTDCMkaCWqJGnMFXxLUL4tEz3vXzfvasme/M2L5eQXPtzTQdKhBxROqzh5CXCAcQpc3 JLeA== 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=xmopYi/nNf6wdml7iVdwwr/MlVD9CKCWQdp5ypLE2TI=; b=G5fJTgfNnb2qKSS9bDYUiXuQ8Xpev5lgEsfIVwaxb8k4Z3CzFlJ7iRc0WmihUM/GMh IZRgUOZA+OiyLLR7oFxDyxnxNK25FRAV4339MO64xxYaBVTePwzQuS90VnzaP+ZO07bV kepT7ybmGVGJXVuuMBvDsXUQgWz9utNtBbIIZj/VXxOb5O3IhBK5AYW7N3HhE/ln+Y98 nDaM7jsZ6EapirEsW9By98hfF+R3my2eT6SGXa/KuFSMtWr6bclsxgTSiaINLgbCH+V+ Ivxc530oqP3a6GelUdu17FFtl7mmoI9kJD7R5XHvwg0+vFUfT7siRNB+z+/6V9u6IL+I ZH7g== X-Gm-Message-State: AOUpUlE8Y7yT0S6L15j1Xk3Zo0WedvAG7s2CCKLZMclOTSXmxuJYV331 x9tYruLEijzl+piQNJTizD1wKbolMTml2Q== X-Google-Smtp-Source: AAOMgpeOGZHhxi4TqjJHifW3DEH66QjP86DNUGA8+50GPL0BIqvvFN4/8gnCXGe0o/cp4aEJTg3slg== X-Received: by 2002:aca:5155:: with SMTP id f82-v6mr329457oib.272.1532377253517; Mon, 23 Jul 2018 13:20:53 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id s124-v6sm6811118oia.51.2018.07.23.13.20.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:20:52 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:17:14 -0500 Message-Id: <20180723201748.25573-66-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::241 Subject: [Qemu-devel] [PATCH 65/99] softfloat: Handle default NaN mode after pickNaNMulAdd, not before 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: Peter Maydell , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell It is implementation defined whether a multiply-add of (0,inf,qnan) or (inf,0,qnan) raises InvalidaOperation or not, so we let the target-specific pickNaNMulAdd function handle this. This means that we must do the "return the default NaN in default NaN mode" check after the call, not before. Correct the ordering, and restore the comment from the old propagateFloat64MulAddNaN() that warned about this corner case. This fixes a regression from 2.11 for Arm guests where we would incorrectly fail to set the Invalid flag for these cases. Cc: qemu-stable@nongnu.org Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Alex Bennée Tested-by: Alex Bennée Message-id: 20180504100547.14621-1-peter.maydell@linaro.org (cherry picked from commit 1839189bbf89889076aadf0c793c1b57977b28d7) Signed-off-by: Michael Roth --- fpu/softfloat.c | 48 ++++++++++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 70e0c40a1c..8401b37bd4 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -602,34 +602,42 @@ static FloatParts pick_nan(FloatParts a, FloatParts b, float_status *s) static FloatParts pick_nan_muladd(FloatParts a, FloatParts b, FloatParts c, bool inf_zero, float_status *s) { + int which; + if (is_snan(a.cls) || is_snan(b.cls) || is_snan(c.cls)) { s->float_exception_flags |= float_flag_invalid; } + which = pickNaNMulAdd(is_qnan(a.cls), is_snan(a.cls), + is_qnan(b.cls), is_snan(b.cls), + is_qnan(c.cls), is_snan(c.cls), + inf_zero, s); + if (s->default_nan_mode) { + /* Note that this check is after pickNaNMulAdd so that function + * has an opportunity to set the Invalid flag. + */ a.cls = float_class_dnan; - } else { - switch (pickNaNMulAdd(is_qnan(a.cls), is_snan(a.cls), - is_qnan(b.cls), is_snan(b.cls), - is_qnan(c.cls), is_snan(c.cls), - inf_zero, s)) { - case 0: - break; - case 1: - a = b; - break; - case 2: - a = c; - break; - case 3: - a.cls = float_class_dnan; - return a; - default: - g_assert_not_reached(); - } + return a; + } - a.cls = float_class_msnan; + switch (which) { + case 0: + break; + case 1: + a = b; + break; + case 2: + a = c; + break; + case 3: + a.cls = float_class_dnan; + return a; + default: + g_assert_not_reached(); } + a.cls = float_class_msnan; + return a; } From patchwork Mon Jul 23 20:17:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948048 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Q+X5h3MG"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZDdx1xQDz9s29 for ; Tue, 24 Jul 2018 07:09:57 +1000 (AEST) Received: from localhost ([::1]:36646 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhi5a-0004up-Qq for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 17:09:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42716) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhKE-0003SC-3h for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhKC-00058Z-Sf for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:58 -0400 Received: from mail-oi0-x242.google.com ([2607:f8b0:4003:c06::242]:37281) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhKC-00058L-NG; Mon, 23 Jul 2018 16:20:56 -0400 Received: by mail-oi0-x242.google.com with SMTP id k81-v6so3480648oib.4; Mon, 23 Jul 2018 13:20:56 -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=R567CLjPuLcmj/VmBI4Kxetfln6noYhEtAG8G2ZZXUI=; b=Q+X5h3MGXiNclUucpwx+wTKNg7AinTo4CDBFlySZINKpoMs+cu6QdcSmuPF0FJpLMM 8jf6GIJaaGvjSRQtBP8lsJmL6dWqG7eyCbAaAU4RDp/lD46gEUaCp2kteeFUXU1rcEjH 9I5D/1TXoaG+FttQniQu8oSbL5gyAx/cRqSwF4NDLmM5MwaS+TeLuJAFp7lA2JbbYYwH HsGr034qGOVhN6J04RMZQ6ZhBDrf3b/TuC0ErZc/YQ3D7cY/SeY7AHsWiPNQK9hy3UV6 4y5KNBZXe1s0DVL5I8v4hGrR7w540llH6uae4TRBsSTbiC12oCKc7GRuZ0NRZJMopAuI CBOQ== 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=R567CLjPuLcmj/VmBI4Kxetfln6noYhEtAG8G2ZZXUI=; b=YyV4z+Bm8TpitwsATSHhrQC2vcJw9xHIbsKOF7J5bXDy+6g6Y+xwkHhP0IDv3dqBx+ KZz4dCkeHzP2is6gLN56F2kL/4y0l4W+15yHeHEYC1jLleDN1iH6fjjU7AYn+LonJRPl Cyvjnes9X6YVw5tfbw1BT1tC8vULJH48IyGKzhzLlzcYCKbVAUPr7GR9fLurjjJ6RnOm 8nqFZnsWm8jIDlmBCM45S2ZSLBDePH6GOlaiMBYk2pVWNkuA5xxM41Tg7kwV7YYjxbxo TSHkAflEOxjUlgKo67B7KG0m9eOAlbI204tq0HVk0LgN7nBLryxHdGaXdlAkn63BD0mN 4gvg== X-Gm-Message-State: AOUpUlEFKawoKQ78LlpxEblxkXhVtWuGNCbVBWJM+gD0V7xgL2up5dcW T257D5sHHO+GTtJjijsdksWDc8JSMQv7+g== X-Google-Smtp-Source: AAOMgpcE6ASJLexHb9D7hHOXuRgoQG8k+uVVanSSqcSi4UhB0oQgfRpl0JdKrh6FWZ3/ufz8Gidq1w== X-Received: by 2002:aca:d015:: with SMTP id h21-v6mr345379oig.142.1532377255554; Mon, 23 Jul 2018 13:20:55 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id m62-v6sm26388292oik.30.2018.07.23.13.20.54 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:20:54 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:17:15 -0500 Message-Id: <20180723201748.25573-67-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::242 Subject: [Qemu-devel] [PATCH 66/99] tcg: Limit the number of ops in a TB 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: Richard Henderson , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson In 6001f7729e12 we partially attempt to address the branch displacement overflow caused by 15fa08f845. However, gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/vqtbX.c is a testcase that contains a TB so large as to overflow anyway. The limit here of 8000 ops produces a maximum output TB size of 24112 bytes on a ppc64le host with that test case. This is still much less than the maximum forward branch distance of 32764 bytes. Cc: qemu-stable@nongnu.org Fixes: 15fa08f845 ("tcg: Dynamically allocate TCGOps") Reviewed-by: Laurent Vivier Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson (cherry picked from commit abebf92597186be2bc48d487235da28b1127860f) Signed-off-by: Michael Roth --- tcg/tcg.c | 3 +++ tcg/tcg.h | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index bb24526c93..66997cc653 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -866,6 +866,7 @@ void tcg_func_start(TCGContext *s) /* No temps have been previously allocated for size or locality. */ memset(s->free_temps, 0, sizeof(s->free_temps)); + s->nb_ops = 0; s->nb_labels = 0; s->current_frame_offset = s->frame_start; @@ -1983,6 +1984,7 @@ void tcg_op_remove(TCGContext *s, TCGOp *op) { QTAILQ_REMOVE(&s->ops, op, link); QTAILQ_INSERT_TAIL(&s->free_ops, op, link); + s->nb_ops--; #ifdef CONFIG_PROFILER atomic_set(&s->prof.del_op_count, s->prof.del_op_count + 1); @@ -2002,6 +2004,7 @@ static TCGOp *tcg_op_alloc(TCGOpcode opc) } memset(op, 0, offsetof(TCGOp, link)); op->opc = opc; + s->nb_ops++; return op; } diff --git a/tcg/tcg.h b/tcg/tcg.h index 30896ca304..17cf764565 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -655,6 +655,7 @@ struct TCGContext { int nb_globals; int nb_temps; int nb_indirects; + int nb_ops; /* goto_tb support */ tcg_insn_unit *code_buf; @@ -844,7 +845,12 @@ static inline TCGOp *tcg_last_op(void) /* Test for whether to terminate the TB for using too many opcodes. */ static inline bool tcg_op_buf_full(void) { - return false; + /* This is not a hard limit, it merely stops translation when + * we have produced "enough" opcodes. We want to limit TB size + * such that a RISC host can reasonably use a 16-bit signed + * branch within the TB. + */ + return tcg_ctx->nb_ops >= 8000; } /* pool based memory allocation */ From patchwork Mon Jul 23 20:17:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948055 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="O/XqjjXT"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZDln5nvMz9s3N for ; Tue, 24 Jul 2018 07:15:01 +1000 (AEST) Received: from localhost ([::1]:36682 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhiAV-0001PP-CI for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 17:14:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42748) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhKF-0003UB-Vh for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:21:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhKE-00059m-Tq for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:59 -0400 Received: from mail-oi0-x22a.google.com ([2607:f8b0:4003:c06::22a]:42536) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhKE-00059V-Nj; Mon, 23 Jul 2018 16:20:58 -0400 Received: by mail-oi0-x22a.google.com with SMTP id n84-v6so3470276oib.9; Mon, 23 Jul 2018 13:20:58 -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=tuvsSTaacbNP8kBZZ1hy3NLI7HeQdafDz/32Il/55zA=; b=O/XqjjXTniKzZf2biXRpIYHly7nXVC5ewaAi/j3sRiRASqNj712BUxaIAOhPDxZv7Y v+IpBZvA53sW7Qs+2aGME1yLGwcRSEXD7pxacRWm+kbqxm324jwX7cSIduD+KgvZ1uD6 bcEw9Ni0XCA693B4j3aHfGYst2QyjZxBD/rfIWi2t1KMa8a9GxBZxui+hOIJEikVrknU +llp3FSkiB/LT2+N/OqvBuCMqjoWRLnggkwLfTWODuq9g8ynW/o/LNMNC+7OI/eLdrrS tFxUU/ERG1zCoo2R4Hc67AfTKPNQlc+R1kmmJlCD3yVorARQr333qys61a5/vBzfiG2u 0l1w== 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=tuvsSTaacbNP8kBZZ1hy3NLI7HeQdafDz/32Il/55zA=; b=OT5N3KQcaFCAQVsmVGVVzLl3ApgJZjF9s2xV7MFs/qfuYFw8GvT2HWCA7pVzOID4dP acvX+tsXmZ/jbWR2i17vRZp1Zok2eEdxNgV8IofqI1YzL8OgFpx9j8AqyhktfhDRgQRt ZY08+OaUl+jeEMy8r2Q+ApQJsLqWHVrYVy94yAJ350WL4pFytRIfJ1D2UAVhubhrco6d HzP0mUM9AWItU91g9NQq6bn/0ObriADHZ8sIXQOQxkdzlvdARC7fwRPtcJOkX0han8p6 e30efVky7BTcq/LaqRo/m0nD/2i6V73sWY1xSXx6x9WIAjekpAG8MlPc0hlLCTOSjVKt h8Ug== X-Gm-Message-State: AOUpUlE6pXHzymhqP2mlxA/MayRI40toApU2daVIRNuMbWX5Osj9EbS2 tT06fbrobZZP0AbPV+A58femef1yCiiB+A== X-Google-Smtp-Source: AAOMgpeQKJ90T4sQOMruTAm+3pi23cSp3HURUtmhOm/7UtVVZOLfq7HcEplk6222V0wmBn/tIx6ixA== X-Received: by 2002:aca:b585:: with SMTP id e127-v6mr299311oif.119.1532377257687; Mon, 23 Jul 2018 13:20:57 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id w204-v6sm12598732oif.2.2018.07.23.13.20.56 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:20:56 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:17:16 -0500 Message-Id: <20180723201748.25573-68-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::22a Subject: [Qemu-devel] [PATCH 67/99] RISC-V: Minimal QEMU 2.12 fix for sifive_u machine 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: Sagar Karandikar , Bastian Koppelmann , Palmer Dabbelt , qemu-stable@nongnu.org, Michael Clark , Alistair Francis Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Michael Clark The 'sifive_u' board has a bug where the ROM is created as RAM at the wrong address and marked readonly. The bug renders the board unusable. This is a minimal fix and allows booting Linux. 5aec3247c190f10654250203a1742490ae7343a2 "RISC-V: Mark ROM read-only after copying in code" contains a comprehensive fix using the ROM APIs memory_region_init_rom and rom_add_blob_fixed_as which could be backported. Cc: Sagar Karandikar Cc: Bastian Koppelmann Cc: Palmer Dabbelt Cc: Alistair Francis Cc: qemu-stable@nongnu.org Signed-off-by: Michael Clark Signed-off-by: Michael Roth --- hw/riscv/sifive_u.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c index 1c2deefa6c..19b034449c 100644 --- a/hw/riscv/sifive_u.c +++ b/hw/riscv/sifive_u.c @@ -250,9 +250,9 @@ static void riscv_sifive_u_init(MachineState *machine) /* boot rom */ memory_region_init_ram(boot_rom, NULL, "riscv.sifive.u.mrom", - memmap[SIFIVE_U_MROM].base, &error_fatal); - memory_region_set_readonly(boot_rom, true); - memory_region_add_subregion(sys_memory, 0x0, boot_rom); + memmap[SIFIVE_U_MROM].size, &error_fatal); + memory_region_add_subregion(sys_memory, memmap[SIFIVE_U_MROM].base, + boot_rom); if (machine->kernel_filename) { load_kernel(machine->kernel_filename); @@ -282,6 +282,7 @@ static void riscv_sifive_u_init(MachineState *machine) qemu_fdt_dumpdtb(s->fdt, s->fdt_size); cpu_physical_memory_write(memmap[SIFIVE_U_MROM].base + sizeof(reset_vec), s->fdt, s->fdt_size); + memory_region_set_readonly(boot_rom, true); /* MMIO */ s->plic = sifive_plic_create(memmap[SIFIVE_U_PLIC].base, From patchwork Mon Jul 23 20:17:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948064 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="JijIKuWG"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZDtQ6y12z9s3N for ; Tue, 24 Jul 2018 07:20:46 +1000 (AEST) Received: from localhost ([::1]:36721 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhiG4-000702-I3 for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 17:20:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42793) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhKK-0003Y5-KO for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:21:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhKH-0005As-DX for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:21:04 -0400 Received: from mail-oi0-x230.google.com ([2607:f8b0:4003:c06::230]:35550) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhKH-0005Ae-82; Mon, 23 Jul 2018 16:21:01 -0400 Received: by mail-oi0-x230.google.com with SMTP id i12-v6so3504850oik.2; Mon, 23 Jul 2018 13:21:01 -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=nIcdRG13OwHhVSw9tUDr/TTtXiyQtkraJxUayg18V2E=; b=JijIKuWGPftCBTiJKV9kqUR7F3bBEf+DNkhlf97kT40BolkxT3NtgLnNPiAToGnvI+ Fjp0+WsgZ4sqUElfSyhXZIVdMDR0+F1Wncmobq0D6V0Pyk838VYSEvRyJNqiXeh8afbX fi4iMDlRiyFIshG0OkRSS+R4ypa8yIciPxXQeV2JCnx1t3+D1oKWTTNtG8/gMTIAZYZH ol7dN9cfgOqPL+MoMZXXbHZbWYi/vD5ykwJtl4ldrWPfhT1yLbSGcVj1qbXL/ZDFLWFK UGcVG6E2FLi6N8ui6AEX5UOQXF5sJRM/GuJtJMylTtaqqX7iyVj/jkpD9enDTsvFRlhi TlQA== 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=nIcdRG13OwHhVSw9tUDr/TTtXiyQtkraJxUayg18V2E=; b=X4CpiK95D7vJjDQnFIDH/zn33DCXq3WW6FHMSNJ45E2wqa+y6yyMS7oDmuZM8E7zzo 8eS2haHNgMi07JP+9e6eJveVdzh6tvH946WEC1/HLPsGiBq4YcO1cxBlDkqEan/0UxA5 BFDwCH0frcdwmxxdGUrdTCgVYxrVsZTlTD4mdy0NL40N4XyN20QamGgJypVdoJHDeqOB 4YLJ12HsextZAmrVWCoQV858TitawSxLSmNjRgHpuL0zL69F62bAq3w52qql9dI3GC0C cWZWbUTmQ17qdYyNrfZcRfQ4hNN1zH/052Sm9NxkmiQ7z4WMqOS24kAWjXnYJVTulRFZ SgRg== X-Gm-Message-State: AOUpUlEcNdBfOsVXlv/kqV8UfB5eODtK4s/ZfRYFHLbpTB7S3xfEu/yi 8peDMfUqBecVm/1b/wfxhn5QVNmDO4f5mw== X-Google-Smtp-Source: AAOMgpctwR21S1graZQMNjoptv+viF7cuqk0aWVA9O897JXOyBg5P+5m+z2MdeeYbH+9S6pbAAd5Tg== X-Received: by 2002:aca:d5cd:: with SMTP id m196-v6mr305129oig.160.1532377260070; Mon, 23 Jul 2018 13:21:00 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id f4-v6sm2838788oic.52.2018.07.23.13.20.58 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:20:59 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:17:17 -0500 Message-Id: <20180723201748.25573-69-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::230 Subject: [Qemu-devel] [PATCH 68/99] blockjob: expose error string via query 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: Kevin Wolf , John Snow , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: John Snow When we've reached the concluded state, we need to expose the error state if applicable. Add the new field. This should be sufficient for determining if a job completed successfully or not after concluding; if we want to discriminate based on how it failed more mechanically, we can always add an explicit return code enumeration later. I didn't bother to make it only show up if we are in the concluded state; I don't think it's necessary. Cc: qemu-stable@nongnu.org Signed-off-by: John Snow Reviewed-by: Eric Blake Reviewed-by: Alberto Garcia Signed-off-by: Kevin Wolf (cherry picked from commit ab9ba614556ac5b0f8d96b99e0dba19f1e28d6c2) Signed-off-by: Michael Roth --- blockjob.c | 2 ++ qapi/block-core.json | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/blockjob.c b/blockjob.c index 27f957e571..4de48166b2 100644 --- a/blockjob.c +++ b/blockjob.c @@ -831,6 +831,8 @@ BlockJobInfo *block_job_query(BlockJob *job, Error **errp) info->status = job->status; info->auto_finalize = job->auto_finalize; info->auto_dismiss = job->auto_dismiss; + info->has_error = job->ret != 0; + info->error = job->ret ? g_strdup(strerror(-job->ret)) : NULL; return info; } diff --git a/qapi/block-core.json b/qapi/block-core.json index c50517bff3..7da3bea6bc 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -1172,6 +1172,9 @@ # @auto-dismiss: Job will dismiss itself when CONCLUDED, moving to the NULL # state and disappearing from the query list. (since 2.12) # +# @error: Error information if the job did not complete successfully. +# Not set if the job completed successfully. (since 2.12.1) +# # Since: 1.1 ## { 'struct': 'BlockJobInfo', @@ -1179,7 +1182,8 @@ 'offset': 'int', 'busy': 'bool', 'paused': 'bool', 'speed': 'int', 'io-status': 'BlockDeviceIoStatus', 'ready': 'bool', 'status': 'BlockJobStatus', - 'auto-finalize': 'bool', 'auto-dismiss': 'bool' } } + 'auto-finalize': 'bool', 'auto-dismiss': 'bool', + '*error': 'str' } } ## # @query-block-jobs: From patchwork Mon Jul 23 20:17:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948059 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Pll/qB+l"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZDq637gsz9s3N for ; Tue, 24 Jul 2018 07:17:54 +1000 (AEST) Received: from localhost ([::1]:36706 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhiDH-0004Ui-R4 for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 17:17:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42794) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhKK-0003Y6-KP for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:21:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhKJ-0005Ce-Dz for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:21:04 -0400 Received: from mail-oi0-x233.google.com ([2607:f8b0:4003:c06::233]:43132) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhKJ-0005CV-7H; Mon, 23 Jul 2018 16:21:03 -0400 Received: by mail-oi0-x233.google.com with SMTP id b15-v6so3468635oib.10; Mon, 23 Jul 2018 13:21: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 :mime-version:content-transfer-encoding; bh=oW1WcFafgHAkdjm0CsLyqQUr/F68AJFRJMt7rynJMsM=; b=Pll/qB+ldnERQMAD1opOf1OR9FRQNDquu6vkgDXCiEj9HVQJXXbdnFISdm/cb0URnc 0JKGh2MkBFc0SmK5RpI8Z64WgPXJ0UkJmZPLVc3yknWSxemtsUP4RUOkk11csbqnj1np 5N41bmdA3/wpP5Gy/FuI8kUR7YYRRadAvFd52FBR8WlTcH8+lgn0cg4yphINWyl6ybn/ fsZuFPLMHf2xoxGbAzfZcfxOdfTFH7lMpAoXMY/PADbbvHjjHlez+Uc7BHuyh4Ro4P6D JqGi84cly2WST+H6mVE4oVXtYp85aoPyXlP8merEJ4TgD7oxi+iXNJhog3vKzolShjAI oCwg== 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=oW1WcFafgHAkdjm0CsLyqQUr/F68AJFRJMt7rynJMsM=; b=hUE/nM87zEtqjdQrKxlKCkHbxSf/ed17cEMfviPPi/3eqNcesq9ZRmCwlrkgMmi30T wXQ/p1M/IsfWzu1wxLZWo5R7t522jQpw5m3/4itbILI3CWLW1315UMlTCF1LoU6P5g+U eaKih6ppyzhKRmjEaTIt/cyOjiOb0YN4KOwkSUOZpY79aAAXz1GqUtVaWcQT055Ukc7M oXwOGSk0FsJPDm6j/yJ2lOccnC9QZDBzIQADzJ7Q0y9IXqoXlAlAK9MtI4kJOFvo54MY x7qrlIlQEPo9k6fINtxfU3QQN1xatkI1juoRHqteZyu0B5VbKFq5GVoDE07pfFD5lyUR bipg== X-Gm-Message-State: AOUpUlF3AsVvWR0PNfCAF08Ux//2mOyfEiud41UbjVwOIR+AeYnXG1sR 2hlwJJZnbKXgvuTiWJ+HIiTzcKtGHgn5Ig== X-Google-Smtp-Source: AAOMgpdVCTgjPosLF+FtX8U+TJTmVwMC9ZBlFFbcHOL+s+wkms1d0PSA31L+Qz8L+MjlacIZq9tELw== X-Received: by 2002:aca:c40e:: with SMTP id u14-v6mr289141oif.288.1532377262113; Mon, 23 Jul 2018 13:21:02 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id u18-v6sm6621311oiv.10.2018.07.23.13.21.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:21:01 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:17:18 -0500 Message-Id: <20180723201748.25573-70-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::233 Subject: [Qemu-devel] [PATCH 69/99] target/arm: Fix fp_status_f16 tininess before rounding 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: Peter Maydell , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell In commit d81ce0ef2c4f105 we added an extra float_status field fp_status_fp16 for Arm, but forgot to initialize it correctly by setting it to float_tininess_before_rounding. This currently will only cause problems for the new V8_FP16 feature, since the float-to-float conversion code doesn't use it yet. The effect would be that we failed to set the Underflow IEEE exception flag in all the cases where we should. Add the missing initialization. Fixes: d81ce0ef2c4f105 Cc: qemu-stable@nongnu.org Reviewed-by: Richard Henderson Reviewed-by: Alex Bennée Signed-off-by: Peter Maydell Message-id: 20180512004311.9299-16-richard.henderson@linaro.org (cherry picked from commit bcc531f0364796104df4443d17f99b5fb494eca2) Signed-off-by: Michael Roth --- target/arm/cpu.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 022d8c5787..7ebe3fcadf 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -311,6 +311,8 @@ static void arm_cpu_reset(CPUState *s) &env->vfp.fp_status); set_float_detect_tininess(float_tininess_before_rounding, &env->vfp.standard_fp_status); + set_float_detect_tininess(float_tininess_before_rounding, + &env->vfp.fp_status_f16); #ifndef CONFIG_USER_ONLY if (kvm_enabled()) { kvm_arm_reset_vcpu(cpu); From patchwork Mon Jul 23 20:17:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948062 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ROoks/k7"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZDt4334Cz9s3Z for ; Tue, 24 Jul 2018 07:20:28 +1000 (AEST) Received: from localhost ([::1]:36717 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhiFl-0006kg-MB for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 17:20:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42830) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhKM-0003Zm-Eo for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:21:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhKL-0005Db-F0 for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:21:06 -0400 Received: from mail-oi0-x241.google.com ([2607:f8b0:4003:c06::241]:43147) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhKL-0005DM-9j; Mon, 23 Jul 2018 16:21:05 -0400 Received: by mail-oi0-x241.google.com with SMTP id b15-v6so3468875oib.10; Mon, 23 Jul 2018 13:21: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; bh=79FhJ45C6ScQWoWPkygQVM7Ai2fm6uQPtNrO1Wa5grY=; b=ROoks/k7y3PEuh7jvWLp+fKsWOZxK5neSHArAZbYLJF85G03sE8eNFLHSPGrcDRQwR vWNy+C553Xmtwn8uBBBZH+/Gzlp9nHMW679McO8lNhCi7sJih+DfcIXvrbLFbBAgeo9x kyQ0nu9EaYhSyUWFdk50B/PKBK/T6kyLZcBGI9VmIvyZQtoZ/WZqAiyO0no2oD1ESkZ0 03+azVv3IlbuAkIrli3nj8Aag1ci2HkI6cJj/KMkYRdiLjF6P2caCln1wzw14e8GXL9/ dR3VCfujLb8/XGPhr4m70IMiQ/iTqy7cK8ICbZFkX+buozoS/Cs81kLMjhwtQG0z4X0y mX9w== 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=79FhJ45C6ScQWoWPkygQVM7Ai2fm6uQPtNrO1Wa5grY=; b=a/3PAQtduP10rzzyLp0yV/ZJGn8kk2+x74Y++qZNYhRRkYcEEVVEa+1YV6Um/kbJqk oWPKEQIzoWi/2gHLxaiUPlIz6Q+16mPRiFayPc0xaxtT2/nt8x/qpjAP89Y9tpe5tXJ1 VyCyf46W2DvYB/8YZ+jZnWShSlATcMIpc8rc0WLtiM0EnDKMY7ymWCAuvlDop3e22cA7 RdW+BMc031/thws7oHgiX38bRBXkyMZDqAzNRg6bwNvB5ogiroNRcXI+iqOuRBSuKJAu Lkiipq3JOQZJQOQiqLsXTIUsTd1f9wu+zjc4QqYSsDa1vr+RRqfQpyuf1NGu79Egx3Uu TM8g== X-Gm-Message-State: AOUpUlGkkve7FHG5HgcKBauUzP196rUYDhKU2XaW530ejlQ+ta1xUSwf mwA450nkc+VNDtaDZmcUT0jI1PIBLjJLrg== X-Google-Smtp-Source: AAOMgpe00a62yhkki6A1lvLGLgOSudaXNYk068nN1WfLiOllqHbttCzIuveG7W6Ymf9TthRrt+UQHA== X-Received: by 2002:aca:ec46:: with SMTP id k67-v6mr312071oih.81.1532377264164; Mon, 23 Jul 2018 13:21:04 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id a8-v6sm7948945oia.24.2018.07.23.13.21.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:21:03 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:17:19 -0500 Message-Id: <20180723201748.25573-71-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::241 Subject: [Qemu-devel] [PATCH 70/99] fpu/softfloat: Don't set Invalid for float-to-int(MAXINT) 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: Peter Maydell , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell In float-to-integer conversion, if the floating point input converts exactly to the largest or smallest integer that fits in to the result type, this is not an overflow. In this situation we were producing the correct result value, but were incorrectly setting the Invalid flag. For example for Arm A64, "FCVTAS w0, d0" on an input of 0x41dfffffffc00000 should produce 0x7fffffff and set no flags. Fix the boundary case to take the right half of the if() statements. This fixes a regression from 2.11 introduced by the softfloat refactoring. Cc: qemu-stable@nongnu.org Fixes: ab52f973a50 Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20180510140141.12120-1-peter.maydell@linaro.org (cherry picked from commit 333583757c5e910b040bef793974773635ce1918) Signed-off-by: Michael Roth --- fpu/softfloat.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 8401b37bd4..9bcaaebe4f 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -1368,14 +1368,14 @@ static int64_t round_to_int_and_pack(FloatParts in, int rmode, r = UINT64_MAX; } if (p.sign) { - if (r < -(uint64_t) min) { + if (r <= -(uint64_t) min) { return -r; } else { s->float_exception_flags = orig_flags | float_flag_invalid; return min; } } else { - if (r < max) { + if (r <= max) { return r; } else { s->float_exception_flags = orig_flags | float_flag_invalid; From patchwork Mon Jul 23 20:17:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948067 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="jPwfsqR2"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZDxm06L2z9s3Z for ; Tue, 24 Jul 2018 07:23:40 +1000 (AEST) Received: from localhost ([::1]:36744 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhiIr-0000xF-E1 for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 17:23:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42909) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhKT-0003hn-CJ for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:21:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhKQ-0005Fg-6G for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:21:13 -0400 Received: from mail-oi0-x231.google.com ([2607:f8b0:4003:c06::231]:45714) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhKQ-0005FN-0J; Mon, 23 Jul 2018 16:21:10 -0400 Received: by mail-oi0-x231.google.com with SMTP id q11-v6so3454191oic.12; Mon, 23 Jul 2018 13:21:09 -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=eNFiUdYrtj6V8YdcdUftq0s+w+8iqj79jT1PgkeIBzw=; b=jPwfsqR2RhqgOiwa/IqqzXUwVDrNDHr5O0ZqqAy0Ilxj9Sornnoq8iQq7xIsDci+JK Ti8V4xrJTwacFUy/eTTcrKKeDdRmsJSivhZgYBWFUmUd7MOT41JDxoln6nfMfxHEcaLc iXUVCzJcgvwqcpvULwC2ajXHehUC8VkSgN3iW3JL6LINo+3stsIZldWL2enen1YF84I+ ImXmDGzA7Hc5ZaOFfPdr5850gjRni97PLSCDb6ghyyGIl05Gnf8LfLj7DP3DSOqifpVM aOcFcPoyr7br3H65f0exV78ZTnLWgpKYNM2TPUxoEF26gUNQwM/zt0kuQ/gfaItudimk v20w== 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=eNFiUdYrtj6V8YdcdUftq0s+w+8iqj79jT1PgkeIBzw=; b=eM8Ux6PWKh193DSUmrgJXv0oLeFZZ7vmpXdvNXsfzhpSeXQ4fHrFJFpTd9sfwOT/w3 HPLT/Kgxs11gG0LA7MNa5p5EsEgpaFZXS22NJd9DNLOoaEPWJvYNhwgClI3KAEvA3HZk a3ktLU8jwrV3J4eM7PTw5PNpaSULLTIWqFP7SI8j4IepR3jIsFudvDDhxFhbcd6yh+7t 48S14HUm/nuA/npFKKndpapUB7M9CoQAuXTWL4mtMcktW0/5mKsjr0E712cx3Wu0YtPv uzjevum2dbbWEH1o1CG+oMDYyZbdB6WJOi5yU8qyxiL16qeVFuWPDJrm1/6GRYxOQxk8 N/hQ== X-Gm-Message-State: AOUpUlHQ4jvXqwsMk6U+YiLGa4YvxkWBjUnSg7uv3QaEJ0YXxF2FjZA1 OCD5I1FGe6G3/TTpc+AwzqhMPvrV6nF99Q== X-Google-Smtp-Source: AAOMgpegp0Rvs3DiItC8EjQfqlDHGu1VBqLwl8UqQOCsgqqikyNNMaQ3vZBkKRWpYtfQc+y4AAqJhw== X-Received: by 2002:aca:f401:: with SMTP id s1-v6mr292189oih.269.1532377268908; Mon, 23 Jul 2018 13:21:08 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id l204-v6sm6939364oia.45.2018.07.23.13.21.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:21:07 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:17:20 -0500 Message-Id: <20180723201748.25573-72-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::231 Subject: [Qemu-devel] [PATCH 71/99] target/arm: Implement vector shifted SCVF/UCVF for fp16 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: Peter Maydell , Richard Henderson , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson While we have some of the scalar paths for *CVF for fp16, we failed to decode the fp16 version of these instructions. Cc: qemu-stable@nongnu.org Signed-off-by: Richard Henderson Message-id: 20180502221552.3873-2-richard.henderson@linaro.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell (cherry picked from commit a6117fae4576edfe7a5a5b802a742c33112c0993) Signed-off-by: Michael Roth --- target/arm/translate-a64.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index c91329249d..f0fa6045e4 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -7159,13 +7159,26 @@ static void handle_simd_shift_intfp_conv(DisasContext *s, bool is_scalar, int immh, int immb, int opcode, int rn, int rd) { - bool is_double = extract32(immh, 3, 1); - int size = is_double ? MO_64 : MO_32; - int elements; + int size, elements, fracbits; int immhb = immh << 3 | immb; - int fracbits = (is_double ? 128 : 64) - immhb; - if (!extract32(immh, 2, 2)) { + if (immh & 8) { + size = MO_64; + if (!is_scalar && !is_q) { + unallocated_encoding(s); + return; + } + } else if (immh & 4) { + size = MO_32; + } else if (immh & 2) { + size = MO_16; + if (!arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { + unallocated_encoding(s); + return; + } + } else { + /* immh == 0 would be a failure of the decode logic */ + g_assert(immh == 1); unallocated_encoding(s); return; } @@ -7173,20 +7186,14 @@ static void handle_simd_shift_intfp_conv(DisasContext *s, bool is_scalar, if (is_scalar) { elements = 1; } else { - elements = is_double ? 2 : is_q ? 4 : 2; - if (is_double && !is_q) { - unallocated_encoding(s); - return; - } + elements = (8 << is_q) >> size; } + fracbits = (16 << size) - immhb; if (!fp_access_check(s)) { return; } - /* immh == 0 would be a failure of the decode logic */ - g_assert(immh); - handle_simd_intfp_conv(s, rd, rn, elements, !is_u, fracbits, size); } From patchwork Mon Jul 23 20:17:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948068 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Ip7x2sTS"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZDyj0jYKz9s3N for ; Tue, 24 Jul 2018 07:24:29 +1000 (AEST) Received: from localhost ([::1]:36749 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhiJe-0001e7-Il for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 17:24:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42924) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhKU-0003iR-23 for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:21:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhKS-0005Gj-OT for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:21:14 -0400 Received: from mail-oi0-x22c.google.com ([2607:f8b0:4003:c06::22c]:39355) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhKS-0005GR-HJ; Mon, 23 Jul 2018 16:21:12 -0400 Received: by mail-oi0-x22c.google.com with SMTP id d189-v6so3486480oib.6; Mon, 23 Jul 2018 13:21:12 -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=oQgVzzLW/AKZnSBdmcngVIFMbjpCsGBPKm5s95XcOIA=; b=Ip7x2sTSV6hxgjoBfiyCMEeRDW6iIu2tUCViLCFMCgTFmF4TMx7aP6lQlaTvnTd7IY j607RreVB+lhLr4qTGMnwFYocpGfQzu8Rcvm68wRtHxmHhUKduQiL2H7E/7+wNZWy/OI xr8zOlYImn3K9ZNZ3+9uhoJ0jvzkqGgz7UNgLogr0ik+/QvYaPlm6440cr9QEOOr3RyZ a1cX2HZsmnUc5kQIoH14OlVUbrJmOHuCm3EelFxitE2sfbYE4I2IzdrB2u27cQfiPAih WgVxZl6dlmi8pGtvR5SEFbWqF37VE46aL9+xyjsTHk9Lz2wMRvPK1GVpT1voYuhZC362 NzYA== 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=oQgVzzLW/AKZnSBdmcngVIFMbjpCsGBPKm5s95XcOIA=; b=shBd+iTv04eC+A4pbI68yvjedo+wO7OsNzE31m8wgQD1514yjDbDCpaPt9M2Cp2NS6 4rrEAjSmoo4ETlshBv1ftGQ/YxM9/4XxviOB5QjTXtq+MRa7immnuEaI/yVofFv38s7i hjyS8xp72eKCy9vq6MyjrFrDDbAI86W0LfJ/WZk0rfqncW930HPxILzzglqap4lgTY5n lQD9efwnjgU9oukWpAZLFRnfVbLHFtM9drSg9kujTfuDeuuqS/iNGOUyQKxnDrx5OGtl 4icWGN4VhcURZfbe0ET8w0LG4vgqW/WIETXXF7yfqt6nDF9ZkoSU3kyXsGjjHWPrz0KH HHXg== X-Gm-Message-State: AOUpUlEhGnRYJfJbFH/+eQbQtg+jtXfDDD1HXo9HayNLvQQ2aC5X52g4 byVB79K3vvFRnppHQ6sET7MvDH8p5K/UZw== X-Google-Smtp-Source: AAOMgpcneXDKGzdd4p+42ZJvvnWOyBRmoG6TSSyB0hViktGcubwbpKCbRR6Cwd7CyKv3WzpiTWdEsQ== X-Received: by 2002:aca:dbc2:: with SMTP id s185-v6mr259183oig.251.1532377271394; Mon, 23 Jul 2018 13:21:11 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id x126-v6sm5000488oig.15.2018.07.23.13.21.09 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:21:10 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:17:21 -0500 Message-Id: <20180723201748.25573-73-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::22c Subject: [Qemu-devel] [PATCH 72/99] target/arm: Implement vector shifted FCVT for fp16 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: Peter Maydell , Richard Henderson , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson While we have some of the scalar paths for FCVT for fp16, we failed to decode the fp16 version of these instructions. Cc: qemu-stable@nongnu.org Signed-off-by: Richard Henderson Message-id: 20180502221552.3873-3-richard.henderson@linaro.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell (cherry picked from commit d0ba8e74acd299b092786ffc30b306638d395a9e) Signed-off-by: Michael Roth --- target/arm/translate-a64.c | 63 +++++++++++++++++++++++++++----------- 1 file changed, 45 insertions(+), 18 deletions(-) diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index f0fa6045e4..61735dc185 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -7202,19 +7202,28 @@ static void handle_simd_shift_fpint_conv(DisasContext *s, bool is_scalar, bool is_q, bool is_u, int immh, int immb, int rn, int rd) { - bool is_double = extract32(immh, 3, 1); int immhb = immh << 3 | immb; - int fracbits = (is_double ? 128 : 64) - immhb; - int pass; + int pass, size, fracbits; TCGv_ptr tcg_fpstatus; TCGv_i32 tcg_rmode, tcg_shift; - if (!extract32(immh, 2, 2)) { - unallocated_encoding(s); - return; - } - - if (!is_scalar && !is_q && is_double) { + if (immh & 0x8) { + size = MO_64; + if (!is_scalar && !is_q) { + unallocated_encoding(s); + return; + } + } else if (immh & 0x4) { + size = MO_32; + } else if (immh & 0x2) { + size = MO_16; + if (!arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { + unallocated_encoding(s); + return; + } + } else { + /* Should have split out AdvSIMD modified immediate earlier. */ + assert(immh == 1); unallocated_encoding(s); return; } @@ -7226,11 +7235,12 @@ static void handle_simd_shift_fpint_conv(DisasContext *s, bool is_scalar, assert(!(is_scalar && is_q)); tcg_rmode = tcg_const_i32(arm_rmode_to_sf(FPROUNDING_ZERO)); - tcg_fpstatus = get_fpstatus_ptr(false); + tcg_fpstatus = get_fpstatus_ptr(size == MO_16); gen_helper_set_rmode(tcg_rmode, tcg_rmode, tcg_fpstatus); + fracbits = (16 << size) - immhb; tcg_shift = tcg_const_i32(fracbits); - if (is_double) { + if (size == MO_64) { int maxpass = is_scalar ? 1 : 2; for (pass = 0; pass < maxpass; pass++) { @@ -7247,20 +7257,37 @@ static void handle_simd_shift_fpint_conv(DisasContext *s, bool is_scalar, } clear_vec_high(s, is_q, rd); } else { - int maxpass = is_scalar ? 1 : is_q ? 4 : 2; - for (pass = 0; pass < maxpass; pass++) { - TCGv_i32 tcg_op = tcg_temp_new_i32(); + void (*fn)(TCGv_i32, TCGv_i32, TCGv_i32, TCGv_ptr); + int maxpass = is_scalar ? 1 : ((8 << is_q) >> size); - read_vec_element_i32(s, tcg_op, rn, pass, MO_32); + switch (size) { + case MO_16: + if (is_u) { + fn = gen_helper_vfp_toulh; + } else { + fn = gen_helper_vfp_toslh; + } + break; + case MO_32: if (is_u) { - gen_helper_vfp_touls(tcg_op, tcg_op, tcg_shift, tcg_fpstatus); + fn = gen_helper_vfp_touls; } else { - gen_helper_vfp_tosls(tcg_op, tcg_op, tcg_shift, tcg_fpstatus); + fn = gen_helper_vfp_tosls; } + break; + default: + g_assert_not_reached(); + } + + for (pass = 0; pass < maxpass; pass++) { + TCGv_i32 tcg_op = tcg_temp_new_i32(); + + read_vec_element_i32(s, tcg_op, rn, pass, size); + fn(tcg_op, tcg_op, tcg_shift, tcg_fpstatus); if (is_scalar) { write_fp_sreg(s, rd, tcg_op); } else { - write_vec_element_i32(s, tcg_op, rd, pass, MO_32); + write_vec_element_i32(s, tcg_op, rd, pass, size); } tcg_temp_free_i32(tcg_op); } From patchwork Mon Jul 23 20:17:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948072 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="i9QYhJA8"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZF1K3ZYfz9s3N for ; Tue, 24 Jul 2018 07:26:45 +1000 (AEST) Received: from localhost ([::1]:36767 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhiLr-0003hr-2P for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 17:26:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42955) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhKW-0003kj-Ba for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:21:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhKV-0005Hd-1k for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:21:16 -0400 Received: from mail-oi0-x241.google.com ([2607:f8b0:4003:c06::241]:33593) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhKU-0005HP-Qq; Mon, 23 Jul 2018 16:21:14 -0400 Received: by mail-oi0-x241.google.com with SMTP id l10-v6so3506629oii.0; Mon, 23 Jul 2018 13:21:14 -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=EAAvhRG8C54tuD9t5OWl5Oz5gtLAuNU9fBik2fQBfos=; b=i9QYhJA8myxOL6pHdntg9tDJu3YeDv3eBLkR8rNKL54/Xw6XVxlTwVAJmCxhE8I1YQ MvhYqVdFU1HbCt1slUvnKG5neHyX0YD/SEZKOinSboJD2UnA7eOqgErLQNOuKtAaej+I TH9DRi2idC1jN7Qc6qqraYuKgZ4YZfTKfJerwKgR6xcg6JotmG6b35fT/ebAxzYiPU9X hrcOK12+xhYLtY97ZPHtAgZcQsUwmg5D0NvDU1y+lN7+jazBTqrh3bq+B6eVpRcGBI2Z J5r9OEy3FLPmx/FllPtrfaKlZmn3aDWFdfYzUWsfw0Z+3W6hbys0sCUF0nSJlIdoeizD gjhQ== 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=EAAvhRG8C54tuD9t5OWl5Oz5gtLAuNU9fBik2fQBfos=; b=qwivXi6ZXmj59suiXSkLxniI7n1sritkte8fngNXRImjRqGf4JHsviLwpKbb5sYWld UmNeUSrOKKUTLikqvyCsVYoOFXe9t3i76CICDSbHPtjWnEM2qoUXSvWuakSfPvM9LMJY YA6Gy9llOt2CCN5Cw/fMqbtpjZ0cVyKMw08zOdKnEF+0YitFRJRq1wCzKPYBJyp4zUFn QT2PSUsjfGaTjRmp4dfWsWowKH8oWLhEgs58M5xzcaEgcCR67+PwxubgRGhV0OoP4ZVf A35EqSv3mtY07BmVpsoetrmT6K9hcIGSqdEhicAi4r2ZLOclsv8SHzjAAUCp4onrn8sB Nm0A== X-Gm-Message-State: AOUpUlF6ZFmSRJPg9aMA13ZbSZO7NAbMuQitRW1FG9IPkdDw+WWfgRST jwgzYVm4SjnYGmZPFgj9D6K7nl1TbThpxg== X-Google-Smtp-Source: AAOMgpcDKawUL3D2GyDgySpd3Zcw3wx8k8924WyjHpCZYr+INGteBlZ0woouTcYYt6pPUQFuRzoHsQ== X-Received: by 2002:aca:5003:: with SMTP id e3-v6mr315979oib.89.1532377273609; Mon, 23 Jul 2018 13:21:13 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id t131-v6sm8734870oie.34.2018.07.23.13.21.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:21:12 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:17:22 -0500 Message-Id: <20180723201748.25573-74-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::241 Subject: [Qemu-devel] [PATCH 73/99] target/arm: Fix float16 to/from int16 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: Peter Maydell , Richard Henderson , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson The instruction "ucvtf v0.4h, v04h, #2", with input 0x8000u, overflows the intermediate float16 to infinity before we have a chance to scale the output. Use float64 as the intermediate type so that no input argument (uint32_t in this case) can overflow or round before scaling. Given the declared argument, the signed int32_t function has the same problem. When converting from float16 to integer, using u/int32_t instead of u/int16_t means that the bounding is incorrect. Cc: qemu-stable@nongnu.org Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Message-id: 20180502221552.3873-4-richard.henderson@linaro.org Signed-off-by: Peter Maydell (cherry picked from commit 88808a022c06f98d81cd3f2d105a5734c5614839) Signed-off-by: Michael Roth --- target/arm/helper.c | 53 ++++++++++++++++++++++++++++++++++++-- target/arm/helper.h | 4 +-- target/arm/translate-a64.c | 4 +-- 3 files changed, 55 insertions(+), 6 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index b14fdab140..c07c1d7f48 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11409,11 +11409,60 @@ VFP_CONV_FIX_A64(sq, s, 32, 64, int64) VFP_CONV_FIX(uh, s, 32, 32, uint16) VFP_CONV_FIX(ul, s, 32, 32, uint32) VFP_CONV_FIX_A64(uq, s, 32, 64, uint64) -VFP_CONV_FIX_A64(sl, h, 16, 32, int32) -VFP_CONV_FIX_A64(ul, h, 16, 32, uint32) + #undef VFP_CONV_FIX #undef VFP_CONV_FIX_FLOAT #undef VFP_CONV_FLOAT_FIX_ROUND +#undef VFP_CONV_FIX_A64 + +/* Conversion to/from f16 can overflow to infinity before/after scaling. + * Therefore we convert to f64 (which does not round), scale, + * and then convert f64 to f16 (which may round). + */ + +static float16 do_postscale_fp16(float64 f, int shift, float_status *fpst) +{ + return float64_to_float16(float64_scalbn(f, -shift, fpst), true, fpst); +} + +float16 HELPER(vfp_sltoh)(uint32_t x, uint32_t shift, void *fpst) +{ + return do_postscale_fp16(int32_to_float64(x, fpst), shift, fpst); +} + +float16 HELPER(vfp_ultoh)(uint32_t x, uint32_t shift, void *fpst) +{ + return do_postscale_fp16(uint32_to_float64(x, fpst), shift, fpst); +} + +static float64 do_prescale_fp16(float16 f, int shift, float_status *fpst) +{ + if (unlikely(float16_is_any_nan(f))) { + float_raise(float_flag_invalid, fpst); + return 0; + } else { + int old_exc_flags = get_float_exception_flags(fpst); + float64 ret; + + ret = float16_to_float64(f, true, fpst); + ret = float64_scalbn(ret, shift, fpst); + old_exc_flags |= get_float_exception_flags(fpst) + & float_flag_input_denormal; + set_float_exception_flags(old_exc_flags, fpst); + + return ret; + } +} + +uint32_t HELPER(vfp_toshh)(float16 x, uint32_t shift, void *fpst) +{ + return float64_to_int16(do_prescale_fp16(x, shift, fpst), fpst); +} + +uint32_t HELPER(vfp_touhh)(float16 x, uint32_t shift, void *fpst) +{ + return float64_to_uint16(do_prescale_fp16(x, shift, fpst), fpst); +} /* Set the current fp rounding mode and return the old one. * The argument is a softfloat float_round_ value. diff --git a/target/arm/helper.h b/target/arm/helper.h index 34e8cc8904..1969b37f2d 100644 --- a/target/arm/helper.h +++ b/target/arm/helper.h @@ -149,8 +149,8 @@ DEF_HELPER_3(vfp_toshd_round_to_zero, i64, f64, i32, ptr) DEF_HELPER_3(vfp_tosld_round_to_zero, i64, f64, i32, ptr) DEF_HELPER_3(vfp_touhd_round_to_zero, i64, f64, i32, ptr) DEF_HELPER_3(vfp_tould_round_to_zero, i64, f64, i32, ptr) -DEF_HELPER_3(vfp_toulh, i32, f16, i32, ptr) -DEF_HELPER_3(vfp_toslh, i32, f16, i32, ptr) +DEF_HELPER_3(vfp_touhh, i32, f16, i32, ptr) +DEF_HELPER_3(vfp_toshh, i32, f16, i32, ptr) DEF_HELPER_3(vfp_toshs, i32, f32, i32, ptr) DEF_HELPER_3(vfp_tosls, i32, f32, i32, ptr) DEF_HELPER_3(vfp_tosqs, i64, f32, i32, ptr) diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 61735dc185..3c4c9b9fdc 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -7263,9 +7263,9 @@ static void handle_simd_shift_fpint_conv(DisasContext *s, bool is_scalar, switch (size) { case MO_16: if (is_u) { - fn = gen_helper_vfp_toulh; + fn = gen_helper_vfp_touhh; } else { - fn = gen_helper_vfp_toslh; + fn = gen_helper_vfp_toshh; } break; case MO_32: From patchwork Mon Jul 23 20:17:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948056 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="X7PtdSc2"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZDnD6MjJz9s3N for ; Tue, 24 Jul 2018 07:16:16 +1000 (AEST) Received: from localhost ([::1]:36697 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhiBi-0002ry-GR for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 17:16:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42986) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhKZ-0003nN-Av for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:21:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhKY-0005J0-BC for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:21:19 -0400 Received: from mail-oi0-x229.google.com ([2607:f8b0:4003:c06::229]:43125) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhKY-0005Ik-6B; Mon, 23 Jul 2018 16:21:18 -0400 Received: by mail-oi0-x229.google.com with SMTP id b15-v6so3470027oib.10; Mon, 23 Jul 2018 13:21:18 -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=5EtukpyyXUOV7ONYgbqzmLjH+V7MTKyMAm/HcGek7mk=; b=X7PtdSc2ReX4Et6Liv8KRz+LO1qLZ9a8msaDEyE9QbMXJxne/WMxf59Dhk2+GtvQPK e7GZCIHVhMmx5FkBqkohY4aHhS328wIoP9KmG09GJPo9nN/xtrNCvLVNlY4jxfmYniUn lWbWwNMTQbxNb9wjN5RORQXr09tGPkI3Sg4W9S0GzsDVR+22He+Fql/9ASUBgf4wL2+z 3V5Iyx/tcklfuDXSN4goaeUZL4Hg88JSSExAqqiYExQLoCk4Wkm8J6LY5fpNQYnVipej UmRJbbkdantZrEqIYrwMyvqfu3ua5wP+cLPXpVtmM86vonj1PaBacTSZG5ihqTWmMKyZ zZUQ== 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=5EtukpyyXUOV7ONYgbqzmLjH+V7MTKyMAm/HcGek7mk=; b=PBlWYsYfjIL688oZs23qDSjn1v2j/o70yozh3ODnzvrVGm2vzEgzFtICLajP/jY6av Jkb+9IVdSR8Pu7IoPkD2HSQa1xG9Q8/8ib95dlnnb7SMVd6vmEtvYP+K47cBhuY78Cvp NvJgVcZMYlNOPR1iOLGL8WsDAb5ISDJf8b2U19GPmwHl0DMAwVy7V8RCLgy7+MsSqeA8 WHAwK3FAjjF+Wbok+nAEQ1gqyt2w8+T6Z2AqEWZ0j53hdmKDYDGhdmB7DLn1F4NTxl5A LddJjPiGY5pdhjzXoCfNJZsTycr3frGAmDyZwdDl4o4ddpFlMnclMYxWArg2mK5h4PUP Bujw== X-Gm-Message-State: AOUpUlFO8asVztM8MGnulaK/O8BMInPF6PV2xsZSZV3Cs/pjpLDVtqz1 1QiGXa8udJ79P+jO8LINnR48tk9ORwDPgg== X-Google-Smtp-Source: AAOMgpfv1WvIxTCONxJA5nPauZujBLWHgqIV++FuBIPzQ73q0kkRCOt6+T0RO3XrUPmVnmKqvH3MPA== X-Received: by 2002:aca:1b11:: with SMTP id b17-v6mr307593oib.178.1532377275864; Mon, 23 Jul 2018 13:21:15 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id o206-v6sm8223354oif.7.2018.07.23.13.21.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:21:14 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:17:23 -0500 Message-Id: <20180723201748.25573-75-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::229 Subject: [Qemu-devel] [PATCH 74/99] target/arm: Clear SVE high bits for FMOV 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: Peter Maydell , Richard Henderson , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Use write_fp_dreg and clear_vec_high to zero the bits that need zeroing for these cases. Cc: qemu-stable@nongnu.org Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Message-id: 20180502221552.3873-5-richard.henderson@linaro.org Signed-off-by: Peter Maydell (cherry picked from commit 9a9f1f59521f46e8ff4527d9a2b52f83577e2aa3) Signed-off-by: Michael Roth --- target/arm/translate-a64.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 3c4c9b9fdc..639cd95772 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -5438,31 +5438,24 @@ static void handle_fmov(DisasContext *s, int rd, int rn, int type, bool itof) if (itof) { TCGv_i64 tcg_rn = cpu_reg(s, rn); + TCGv_i64 tmp; switch (type) { case 0: - { /* 32 bit */ - TCGv_i64 tmp = tcg_temp_new_i64(); + tmp = tcg_temp_new_i64(); tcg_gen_ext32u_i64(tmp, tcg_rn); - tcg_gen_st_i64(tmp, cpu_env, fp_reg_offset(s, rd, MO_64)); - tcg_gen_movi_i64(tmp, 0); - tcg_gen_st_i64(tmp, cpu_env, fp_reg_hi_offset(s, rd)); + write_fp_dreg(s, rd, tmp); tcg_temp_free_i64(tmp); break; - } case 1: - { /* 64 bit */ - TCGv_i64 tmp = tcg_const_i64(0); - tcg_gen_st_i64(tcg_rn, cpu_env, fp_reg_offset(s, rd, MO_64)); - tcg_gen_st_i64(tmp, cpu_env, fp_reg_hi_offset(s, rd)); - tcg_temp_free_i64(tmp); + write_fp_dreg(s, rd, tcg_rn); break; - } case 2: /* 64 bit to top half. */ tcg_gen_st_i64(tcg_rn, cpu_env, fp_reg_hi_offset(s, rd)); + clear_vec_high(s, true, rd); break; } } else { From patchwork Mon Jul 23 20:17:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948078 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="qeAzSBy3"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZF2J4X0xz9s3Z for ; Tue, 24 Jul 2018 07:27:36 +1000 (AEST) Received: from localhost ([::1]:36772 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhiMg-0004Tx-6B for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 17:27:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43019) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhKc-0003oS-EU for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:21:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhKZ-0005JV-CW for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:21:22 -0400 Received: from mail-oi0-x244.google.com ([2607:f8b0:4003:c06::244]:41190) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhKZ-0005JE-7E; Mon, 23 Jul 2018 16:21:19 -0400 Received: by mail-oi0-x244.google.com with SMTP id k12-v6so3469388oiw.8; Mon, 23 Jul 2018 13:21:19 -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=0eWGZUjdYHS8DbjInkKruRTzzxqxsVA0NX9o2ecCaEQ=; b=qeAzSBy343dbAF41NVVWms+hlQB7yjrZSj6eP1iFFL+9vfoddfxDJFHdVQuNXclgQH btJ9L4fgYGfus8Hng6ehX/f0YBMinWIjAy4zCP+XVWD0kwe8G2C4QlUAJVOtmv7RWeIO 1XBDSwodbjhw4kK5J1HTZ8RAKbHQYZbpQRYKXVvq5p3VhsjU38O94dsv9KmNlV8o2Rv/ gM0MASjWUswTgxoEbvZyLmj4yTfYRyjwJY0c3ou8deHC8E+Uskib39zkOLD+yFtByihw uf6cJPd1pd8JeoW+b4+o10qPW0ZzDcNMKpv6XexVzGbCG6+L/Xpd7oNfSNMev/Kqhz2n LJbw== 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=0eWGZUjdYHS8DbjInkKruRTzzxqxsVA0NX9o2ecCaEQ=; b=AQ7OQIKu9qjymJ/UyKUrJqf/D46qQ5PSGf7s/KsLMN3DSozpJS6KMfgfAd+p5T8z6W F0OMYNZau77Fk1WGAQlwZ+rRb6ziCTxBp8RM7Yrd7pu0wBcJAFHQ4MLpg9vFKRCkKnlK Aj/yPaLGkHcv8tnsoWBZ3+U16+ToDjEMUIkumdthhssvlQyd1The4iLASH4EwFA8lnoE pYWy7zTtyzMEVAHhEg8ImIAD99QhXw+d7qzRqNbOrIoUTHvPYZZObzMzH2+Ur/NwXcdD PlVBFXzAAIgRDDv8QVqC0Nq0riDV546d8S5aVB/4yHV5CDP4WcXa+rPAIB+qj5U4TDWb Jutg== X-Gm-Message-State: AOUpUlElbj7I9oQA6ii2FNYDq53h1AiMB6TliQGRYJT8BV0DB9nVBwnI ce6LKu2FD78y3QfeX5eANaRMWLA3eM63BA== X-Google-Smtp-Source: AAOMgpc/7HXWqTYH9yDth6i2tleYGGOJ2JvBIWnJrC8VcsxmjBcJhZPFooKkrCyPRT5j7VZlebzq8Q== X-Received: by 2002:aca:560d:: with SMTP id k13-v6mr312577oib.190.1532377278061; Mon, 23 Jul 2018 13:21:18 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id f75-v6sm17900876oig.53.2018.07.23.13.21.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:21:17 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:17:24 -0500 Message-Id: <20180723201748.25573-76-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::244 Subject: [Qemu-devel] [PATCH 75/99] fpu/softfloat: Fix conversion from uint64 to float128 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: Richard Henderson , qemu-stable@nongnu.org, Petr Tesarik Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Petr Tesarik The significand is passed to normalizeRoundAndPackFloat128() as high first, low second. The current code passes the integer first, so the result is incorrectly shifted left by 64 bits. This bug affects the emulation of s390x instruction CXLGBR (convert from logical 64-bit binary-integer operand to extended BFP result). Cc: qemu-stable@nongnu.org Tested-by: Alex Bennée Reviewed-by: Alex Bennée Reviewed-by: Peter Maydell Signed-off-by: Petr Tesarik Message-Id: <20180511071052.1443-1-ptesarik@suse.com> Signed-off-by: Richard Henderson (cherry picked from commit 6603d50648901e8b9e6d66ec1142accf0b1df1e6) Signed-off-by: Michael Roth --- fpu/softfloat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 9bcaaebe4f..a926b91864 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -3147,7 +3147,7 @@ float128 uint64_to_float128(uint64_t a, float_status *status) if (a == 0) { return float128_zero; } - return normalizeRoundAndPackFloat128(0, 0x406E, a, 0, status); + return normalizeRoundAndPackFloat128(0, 0x406E, 0, a, status); } From patchwork Mon Jul 23 20:17:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948083 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="I28VJK9k"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZF4l0M8qz9s3N for ; Tue, 24 Jul 2018 07:29:43 +1000 (AEST) Received: from localhost ([::1]:36785 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhiOi-0006KD-EP for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 17:29:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43018) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhKc-0003oR-Dr for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:21:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhKb-0005KA-GG for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:21:22 -0400 Received: from mail-oi0-x230.google.com ([2607:f8b0:4003:c06::230]:33590) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhKb-0005K4-A4; Mon, 23 Jul 2018 16:21:21 -0400 Received: by mail-oi0-x230.google.com with SMTP id l10-v6so3507163oii.0; Mon, 23 Jul 2018 13:21:21 -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=Fl9uEjw1xc2dKDewX9QPdz6gea0SzgkVpH8oMMWOvRQ=; b=I28VJK9knH/01UrpGOJNNUM/a+h3j7uEgzBH5qCVnBpjvjuqubRJTjz4m12Ir9vvBX WOVrYVERHKjj4K43g/l5AENAWj6moY6AW06uOj6Cef+BmWeIzqYtroaK9SlETTFdexh3 dgQaiRVdS4aGHqB6g/TgMnT9ujEaLPFgfaH/LzfkHJwm1t3jiELRCYjBl7kXa1bzIpYa Tlr6R9gsCW13/1q5iTHjY4oOG36ObUYE7iK/uGNPoyW9et0GfyPO9S6bdibIAhmfrkgv vWC4w6goszLKdlFmNp7IPlMbTTnCiJ+LzvpR/nB61Jt4pkWfkzBTodrWgTpgYcCcwjdP Se3A== 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=Fl9uEjw1xc2dKDewX9QPdz6gea0SzgkVpH8oMMWOvRQ=; b=N+Ea3CTm81/4/rk/lEwatSWjhoPx5vSpzaHVhl4t3Pr4r6TvtM/sEZdRYzXLdUDhS+ Aof/leBd4pm1N4+j1w6c06N9SI2eHJZ+EHBjMmD6siavkqLsEVrg84hS3BNWyqCP19EN 3FDUzRuSHyGZbOdPQ02TEPLJ4oocRItcavyOiQuvfkTa/godABYRQqkjJtbV2VTidu/p ZTikyPLrUbPqnBKJng1qrQXO8ZrOVFqnMCeUoJOLUr9hBkVDdjVNlXypoO+LzYlJwkXK SuoFCcHHE+cO6wdj4fiE1xKKXMWgIcoLzn3F8TRauprBZWkBUKOvhzYaEuSJyicNH7wg zzLw== X-Gm-Message-State: AOUpUlGVMvDG2P6JcG3zPc9M3um9+FP09q2vaKVOcDZEud2BJEF0ERZG 9p6aY4XSu4Q2gGmGOx3jiIwskJkYboeMuw== X-Google-Smtp-Source: AAOMgpeUdS5p1p2TrL9pIA4Oy+1gPeFXii/XHkFFlYDBfJQmg+uLQNU+5aEbwjKkHAmeVefuN6J59w== X-Received: by 2002:aca:a94c:: with SMTP id s73-v6mr320905oie.68.1532377280129; Mon, 23 Jul 2018 13:21:20 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id v5-v6sm1203124oix.36.2018.07.23.13.21.18 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:21:19 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:17:25 -0500 Message-Id: <20180723201748.25573-77-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::230 Subject: [Qemu-devel] [PATCH 76/99] target/arm: Implement FMOV (general) for fp16 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: Peter Maydell , Richard Henderson , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Adding the fp16 moves to/from general registers. Cc: qemu-stable@nongnu.org Signed-off-by: Richard Henderson Tested-by: Alex Bennée Message-id: 20180512003217.9105-2-richard.henderson@linaro.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell (cherry picked from commit 68130236e30a1ec64363f4915349feee181bfbc1) Signed-off-by: Michael Roth --- target/arm/translate-a64.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 639cd95772..b05f9bfe91 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -5457,6 +5457,15 @@ static void handle_fmov(DisasContext *s, int rd, int rn, int type, bool itof) tcg_gen_st_i64(tcg_rn, cpu_env, fp_reg_hi_offset(s, rd)); clear_vec_high(s, true, rd); break; + case 3: + /* 16 bit */ + tmp = tcg_temp_new_i64(); + tcg_gen_ext16u_i64(tmp, tcg_rn); + write_fp_dreg(s, rd, tmp); + tcg_temp_free_i64(tmp); + break; + default: + g_assert_not_reached(); } } else { TCGv_i64 tcg_rd = cpu_reg(s, rd); @@ -5474,6 +5483,12 @@ static void handle_fmov(DisasContext *s, int rd, int rn, int type, bool itof) /* 64 bits from top half */ tcg_gen_ld_i64(tcg_rd, cpu_env, fp_reg_hi_offset(s, rn)); break; + case 3: + /* 16 bit */ + tcg_gen_ld16u_i64(tcg_rd, cpu_env, fp_reg_offset(s, rn, MO_16)); + break; + default: + g_assert_not_reached(); } } } @@ -5513,6 +5528,12 @@ static void disas_fp_int_conv(DisasContext *s, uint32_t insn) case 0xa: /* 64 bit */ case 0xd: /* 64 bit to top half of quad */ break; + case 0x6: /* 16-bit float, 32-bit int */ + case 0xe: /* 16-bit float, 64-bit int */ + if (arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { + break; + } + /* fallthru */ default: /* all other sf/type/rmode combinations are invalid */ unallocated_encoding(s); From patchwork Mon Jul 23 20:17:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948084 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="jeRJCdyv"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZF635Jnzz9s3Z for ; Tue, 24 Jul 2018 07:30:51 +1000 (AEST) Received: from localhost ([::1]:36791 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhiPp-0007Gy-DZ for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 17:30:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43091) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhKf-0003rc-H6 for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:21:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhKd-0005LW-Tk for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:21:25 -0400 Received: from mail-oi0-x241.google.com ([2607:f8b0:4003:c06::241]:42738) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhKd-0005L1-L4; Mon, 23 Jul 2018 16:21:23 -0400 Received: by mail-oi0-x241.google.com with SMTP id n84-v6so3472600oib.9; Mon, 23 Jul 2018 13:21:23 -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=FdarBSs+mctGDElKHbhV5ZEMxApRQE8DJ91JheNMCxs=; b=jeRJCdyv5wsTuKpnPvL16A99L13SgRYF7I4hg5E4T2AFIPvM6eXM9+mUNAf/U7Sc+t oYYfaOe5d8yYC6sZ+0Z7Hz0K3lDqjxCfnOdGjPTBhpG4CxYbA3xpEDHL/1QoIKoHR6nR 1XgAvfJ3YmS3wCKa7HvSKK/RPFuwjZSzDADAA6HgaEY2ub/I9PVWZrUflui4548TpJXG hK6Sx/rLUtW7xWKIcrus4y5V/nAH1T6YgFD+UN6PAuuIvKEFqRgj0nXJmFEiZQvDEqKf /2UQtmaaowBlreflrfZ3xxdejZDjotkfVy5vtsvLgagdwiiSioeVpPOVsfn+bQdKq96c wl1g== 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=FdarBSs+mctGDElKHbhV5ZEMxApRQE8DJ91JheNMCxs=; b=iok7FnzVtlHE/t/JHHz+Y0R7SHM8TRIGB+1fPkW9p0HB7QA5GPdfGHTyo6AbLVHnXo ml0mc3AmqaVgCFTc9PD+/lvKFQCZO+TWEGyBXOZx3aynkVmfxN53Yzh9MirC1JHtnv46 4McDNfpabDq7J5m6yIuYoy1ImSPLWPoDzCYk9whpBuSSjsaNkbnP4QMhoxJjJhv1RF7s CkIBRfQVPInMGplzCFQ4DaLSjdADvR6Ye7q7z7xYsEPkF117O3siHZHbAMtP+jocOQUA 2uCve/oVWigz2eU80u4I1JBJl7miH8XjCE5/JFW10rGvTxuLB70h0J2fdNBlZowZYVDJ dXCQ== X-Gm-Message-State: AOUpUlHzdQthORwKdgxmBAEt55dGZSPhLyHpjw8/aR+wfsX1Q+jn5+B9 Bjrapnvk9XiMhrCCRxsEMzHhbOz80MRgng== X-Google-Smtp-Source: AAOMgpd2HeC0H7bfpCdNrXzIvvQIMWPyJxxVEfTbpFzZAuOdbKUK+VZPqQYlCUs9uPiUNq1FfiLrnQ== X-Received: by 2002:aca:dc08:: with SMTP id t8-v6mr340065oig.226.1532377282407; Mon, 23 Jul 2018 13:21:22 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id e125-v6sm9839232oig.4.2018.07.23.13.21.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:21:21 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:17:26 -0500 Message-Id: <20180723201748.25573-78-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::241 Subject: [Qemu-devel] [PATCH 77/99] target/arm: Implement FCVT (scalar, integer) for fp16 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: Peter Maydell , Richard Henderson , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Cc: qemu-stable@nongnu.org Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Tested-by: Alex Bennée Message-id: 20180512003217.9105-4-richard.henderson@linaro.org Signed-off-by: Peter Maydell (cherry picked from commit 564a0632504fad840491aa9a59453f4e64a316c4) Signed-off-by: Michael Roth --- target/arm/helper.c | 38 ++++++++++++++- target/arm/helper.h | 6 +++ target/arm/translate-a64.c | 96 +++++++++++++++++++++++++++++++------- 3 files changed, 122 insertions(+), 18 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index c07c1d7f48..1043d6ed32 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11416,8 +11416,12 @@ VFP_CONV_FIX_A64(uq, s, 32, 64, uint64) #undef VFP_CONV_FIX_A64 /* Conversion to/from f16 can overflow to infinity before/after scaling. - * Therefore we convert to f64 (which does not round), scale, - * and then convert f64 to f16 (which may round). + * Therefore we convert to f64, scale, and then convert f64 to f16; or + * vice versa for conversion to integer. + * + * For 16- and 32-bit integers, the conversion to f64 never rounds. + * For 64-bit integers, any integer that would cause rounding will also + * overflow to f16 infinity, so there is no double rounding problem. */ static float16 do_postscale_fp16(float64 f, int shift, float_status *fpst) @@ -11435,6 +11439,16 @@ float16 HELPER(vfp_ultoh)(uint32_t x, uint32_t shift, void *fpst) return do_postscale_fp16(uint32_to_float64(x, fpst), shift, fpst); } +float16 HELPER(vfp_sqtoh)(uint64_t x, uint32_t shift, void *fpst) +{ + return do_postscale_fp16(int64_to_float64(x, fpst), shift, fpst); +} + +float16 HELPER(vfp_uqtoh)(uint64_t x, uint32_t shift, void *fpst) +{ + return do_postscale_fp16(uint64_to_float64(x, fpst), shift, fpst); +} + static float64 do_prescale_fp16(float16 f, int shift, float_status *fpst) { if (unlikely(float16_is_any_nan(f))) { @@ -11464,6 +11478,26 @@ uint32_t HELPER(vfp_touhh)(float16 x, uint32_t shift, void *fpst) return float64_to_uint16(do_prescale_fp16(x, shift, fpst), fpst); } +uint32_t HELPER(vfp_toslh)(float16 x, uint32_t shift, void *fpst) +{ + return float64_to_int32(do_prescale_fp16(x, shift, fpst), fpst); +} + +uint32_t HELPER(vfp_toulh)(float16 x, uint32_t shift, void *fpst) +{ + return float64_to_uint32(do_prescale_fp16(x, shift, fpst), fpst); +} + +uint64_t HELPER(vfp_tosqh)(float16 x, uint32_t shift, void *fpst) +{ + return float64_to_int64(do_prescale_fp16(x, shift, fpst), fpst); +} + +uint64_t HELPER(vfp_touqh)(float16 x, uint32_t shift, void *fpst) +{ + return float64_to_uint64(do_prescale_fp16(x, shift, fpst), fpst); +} + /* Set the current fp rounding mode and return the old one. * The argument is a softfloat float_round_ value. */ diff --git a/target/arm/helper.h b/target/arm/helper.h index 1969b37f2d..ce89968b2d 100644 --- a/target/arm/helper.h +++ b/target/arm/helper.h @@ -151,6 +151,10 @@ DEF_HELPER_3(vfp_touhd_round_to_zero, i64, f64, i32, ptr) DEF_HELPER_3(vfp_tould_round_to_zero, i64, f64, i32, ptr) DEF_HELPER_3(vfp_touhh, i32, f16, i32, ptr) DEF_HELPER_3(vfp_toshh, i32, f16, i32, ptr) +DEF_HELPER_3(vfp_toulh, i32, f16, i32, ptr) +DEF_HELPER_3(vfp_toslh, i32, f16, i32, ptr) +DEF_HELPER_3(vfp_touqh, i64, f16, i32, ptr) +DEF_HELPER_3(vfp_tosqh, i64, f16, i32, ptr) DEF_HELPER_3(vfp_toshs, i32, f32, i32, ptr) DEF_HELPER_3(vfp_tosls, i32, f32, i32, ptr) DEF_HELPER_3(vfp_tosqs, i64, f32, i32, ptr) @@ -177,6 +181,8 @@ DEF_HELPER_3(vfp_ultod, f64, i64, i32, ptr) DEF_HELPER_3(vfp_uqtod, f64, i64, i32, ptr) DEF_HELPER_3(vfp_sltoh, f16, i32, i32, ptr) DEF_HELPER_3(vfp_ultoh, f16, i32, i32, ptr) +DEF_HELPER_3(vfp_sqtoh, f16, i64, i32, ptr) +DEF_HELPER_3(vfp_uqtoh, f16, i64, i32, ptr) DEF_HELPER_FLAGS_2(set_rmode, TCG_CALL_NO_RWG, i32, i32, ptr) DEF_HELPER_FLAGS_2(set_neon_rmode, TCG_CALL_NO_RWG, i32, i32, env) diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index b05f9bfe91..33be611bdb 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -5268,11 +5268,11 @@ static void handle_fpfpcvt(DisasContext *s, int rd, int rn, int opcode, bool itof, int rmode, int scale, int sf, int type) { bool is_signed = !(opcode & 1); - bool is_double = type; TCGv_ptr tcg_fpstatus; - TCGv_i32 tcg_shift; + TCGv_i32 tcg_shift, tcg_single; + TCGv_i64 tcg_double; - tcg_fpstatus = get_fpstatus_ptr(false); + tcg_fpstatus = get_fpstatus_ptr(type == 3); tcg_shift = tcg_const_i32(64 - scale); @@ -5290,8 +5290,9 @@ static void handle_fpfpcvt(DisasContext *s, int rd, int rn, int opcode, tcg_int = tcg_extend; } - if (is_double) { - TCGv_i64 tcg_double = tcg_temp_new_i64(); + switch (type) { + case 1: /* float64 */ + tcg_double = tcg_temp_new_i64(); if (is_signed) { gen_helper_vfp_sqtod(tcg_double, tcg_int, tcg_shift, tcg_fpstatus); @@ -5301,8 +5302,10 @@ static void handle_fpfpcvt(DisasContext *s, int rd, int rn, int opcode, } write_fp_dreg(s, rd, tcg_double); tcg_temp_free_i64(tcg_double); - } else { - TCGv_i32 tcg_single = tcg_temp_new_i32(); + break; + + case 0: /* float32 */ + tcg_single = tcg_temp_new_i32(); if (is_signed) { gen_helper_vfp_sqtos(tcg_single, tcg_int, tcg_shift, tcg_fpstatus); @@ -5312,6 +5315,23 @@ static void handle_fpfpcvt(DisasContext *s, int rd, int rn, int opcode, } write_fp_sreg(s, rd, tcg_single); tcg_temp_free_i32(tcg_single); + break; + + case 3: /* float16 */ + tcg_single = tcg_temp_new_i32(); + if (is_signed) { + gen_helper_vfp_sqtoh(tcg_single, tcg_int, + tcg_shift, tcg_fpstatus); + } else { + gen_helper_vfp_uqtoh(tcg_single, tcg_int, + tcg_shift, tcg_fpstatus); + } + write_fp_sreg(s, rd, tcg_single); + tcg_temp_free_i32(tcg_single); + break; + + default: + g_assert_not_reached(); } } else { TCGv_i64 tcg_int = cpu_reg(s, rd); @@ -5328,8 +5348,9 @@ static void handle_fpfpcvt(DisasContext *s, int rd, int rn, int opcode, gen_helper_set_rmode(tcg_rmode, tcg_rmode, tcg_fpstatus); - if (is_double) { - TCGv_i64 tcg_double = read_fp_dreg(s, rn); + switch (type) { + case 1: /* float64 */ + tcg_double = read_fp_dreg(s, rn); if (is_signed) { if (!sf) { gen_helper_vfp_tosld(tcg_int, tcg_double, @@ -5347,9 +5368,14 @@ static void handle_fpfpcvt(DisasContext *s, int rd, int rn, int opcode, tcg_shift, tcg_fpstatus); } } + if (!sf) { + tcg_gen_ext32u_i64(tcg_int, tcg_int); + } tcg_temp_free_i64(tcg_double); - } else { - TCGv_i32 tcg_single = read_fp_sreg(s, rn); + break; + + case 0: /* float32 */ + tcg_single = read_fp_sreg(s, rn); if (sf) { if (is_signed) { gen_helper_vfp_tosqs(tcg_int, tcg_single, @@ -5371,14 +5397,39 @@ static void handle_fpfpcvt(DisasContext *s, int rd, int rn, int opcode, tcg_temp_free_i32(tcg_dest); } tcg_temp_free_i32(tcg_single); + break; + + case 3: /* float16 */ + tcg_single = read_fp_sreg(s, rn); + if (sf) { + if (is_signed) { + gen_helper_vfp_tosqh(tcg_int, tcg_single, + tcg_shift, tcg_fpstatus); + } else { + gen_helper_vfp_touqh(tcg_int, tcg_single, + tcg_shift, tcg_fpstatus); + } + } else { + TCGv_i32 tcg_dest = tcg_temp_new_i32(); + if (is_signed) { + gen_helper_vfp_toslh(tcg_dest, tcg_single, + tcg_shift, tcg_fpstatus); + } else { + gen_helper_vfp_toulh(tcg_dest, tcg_single, + tcg_shift, tcg_fpstatus); + } + tcg_gen_extu_i32_i64(tcg_int, tcg_dest); + tcg_temp_free_i32(tcg_dest); + } + tcg_temp_free_i32(tcg_single); + break; + + default: + g_assert_not_reached(); } gen_helper_set_rmode(tcg_rmode, tcg_rmode, tcg_fpstatus); tcg_temp_free_i32(tcg_rmode); - - if (!sf) { - tcg_gen_ext32u_i64(tcg_int, tcg_int); - } } tcg_temp_free_ptr(tcg_fpstatus); @@ -5548,7 +5599,20 @@ static void disas_fp_int_conv(DisasContext *s, uint32_t insn) /* actual FP conversions */ bool itof = extract32(opcode, 1, 1); - if (type > 1 || (rmode != 0 && opcode > 1)) { + if (rmode != 0 && opcode > 1) { + unallocated_encoding(s); + return; + } + switch (type) { + case 0: /* float32 */ + case 1: /* float64 */ + break; + case 3: /* float16 */ + if (arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { + break; + } + /* fallthru */ + default: unallocated_encoding(s); return; } From patchwork Mon Jul 23 20:17:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948060 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="df7n2tKo"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZDrb0Zy9z9s3N for ; Tue, 24 Jul 2018 07:19:11 +1000 (AEST) Received: from localhost ([::1]:36710 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhiEW-0005iP-HJ for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 17:19:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43103) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhKg-0003t2-PU for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:21:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhKg-0005MZ-10 for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:21:26 -0400 Received: from mail-oi0-x22c.google.com ([2607:f8b0:4003:c06::22c]:40354) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhKf-0005MG-SM; Mon, 23 Jul 2018 16:21:25 -0400 Received: by mail-oi0-x22c.google.com with SMTP id w126-v6so3482556oie.7; Mon, 23 Jul 2018 13:21:25 -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=VVvH4YNzTK+zAkrkiwSZ16MOLhc3dhyTKbADCU/yIfg=; b=df7n2tKoNfJT8Q90wVaHu/73Q0m+wpN9Ro3qK+DCDsNyd+2vHM+DrhOyyi4KRvW/a5 Uzk1EGio8oEumvDlgU03kyWKlBqLKal0WgD4th83AZw7988LOPSU1mcLNhceEtoLeucG 9erp0pK1zneURKtj3NlGUZaaNos1eI5xy5I2P6VCXD0x78PAe1U+DcdBS7fgV/2pa9t8 T1qt8N9E1D0U6yHCVoqAIElYMCfaLK15Mv6EMtPilAycMqiSeah0YdWpRyX/jZbD4DJg iSW/uRrWlGJnfgda3Jg0RuNHNFf2NZc7HD6J8VsHn4qUVdp1D0oejP68D1iCCRCfYHMY 9S8Q== 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=VVvH4YNzTK+zAkrkiwSZ16MOLhc3dhyTKbADCU/yIfg=; b=qxJ72/x4BwKfdq4k/BVFBAT3akNy9WjVUrx4gbKl7+1RLccdLf+8ZL7R2vIEpej4EB s0wyFJWzsUHM64a0KK8Zr/6mGWd/7JxVoPchfbDUoX7V8YFIfnfVMm90IWE5hJRUSBo0 eHklheH9D/rkeH4TDaVa5ktYPUCBopS9kKcyhThOuD4GoOOMa5aYUvN8XokZIGKy3G2G WRJHO2CYNbrpkp+OX5D9jBhrt3TL7+Lz6BeCQrtW01dBAgWlOU0Vv+n3fm+NJaFZRAra N5IG+RuUmxv/mtyjtYVU6ckVYomzz67Lrht7HW/Bqo/ThJB7Xl4pCMfhiuuK9zz1N3C1 lCvg== X-Gm-Message-State: AOUpUlGYRlOXQz4Mk4+E5irZoUGE7/1kefWJCEjtligrCFc6wKhcg6WZ g7tkZ+G+8gjGdsah9VUg9WFinYjC8sX3Fg== X-Google-Smtp-Source: AAOMgpfePbGjwf87KJy/xl20Bze0dnuEEj7Y8+d5e6bHq7j8DuRwrgb4D1AkJfcF2Y0lXgI2zzi5Wg== X-Received: by 2002:aca:4a49:: with SMTP id x70-v6mr278796oia.11.1532377284656; Mon, 23 Jul 2018 13:21:24 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id r133-v6sm7511499oia.33.2018.07.23.13.21.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:21:23 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:17:27 -0500 Message-Id: <20180723201748.25573-79-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::22c Subject: [Qemu-devel] [PATCH 78/99] target/arm: Implement FCVT (scalar, fixed-point) for fp16 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: Peter Maydell , Richard Henderson , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Cc: qemu-stable@nongnu.org Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Tested-by: Alex Bennée Message-id: 20180512003217.9105-5-richard.henderson@linaro.org Signed-off-by: Peter Maydell (cherry picked from commit 2752728016bef06e7c9cfb961019272859beeca4) Signed-off-by: Michael Roth --- target/arm/translate-a64.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 33be611bdb..c5be901b5f 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -5454,8 +5454,21 @@ static void disas_fp_fixed_conv(DisasContext *s, uint32_t insn) bool sf = extract32(insn, 31, 1); bool itof; - if (sbit || (type > 1) - || (!sf && scale < 32)) { + if (sbit || (!sf && scale < 32)) { + unallocated_encoding(s); + return; + } + + switch (type) { + case 0: /* float32 */ + case 1: /* float64 */ + break; + case 3: /* float16 */ + if (arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { + break; + } + /* fallthru */ + default: unallocated_encoding(s); return; } From patchwork Mon Jul 23 20:17:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948057 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="pwkq1aac"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZDnz2xV2z9s3N for ; Tue, 24 Jul 2018 07:16:55 +1000 (AEST) Received: from localhost ([::1]:36701 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhiCK-0003TY-Vo for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 17:16:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43149) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhKm-0003wj-8G for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:21:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhKi-0005NQ-8q for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:21:31 -0400 Received: from mail-oi0-x241.google.com ([2607:f8b0:4003:c06::241]:40410) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhKi-0005NF-2M; Mon, 23 Jul 2018 16:21:28 -0400 Received: by mail-oi0-x241.google.com with SMTP id w126-v6so3482743oie.7; Mon, 23 Jul 2018 13:21:28 -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=ZheyVE/pjPhu9F8cg6sWew5iy2ewnczU/RjVypp3QrE=; b=pwkq1aacGwxDdXo9nYovy9+XLdXFyJXuqIwWQ2CA16WBqKi4/IKKYJ7wRRL+2hUqad ww3uF4lWTj2mTx8k9SvJ3ALwqcCKnlwoXBgfBYVl8DMPTZMZMgtCTSyqIgV+tfT72aZW +Xa6iiKfmdnNia2od9+5wtFDlDmVYTET0ln0LSLbqbn82RF7p1s82u01VFO2RsHlDHZG ixaAkh2OJ3cIbV2tsrtb4AVfqFCw/zrze2E+KdvQWTEqp87ZaN4Mcw0ZsTsgcEsutPu8 /xnQ7BG6cIcGj4NRVXOgTAZktHMFyUFyetxB5w+TA3lppVytYWn2oamjgqZaQ0oMgKLR BeNA== 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=ZheyVE/pjPhu9F8cg6sWew5iy2ewnczU/RjVypp3QrE=; b=eLFXsKh++WnUaSE/meIubQATaGRzZfy+o9S9EezJhW2kNY5aZE891VwF/0zkK5APhi drKUYjUfo7+Q4n3ycu8XvClsQhHuooKmJ1GI0hyd6HkPGBRA3zC6Os6Q+WHdFrlOmOqu J8AvwbEr9Zg/PD8f4CTetb2jPH7/e7MfpEfSMpSlgf9RMCOdcjuXY7lhUTkl1T6Jjjua uoTghv3SqSnw5oQPRccILLY3wwvLxDxMmL0P1DriA4Xroa7LdglcXDWuxHKvLXnuYza1 XvM0aZGhcZpHdWmH70d7o9v6kA1QSz4iP9sF1pRP6+xP14Np+7p3PUJVSgEAgGQSZ5y3 9Nog== X-Gm-Message-State: AOUpUlEGUg1U3CutFBwEGhhuci/oOjLVF7FG3i9Updr85SNVb7LHPiEU LOUPgRb6sTi19PByVHUsWcjfwi+G0uwjzg== X-Google-Smtp-Source: AAOMgpeU5KgHcC0VUrmDafcDmjwhcuuxtxXCmxYX/o9gIelRHFu1qTrX/Ng6AxO9avdm7JyHlMWQOw== X-Received: by 2002:aca:e185:: with SMTP id y127-v6mr291260oig.245.1532377286875; Mon, 23 Jul 2018 13:21:26 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id w204-v6sm12600096oif.2.2018.07.23.13.21.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:21:25 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:17:28 -0500 Message-Id: <20180723201748.25573-80-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::241 Subject: [Qemu-devel] [PATCH 79/99] target/arm: Introduce and use read_fp_hreg 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: Peter Maydell , Richard Henderson , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Cc: qemu-stable@nongnu.org Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Tested-by: Alex Bennée Message-id: 20180512003217.9105-6-richard.henderson@linaro.org Signed-off-by: Peter Maydell (cherry picked from commit 3d99d931266eaeaf7e83703a53f32232cd6faad7) Signed-off-by: Michael Roth --- target/arm/translate-a64.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index c5be901b5f..bcb3b5c5e7 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -614,6 +614,14 @@ static TCGv_i32 read_fp_sreg(DisasContext *s, int reg) return v; } +static TCGv_i32 read_fp_hreg(DisasContext *s, int reg) +{ + TCGv_i32 v = tcg_temp_new_i32(); + + tcg_gen_ld16u_i32(v, cpu_env, fp_reg_offset(s, reg, MO_16)); + return v; +} + /* Clear the bits above an N-bit vector, for N = (is_q ? 128 : 64). * If SVE is not enabled, then there are only 128 bits in the vector. */ @@ -4638,11 +4646,9 @@ static void disas_fp_csel(DisasContext *s, uint32_t insn) static void handle_fp_1src_half(DisasContext *s, int opcode, int rd, int rn) { TCGv_ptr fpst = NULL; - TCGv_i32 tcg_op = tcg_temp_new_i32(); + TCGv_i32 tcg_op = read_fp_hreg(s, rn); TCGv_i32 tcg_res = tcg_temp_new_i32(); - read_vec_element_i32(s, tcg_op, rn, 0, MO_16); - switch (opcode) { case 0x0: /* FMOV */ tcg_gen_mov_i32(tcg_res, tcg_op); @@ -7538,13 +7544,10 @@ static void disas_simd_scalar_three_reg_diff(DisasContext *s, uint32_t insn) tcg_temp_free_i64(tcg_op2); tcg_temp_free_i64(tcg_res); } else { - TCGv_i32 tcg_op1 = tcg_temp_new_i32(); - TCGv_i32 tcg_op2 = tcg_temp_new_i32(); + TCGv_i32 tcg_op1 = read_fp_hreg(s, rn); + TCGv_i32 tcg_op2 = read_fp_hreg(s, rm); TCGv_i64 tcg_res = tcg_temp_new_i64(); - read_vec_element_i32(s, tcg_op1, rn, 0, MO_16); - read_vec_element_i32(s, tcg_op2, rm, 0, MO_16); - gen_helper_neon_mull_s16(tcg_res, tcg_op1, tcg_op2); gen_helper_neon_addl_saturate_s32(tcg_res, cpu_env, tcg_res, tcg_res); @@ -8085,13 +8088,10 @@ static void disas_simd_scalar_three_reg_same_fp16(DisasContext *s, fpst = get_fpstatus_ptr(true); - tcg_op1 = tcg_temp_new_i32(); - tcg_op2 = tcg_temp_new_i32(); + tcg_op1 = read_fp_hreg(s, rn); + tcg_op2 = read_fp_hreg(s, rm); tcg_res = tcg_temp_new_i32(); - read_vec_element_i32(s, tcg_op1, rn, 0, MO_16); - read_vec_element_i32(s, tcg_op2, rm, 0, MO_16); - switch (fpopcode) { case 0x03: /* FMULX */ gen_helper_advsimd_mulxh(tcg_res, tcg_op1, tcg_op2, fpst); @@ -12010,11 +12010,9 @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn) } if (is_scalar) { - TCGv_i32 tcg_op = tcg_temp_new_i32(); + TCGv_i32 tcg_op = read_fp_hreg(s, rn); TCGv_i32 tcg_res = tcg_temp_new_i32(); - read_vec_element_i32(s, tcg_op, rn, 0, MO_16); - switch (fpop) { case 0x1a: /* FCVTNS */ case 0x1b: /* FCVTMS */ From patchwork Mon Jul 23 20:17:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948087 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="S430aq4Y"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZF9Q0snKz9s3N for ; Tue, 24 Jul 2018 07:33:46 +1000 (AEST) Received: from localhost ([::1]:36812 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhiSd-0001eW-Na for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 17:33:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43150) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhKm-0003wk-8Y for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:21:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhKk-0005PE-Fb for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:21:31 -0400 Received: from mail-oi0-x241.google.com ([2607:f8b0:4003:c06::241]:41190) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhKk-0005Od-9H; Mon, 23 Jul 2018 16:21:30 -0400 Received: by mail-oi0-x241.google.com with SMTP id k12-v6so3470408oiw.8; Mon, 23 Jul 2018 13:21:30 -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=6hjUj8XyV2DypjsCvz3iBwG01puPwJvqRnMj7VRoXbI=; b=S430aq4YdmQqd/oMMSA3umegvasrKD15r+RUcNBu+hVDpmtbzhf/DE6XIqu9W7pnPV 4U9qlz/jNV64GcsinejNJUjQCep3D7tXWgwG22+VZlxvA0se3IBf1lldE3TjhKeUlqmw hcGW/2+j4x/s0vsg1TdIPPXGJei5QJje1mAw+p9VvyNtI7Qcl9AgxQQ89ukiOKUm6tVk Fiempz9M9AQIsa+RKg8Ujlj2P+Xq8vWaCVLQnK3dwSPm1J8UAwSifqLMcWIR/Pc5OaDc E3ff+CGiPinLOQvV5j1O2LKkINnBJipDsayzkisCvePexDf3AjChpM1yNW4HTOAClIrX 2ufQ== 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=6hjUj8XyV2DypjsCvz3iBwG01puPwJvqRnMj7VRoXbI=; b=lDnS+pZb5ERNNa/c8SP2ksbhoMuUgiGqNxE7h6FeS9Fa6eVcawed681tqwf3WjHIXr NllP6/3SCyurrRjvbWhTMWXiBzQsTPMbGcLS6+YiEfaNf/qY6xgP50Z3VAtVCtvnhxvU n9BA9sKQacWHLw7x4b6gVQ+q+k5aFyB00cyybYxPjKoHN7vJbGy1tWO2yGeXDLCS33MX TOpl2xpUUcHCoNG+7TePa3xWzU3ZKBlZoxKkvG0ijzXcQFWaMFFN7b2SSDL8dglqAQeF vMu7Y/bnM5s8emiidOCgN2Dbmci593Gpu7enRHneCIaJKucAviBF92hfUUlDZSGXXPzH cEMg== X-Gm-Message-State: AOUpUlGt2TTJms9b57eVLFsiOHUpegs7hyD+WIb6ErHm3s5JD1Y9GosM xJ2aPGoc8xvoj30H0wobAPs2Q7SqZi7S1w== X-Google-Smtp-Source: AAOMgpdbgL1yikOUQhYN6CKs1QknnEquO2XE8fowi7RUe7t3YZ+sCToIejl/FxSFq915EFPTZP8ayg== X-Received: by 2002:aca:d5cd:: with SMTP id m196-v6mr306652oig.160.1532377289113; Mon, 23 Jul 2018 13:21:29 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id q124-v6sm7914349oif.8.2018.07.23.13.21.27 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:21:28 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:17:29 -0500 Message-Id: <20180723201748.25573-81-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::241 Subject: [Qemu-devel] [PATCH 80/99] target/arm: Implement FP data-processing (2 source) for fp16 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: Peter Maydell , Richard Henderson , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson We missed all of the scalar fp16 binary operations. Cc: qemu-stable@nongnu.org Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Tested-by: Alex Bennée Message-id: 20180512003217.9105-7-richard.henderson@linaro.org Signed-off-by: Peter Maydell (cherry picked from commit b8f5171cf01420a9f0ee895c5591e9b9914f391a) Signed-off-by: Michael Roth --- target/arm/translate-a64.c | 65 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index bcb3b5c5e7..5260849f03 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -5056,6 +5056,61 @@ static void handle_fp_2src_double(DisasContext *s, int opcode, tcg_temp_free_i64(tcg_res); } +/* Floating-point data-processing (2 source) - half precision */ +static void handle_fp_2src_half(DisasContext *s, int opcode, + int rd, int rn, int rm) +{ + TCGv_i32 tcg_op1; + TCGv_i32 tcg_op2; + TCGv_i32 tcg_res; + TCGv_ptr fpst; + + tcg_res = tcg_temp_new_i32(); + fpst = get_fpstatus_ptr(true); + tcg_op1 = read_fp_hreg(s, rn); + tcg_op2 = read_fp_hreg(s, rm); + + switch (opcode) { + case 0x0: /* FMUL */ + gen_helper_advsimd_mulh(tcg_res, tcg_op1, tcg_op2, fpst); + break; + case 0x1: /* FDIV */ + gen_helper_advsimd_divh(tcg_res, tcg_op1, tcg_op2, fpst); + break; + case 0x2: /* FADD */ + gen_helper_advsimd_addh(tcg_res, tcg_op1, tcg_op2, fpst); + break; + case 0x3: /* FSUB */ + gen_helper_advsimd_subh(tcg_res, tcg_op1, tcg_op2, fpst); + break; + case 0x4: /* FMAX */ + gen_helper_advsimd_maxh(tcg_res, tcg_op1, tcg_op2, fpst); + break; + case 0x5: /* FMIN */ + gen_helper_advsimd_minh(tcg_res, tcg_op1, tcg_op2, fpst); + break; + case 0x6: /* FMAXNM */ + gen_helper_advsimd_maxnumh(tcg_res, tcg_op1, tcg_op2, fpst); + break; + case 0x7: /* FMINNM */ + gen_helper_advsimd_minnumh(tcg_res, tcg_op1, tcg_op2, fpst); + break; + case 0x8: /* FNMUL */ + gen_helper_advsimd_mulh(tcg_res, tcg_op1, tcg_op2, fpst); + tcg_gen_xori_i32(tcg_res, tcg_res, 0x8000); + break; + default: + g_assert_not_reached(); + } + + write_fp_sreg(s, rd, tcg_res); + + tcg_temp_free_ptr(fpst); + tcg_temp_free_i32(tcg_op1); + tcg_temp_free_i32(tcg_op2); + tcg_temp_free_i32(tcg_res); +} + /* Floating point data-processing (2 source) * 31 30 29 28 24 23 22 21 20 16 15 12 11 10 9 5 4 0 * +---+---+---+-----------+------+---+------+--------+-----+------+------+ @@ -5088,6 +5143,16 @@ static void disas_fp_2src(DisasContext *s, uint32_t insn) } handle_fp_2src_double(s, opcode, rd, rn, rm); break; + case 3: + if (!arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { + unallocated_encoding(s); + return; + } + if (!fp_access_check(s)) { + return; + } + handle_fp_2src_half(s, opcode, rd, rn, rm); + break; default: unallocated_encoding(s); } From patchwork Mon Jul 23 20:17:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948088 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="d3Xi68jk"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZFBm2H9Pz9s3N for ; Tue, 24 Jul 2018 07:34:56 +1000 (AEST) Received: from localhost ([::1]:36816 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhiTm-0002oZ-00 for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 17:34:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43206) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhKq-00043L-I0 for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:21:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhKp-0005Sc-CL for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:21:36 -0400 Received: from mail-oi0-x22c.google.com ([2607:f8b0:4003:c06::22c]:43131) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhKp-0005SM-6J; Mon, 23 Jul 2018 16:21:35 -0400 Received: by mail-oi0-x22c.google.com with SMTP id b15-v6so3471524oib.10; Mon, 23 Jul 2018 13:21:35 -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=GU6mHHNnptLNGjZsRkDztjlgUH/p7DOB0aYBTtKmDOg=; b=d3Xi68jk72gPmKGcWrSdOBaE6uwg7hT6Iy4FXfh6ZScF57mByU7gHcVG7ObyTZQ/mk +yrAi6b3elXc7mejH/lfDbCCzUdxMJW/IGzsJPUfcsvWM43z+WksSKFnctWvZpeyPHGk GOQoaci9Geo5RQZUQ4dvKBZ89D1sjnyr0btW9PBIEPn1G6EC6YZUX5duTnOuyA6EYmDV f11t5ZQS4/IBA9f4clMOAklnDC1C3fptxG8PszFb4URmUfQ1k6F/Vh2Hx/d8XJ+6iLlm RQIcnwYQOIqb1WihBV8wEXEkTnmDhBnTI/EUxNLms1dNetI6o7aT0JHdI0DzGKppSf3Q yQ/g== 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=GU6mHHNnptLNGjZsRkDztjlgUH/p7DOB0aYBTtKmDOg=; b=Ibr6wrig6MPvNRTSPvtqwLQDcNyM3SkEQkKhWQkMar16y0Ghxr/DTs+bUjiFOUfusB 6fznCaRKmnF5rYTtamsxB/r0HnlTQL2oVnGMvptdfrhPMhCFYwsoCseXJJdm8vE4f71z n8jfful2hrGf9uBetWQDnymhclLODjAlzmKleZKN1GDdl3s7lSn/QGeGV6RnZPModKRc VUbF+O/Uj2TADotYqPwhodpxiIjMqa9RIl1Fd5lAC7E2ZBDr+Yh08BwrwnPdJzU8M2Ix X51HUD6ZfkcdP+kzZNTdL7lGBzAorXCgHDph/s0rXvRKpJw+j9xcvN2Ld75wJ775EVkY q2hA== X-Gm-Message-State: AOUpUlFSVjV8k1SegC6d6jEZ/VNt46HfawZZQUO8RqOVDts9WzYwQhAl B6kFjHcZDVT9FSsdIwtgmiCciWJlvsRIRA== X-Google-Smtp-Source: AAOMgpcF1RtvsR9OqO3FM4DH7a+YQQVlxwhs3Rt4u7L+MpRUETESFiG0kyY4rItjPGXQcWzqd33ArQ== X-Received: by 2002:aca:4d0a:: with SMTP id a10-v6mr295998oib.175.1532377293857; Mon, 23 Jul 2018 13:21:33 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id i204-v6sm19824135oia.41.2018.07.23.13.21.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:21:32 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:17:30 -0500 Message-Id: <20180723201748.25573-82-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::22c Subject: [Qemu-devel] [PATCH 81/99] target/arm: Implement FP data-processing (3 source) for fp16 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: Peter Maydell , Richard Henderson , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson We missed all of the scalar fp16 fma operations. Cc: qemu-stable@nongnu.org Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Tested-by: Alex Bennée Message-id: 20180512003217.9105-8-richard.henderson@linaro.org Signed-off-by: Peter Maydell (cherry picked from commit 95f9864fde6078e2d2c036a07cc4fe44f199be96) Signed-off-by: Michael Roth --- target/arm/translate-a64.c | 48 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 5260849f03..9880a5d047 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -5234,6 +5234,44 @@ static void handle_fp_3src_double(DisasContext *s, bool o0, bool o1, tcg_temp_free_i64(tcg_res); } +/* Floating-point data-processing (3 source) - half precision */ +static void handle_fp_3src_half(DisasContext *s, bool o0, bool o1, + int rd, int rn, int rm, int ra) +{ + TCGv_i32 tcg_op1, tcg_op2, tcg_op3; + TCGv_i32 tcg_res = tcg_temp_new_i32(); + TCGv_ptr fpst = get_fpstatus_ptr(true); + + tcg_op1 = read_fp_hreg(s, rn); + tcg_op2 = read_fp_hreg(s, rm); + tcg_op3 = read_fp_hreg(s, ra); + + /* These are fused multiply-add, and must be done as one + * floating point operation with no rounding between the + * multiplication and addition steps. + * NB that doing the negations here as separate steps is + * correct : an input NaN should come out with its sign bit + * flipped if it is a negated-input. + */ + if (o1 == true) { + tcg_gen_xori_i32(tcg_op3, tcg_op3, 0x8000); + } + + if (o0 != o1) { + tcg_gen_xori_i32(tcg_op1, tcg_op1, 0x8000); + } + + gen_helper_advsimd_muladdh(tcg_res, tcg_op1, tcg_op2, tcg_op3, fpst); + + write_fp_sreg(s, rd, tcg_res); + + tcg_temp_free_ptr(fpst); + tcg_temp_free_i32(tcg_op1); + tcg_temp_free_i32(tcg_op2); + tcg_temp_free_i32(tcg_op3); + tcg_temp_free_i32(tcg_res); +} + /* Floating point data-processing (3 source) * 31 30 29 28 24 23 22 21 20 16 15 14 10 9 5 4 0 * +---+---+---+-----------+------+----+------+----+------+------+------+ @@ -5263,6 +5301,16 @@ static void disas_fp_3src(DisasContext *s, uint32_t insn) } handle_fp_3src_double(s, o0, o1, rd, rn, rm, ra); break; + case 3: + if (!arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { + unallocated_encoding(s); + return; + } + if (!fp_access_check(s)) { + return; + } + handle_fp_3src_half(s, o0, o1, rd, rn, rm, ra); + break; default: unallocated_encoding(s); } From patchwork Mon Jul 23 20:17:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948070 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="VYxrYdxc"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZF0M2rZRz9s3N for ; Tue, 24 Jul 2018 07:25:55 +1000 (AEST) Received: from localhost ([::1]:36758 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhiL2-0002rE-Vo for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 17:25:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43232) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhKu-00047b-RG for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:21:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhKr-0005TC-Ju for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:21:40 -0400 Received: from mail-oi0-x22a.google.com ([2607:f8b0:4003:c06::22a]:39357) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhKr-0005T5-CU; Mon, 23 Jul 2018 16:21:37 -0400 Received: by mail-oi0-x22a.google.com with SMTP id d189-v6so3488686oib.6; Mon, 23 Jul 2018 13:21:37 -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=WSnvSXMbdx8hUZexpfJ0bUF04M4al43hgNTbrqASRV8=; b=VYxrYdxcDH8autSpHW9z16WRoqXBlNx5b+Bs+WTqIM8u+yS+0A/J2yuOnYnqrdnna4 Iy7hJA3G8kdyDS5vqNxK/C/NJNZML7C6SCAY/ySvPl6M5MuEzq5E2wY5okpWmdjiH2vq XGTipl6TR1KhhS+KUbw/h0xfQFacFSGWjdG2lQkFkL2O/71uGiUIyIDXbkqWBEuIBgDL rczF/rYis3ARkkAR1qxHHQbH1qd05CksJNcZqDB3jSchhoXZvDyrnKAcVHzmVODDFt6h 6Q1GBtzHiOQ93eW2iqvhWVqLNSJuiWWqxGnKNwc8LElNImlOGauPXe4vvIkQLlr0svBW 8c6A== 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=WSnvSXMbdx8hUZexpfJ0bUF04M4al43hgNTbrqASRV8=; b=fsDHONyEvAljOf8EbYsGijKPYtV4t3qxTMrYuYc4mRiMnHISdmfOB49/RHDWNK0gVs 7Rq9HEHdKPvmVE/S0dU2zspGct0s1z8rCAvCvJOBMWdAe+S8xHPILUBeMu4GRtNRZ3VT f7lxPOUywWEPMk8Q8kU/HBm4ui08UDTXMATW5G8DBomZKQ+mn3toau8cwUiXYXiM2JmT CynBzfi/Eqcw0s0JgJD33wX2MtWLcAeIo5vF17M3yXNZMeHf3Fafpt+U5tOiSMCEDf5k GMOKKMCbVFKN3uwCNeYPZbWy05g7xibGbeCbh89GwjQ2KG1+sWls4a1X8cVHzkgTP8Vz D2fA== X-Gm-Message-State: AOUpUlFPPxPL7zXY7x+ke58nUuE0glaMA2qL7uLWg4OHhpo0HNW8c6vU Ahwhdm2tXxfwF4CL0EAG6gHI8vU0Gt4j2w== X-Google-Smtp-Source: AAOMgpfbdqCYHtIQq1B7xVwrjjhEfpk3qbfu9U6iQqFAE8gyYSIDmA0Kc0LH/BmXGHMQcSI+aSN0Pw== X-Received: by 2002:aca:6142:: with SMTP id v63-v6mr312199oib.137.1532377296139; Mon, 23 Jul 2018 13:21:36 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id v202-v6sm9033537oie.47.2018.07.23.13.21.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:21:35 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:17:31 -0500 Message-Id: <20180723201748.25573-83-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::22a Subject: [Qemu-devel] [PATCH 82/99] target/arm: Implement FCMP for fp16 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: Richard Henderson , =?utf-8?q?Alex_Benn?= =?utf-8?b?w6ll?= , qemu-stable@nongnu.org, Peter Maydell Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Alex Bennée These where missed out from the rest of the half-precision work. Cc: qemu-stable@nongnu.org Reviewed-by: Peter Maydell Signed-off-by: Alex Bennée Tested-by: Alex Bennée Signed-off-by: Richard Henderson Message-id: 20180512003217.9105-9-richard.henderson@linaro.org [rth: Diagnose lack of FP16 before fp_access_check] Signed-off-by: Richard Henderson Signed-off-by: Peter Maydell (cherry picked from commit 7a1929256ea1a03df12625e75ed571c60dca5bfb) Signed-off-by: Michael Roth --- target/arm/helper-a64.c | 10 +++++ target/arm/helper-a64.h | 2 + target/arm/translate-a64.c | 88 ++++++++++++++++++++++++++++++-------- 3 files changed, 83 insertions(+), 17 deletions(-) diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c index afb25ad20c..35df07adb9 100644 --- a/target/arm/helper-a64.c +++ b/target/arm/helper-a64.c @@ -85,6 +85,16 @@ static inline uint32_t float_rel_to_flags(int res) return flags; } +uint64_t HELPER(vfp_cmph_a64)(float16 x, float16 y, void *fp_status) +{ + return float_rel_to_flags(float16_compare_quiet(x, y, fp_status)); +} + +uint64_t HELPER(vfp_cmpeh_a64)(float16 x, float16 y, void *fp_status) +{ + return float_rel_to_flags(float16_compare(x, y, fp_status)); +} + uint64_t HELPER(vfp_cmps_a64)(float32 x, float32 y, void *fp_status) { return float_rel_to_flags(float32_compare_quiet(x, y, fp_status)); diff --git a/target/arm/helper-a64.h b/target/arm/helper-a64.h index ef4ddfe9d8..5c0b9bd799 100644 --- a/target/arm/helper-a64.h +++ b/target/arm/helper-a64.h @@ -19,6 +19,8 @@ DEF_HELPER_FLAGS_2(udiv64, TCG_CALL_NO_RWG_SE, i64, i64, i64) DEF_HELPER_FLAGS_2(sdiv64, TCG_CALL_NO_RWG_SE, s64, s64, s64) DEF_HELPER_FLAGS_1(rbit64, TCG_CALL_NO_RWG_SE, i64, i64) +DEF_HELPER_3(vfp_cmph_a64, i64, f16, f16, ptr) +DEF_HELPER_3(vfp_cmpeh_a64, i64, f16, f16, ptr) DEF_HELPER_3(vfp_cmps_a64, i64, f32, f32, ptr) DEF_HELPER_3(vfp_cmpes_a64, i64, f32, f32, ptr) DEF_HELPER_3(vfp_cmpd_a64, i64, f64, f64, ptr) diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 9880a5d047..05d51ecbdc 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -4469,14 +4469,14 @@ static void disas_data_proc_reg(DisasContext *s, uint32_t insn) } } -static void handle_fp_compare(DisasContext *s, bool is_double, +static void handle_fp_compare(DisasContext *s, int size, unsigned int rn, unsigned int rm, bool cmp_with_zero, bool signal_all_nans) { TCGv_i64 tcg_flags = tcg_temp_new_i64(); - TCGv_ptr fpst = get_fpstatus_ptr(false); + TCGv_ptr fpst = get_fpstatus_ptr(size == MO_16); - if (is_double) { + if (size == MO_64) { TCGv_i64 tcg_vn, tcg_vm; tcg_vn = read_fp_dreg(s, rn); @@ -4493,19 +4493,35 @@ static void handle_fp_compare(DisasContext *s, bool is_double, tcg_temp_free_i64(tcg_vn); tcg_temp_free_i64(tcg_vm); } else { - TCGv_i32 tcg_vn, tcg_vm; + TCGv_i32 tcg_vn = tcg_temp_new_i32(); + TCGv_i32 tcg_vm = tcg_temp_new_i32(); - tcg_vn = read_fp_sreg(s, rn); + read_vec_element_i32(s, tcg_vn, rn, 0, size); if (cmp_with_zero) { - tcg_vm = tcg_const_i32(0); + tcg_gen_movi_i32(tcg_vm, 0); } else { - tcg_vm = read_fp_sreg(s, rm); + read_vec_element_i32(s, tcg_vm, rm, 0, size); } - if (signal_all_nans) { - gen_helper_vfp_cmpes_a64(tcg_flags, tcg_vn, tcg_vm, fpst); - } else { - gen_helper_vfp_cmps_a64(tcg_flags, tcg_vn, tcg_vm, fpst); + + switch (size) { + case MO_32: + if (signal_all_nans) { + gen_helper_vfp_cmpes_a64(tcg_flags, tcg_vn, tcg_vm, fpst); + } else { + gen_helper_vfp_cmps_a64(tcg_flags, tcg_vn, tcg_vm, fpst); + } + break; + case MO_16: + if (signal_all_nans) { + gen_helper_vfp_cmpeh_a64(tcg_flags, tcg_vn, tcg_vm, fpst); + } else { + gen_helper_vfp_cmph_a64(tcg_flags, tcg_vn, tcg_vm, fpst); + } + break; + default: + g_assert_not_reached(); } + tcg_temp_free_i32(tcg_vn); tcg_temp_free_i32(tcg_vm); } @@ -4526,16 +4542,35 @@ static void handle_fp_compare(DisasContext *s, bool is_double, static void disas_fp_compare(DisasContext *s, uint32_t insn) { unsigned int mos, type, rm, op, rn, opc, op2r; + int size; mos = extract32(insn, 29, 3); - type = extract32(insn, 22, 2); /* 0 = single, 1 = double */ + type = extract32(insn, 22, 2); rm = extract32(insn, 16, 5); op = extract32(insn, 14, 2); rn = extract32(insn, 5, 5); opc = extract32(insn, 3, 2); op2r = extract32(insn, 0, 3); - if (mos || op || op2r || type > 1) { + if (mos || op || op2r) { + unallocated_encoding(s); + return; + } + + switch (type) { + case 0: + size = MO_32; + break; + case 1: + size = MO_64; + break; + case 3: + size = MO_16; + if (arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { + break; + } + /* fallthru */ + default: unallocated_encoding(s); return; } @@ -4544,7 +4579,7 @@ static void disas_fp_compare(DisasContext *s, uint32_t insn) return; } - handle_fp_compare(s, type, rn, rm, opc & 1, opc & 2); + handle_fp_compare(s, size, rn, rm, opc & 1, opc & 2); } /* Floating point conditional compare @@ -4558,16 +4593,35 @@ static void disas_fp_ccomp(DisasContext *s, uint32_t insn) unsigned int mos, type, rm, cond, rn, op, nzcv; TCGv_i64 tcg_flags; TCGLabel *label_continue = NULL; + int size; mos = extract32(insn, 29, 3); - type = extract32(insn, 22, 2); /* 0 = single, 1 = double */ + type = extract32(insn, 22, 2); rm = extract32(insn, 16, 5); cond = extract32(insn, 12, 4); rn = extract32(insn, 5, 5); op = extract32(insn, 4, 1); nzcv = extract32(insn, 0, 4); - if (mos || type > 1) { + if (mos) { + unallocated_encoding(s); + return; + } + + switch (type) { + case 0: + size = MO_32; + break; + case 1: + size = MO_64; + break; + case 3: + size = MO_16; + if (arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { + break; + } + /* fallthru */ + default: unallocated_encoding(s); return; } @@ -4588,7 +4642,7 @@ static void disas_fp_ccomp(DisasContext *s, uint32_t insn) gen_set_label(label_match); } - handle_fp_compare(s, type, rn, rm, false, op); + handle_fp_compare(s, size, rn, rm, false, op); if (cond < 0x0e) { gen_set_label(label_continue); From patchwork Mon Jul 23 20:17:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948065 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="aQm82p8I"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZDxD42bsz9s3Z for ; Tue, 24 Jul 2018 07:23:12 +1000 (AEST) Received: from localhost ([::1]:36737 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhiIQ-0000ZJ-58 for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 17:23:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43234) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhKu-00047d-RU for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:21:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhKt-0005Tj-NL for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:21:40 -0400 Received: from mail-oi0-x234.google.com ([2607:f8b0:4003:c06::234]:33597) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhKt-0005Tc-Hn; Mon, 23 Jul 2018 16:21:39 -0400 Received: by mail-oi0-x234.google.com with SMTP id l10-v6so3508659oii.0; Mon, 23 Jul 2018 13:21:39 -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=aU6+1pILpx3AH2qSrnLg/7HMEjAsH5WP/rg+2tSd7Gk=; b=aQm82p8IYvfbH37ZUwg2yMPFNm4hdOfW55zkLAw9eL7bscaLdMURXQpR+mT4BnLRm0 E1kYlwbzem6BTlAgcjVJ3PyawUjQbfJKEL6iOAMj9/2t9UyteqRwmLHIzlhnRngva7/D uz7InFmxuqq4NVfaqgKBvG9fLB1C9leOeGy1dWBzokb97meqlJRUm0xyoPcVtekQY+6i /TKM/SG0ibuGbH3vYN3iI0TjrucH41s3ScCNrx/rYfSQ8iBV6iJv/wwHNu20WY43mbKs WaHRV4j8v8XYkzhYSPa/ZorZC0ROsSKK4smQ7S8NRuCYHQwYA36GuWHE8NyZXmPsx5A+ PuOQ== 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=aU6+1pILpx3AH2qSrnLg/7HMEjAsH5WP/rg+2tSd7Gk=; b=n/juX7DLUZ3DZozVUZ+DrZ4IuZ365PjGv1crjkL7i8/oBsUQmNU1sw1930zobMK7R0 GQ+0ILOWIIqBHBFRLggiqX1ryvqTE6N+AjEO9RVhP7CeuzyqWc1C2G4mRW7xZcxE+RCa uEt2x0N7rsEnhCwGhlEac38GIhqoV9j3gamL0NXNIosMjwj4ev5iPKx1VUBqb/KiymUl GxP0t8VRelnamID1IU/hzQlH1+KoUJW5X5G06fYR6EN6TbguJVlJ/vI6IuuIs16THa5j hRnYdaLhOrYUU5cqTM9rQXdi5giX5tqdm27q3KMKai40Pk+gsslv66CZ4H2259fljhNl 5i/w== X-Gm-Message-State: AOUpUlGBYHOHm9MdZWajUvoA6X4sPrqf7+zBPY1mHYT7aXonMqCRt61l XmSKMgJwWUbAMnjOV+w9arxrPLdk+DGKkQ== X-Google-Smtp-Source: AAOMgpdPVlzBpQOvrObmKCzdrgRLwN+R66kE1j/+6CzbaoJxh8QMJ6f5R4VA0QAf15U89vCNhdGm7A== X-Received: by 2002:aca:68a2:: with SMTP id o34-v6mr296209oik.267.1532377298328; Mon, 23 Jul 2018 13:21:38 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id e125-v6sm9840061oig.4.2018.07.23.13.21.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:21:37 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:17:32 -0500 Message-Id: <20180723201748.25573-84-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::234 Subject: [Qemu-devel] [PATCH 83/99] target/arm: Implement FCSEL for fp16 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: Richard Henderson , =?utf-8?q?Alex_Benn?= =?utf-8?b?w6ll?= , qemu-stable@nongnu.org, Peter Maydell Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Alex Bennée These were missed out from the rest of the half-precision work. Cc: qemu-stable@nongnu.org Reviewed-by: Peter Maydell Signed-off-by: Alex Bennée Tested-by: Alex Bennée Signed-off-by: Richard Henderson Message-id: 20180512003217.9105-10-richard.henderson@linaro.org [rth: Fix erroneous check vs type] Signed-off-by: Richard Henderson Signed-off-by: Peter Maydell (cherry picked from commit ace97feef3613194900d4eb9ffc6819b840fbaeb) Signed-off-by: Michael Roth --- target/arm/translate-a64.c | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 05d51ecbdc..7075f27e05 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -4660,15 +4660,34 @@ static void disas_fp_csel(DisasContext *s, uint32_t insn) unsigned int mos, type, rm, cond, rn, rd; TCGv_i64 t_true, t_false, t_zero; DisasCompare64 c; + TCGMemOp sz; mos = extract32(insn, 29, 3); - type = extract32(insn, 22, 2); /* 0 = single, 1 = double */ + type = extract32(insn, 22, 2); rm = extract32(insn, 16, 5); cond = extract32(insn, 12, 4); rn = extract32(insn, 5, 5); rd = extract32(insn, 0, 5); - if (mos || type > 1) { + if (mos) { + unallocated_encoding(s); + return; + } + + switch (type) { + case 0: + sz = MO_32; + break; + case 1: + sz = MO_64; + break; + case 3: + sz = MO_16; + if (arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { + break; + } + /* fallthru */ + default: unallocated_encoding(s); return; } @@ -4677,11 +4696,11 @@ static void disas_fp_csel(DisasContext *s, uint32_t insn) return; } - /* Zero extend sreg inputs to 64 bits now. */ + /* Zero extend sreg & hreg inputs to 64 bits now. */ t_true = tcg_temp_new_i64(); t_false = tcg_temp_new_i64(); - read_vec_element(s, t_true, rn, 0, type ? MO_64 : MO_32); - read_vec_element(s, t_false, rm, 0, type ? MO_64 : MO_32); + read_vec_element(s, t_true, rn, 0, sz); + read_vec_element(s, t_false, rm, 0, sz); a64_test_cc(&c, cond); t_zero = tcg_const_i64(0); @@ -4690,7 +4709,7 @@ static void disas_fp_csel(DisasContext *s, uint32_t insn) tcg_temp_free_i64(t_false); a64_free_cc(&c); - /* Note that sregs write back zeros to the high bits, + /* Note that sregs & hregs write back zeros to the high bits, and we've already done the zero-extension. */ write_fp_dreg(s, rd, t_true); tcg_temp_free_i64(t_true); From patchwork Mon Jul 23 20:17:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948091 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="IKye51sg"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZFFq4n9Zz9s3N for ; Tue, 24 Jul 2018 07:37:35 +1000 (AEST) Received: from localhost ([::1]:36841 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhiWL-0005Yx-9S for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 17:37:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43262) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhKw-000488-V7 for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:21:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhKw-0005Ub-07 for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:21:42 -0400 Received: from mail-oi0-x230.google.com ([2607:f8b0:4003:c06::230]:35556) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhKv-0005UP-Qn; Mon, 23 Jul 2018 16:21:41 -0400 Received: by mail-oi0-x230.google.com with SMTP id i12-v6so3508334oik.2; Mon, 23 Jul 2018 13:21:41 -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=9tH4pupl7s1gkH526KWx8Yj77S7uAqfJTbdOKzq4alk=; b=IKye51sgDP8+fme/s08wDIyStNwflkUtM9wxquPff2kOWrBGG6A/nFuYxa3ryOxEWZ JD2VRx/EslNq93nlRxDlC8E0H0+U/ENr1lvc//gmUFg29i5lriDCmtv3Qc0a3GKwfu3B T0FXo7fUHzmmRtp9vywraNbALgvrkfFt5ZrjlwiNIVDWiY6cGx/hSxmOq4bD3N5yqpnH Sd0eKLp4wQumHbwoPzAYs0qqLQeb+Moin+P8vDfH3HryLTkhZECYwU1MANWRzrNZNcG4 mT5LJFC3P2AagsLNrx4Ab1OSRnn7nnE1R0J0q9lKQpdWzNMVw5YEB6zc5dhhMO3U28u3 QBxA== 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=9tH4pupl7s1gkH526KWx8Yj77S7uAqfJTbdOKzq4alk=; b=cvS5/3MLJ/67YUevK+FxfZqK7Q/4c1yxpgtCTZz3J54OHCt9mcYGfJr3gaI6a9TyMO 5/J6eFUxArwsXvuU4aonsvFFS10MXGDARNj7mThHiSIiP89gZcBP2TBUCK6Iu2FLloQv S29qoX2Vm3x05REZtt9eM7CxkrYTdswiH8NWjgjJ/bQrgGb4xurDAfsgZN/1dWawN76u tdEUgl7s5CMVyVfUoqqYCMIJO9hGlEAuDlJ0HiwreNnhFJHx8Nl+1K4IkxTxBDZQZD14 AG2XowiqRDH5fKyYcPX0c29lhGHgnsAVeNVppDMA1HTgc6AN+o97YjYnvcp6IhT+slkZ uTVA== X-Gm-Message-State: AOUpUlHWBDNrGz+fkrtYDvcsduN+4pVuSPWtrZWZNtUWS3Ot6giASWpq gj3yNEVPlbxUXzWunkMQ4eB8Bb3uTMmlhQ== X-Google-Smtp-Source: AAOMgpfbRq/8duZkW4UchWlkTwQSctiOLHY7Q3FhcVCbcX/3euL9Y4N4ASwfNCdTmAJM2vxBHpjuNQ== X-Received: by 2002:aca:f58f:: with SMTP id t137-v6mr331453oih.244.1532377300682; Mon, 23 Jul 2018 13:21:40 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id m7-v6sm7929283oia.32.2018.07.23.13.21.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:21:39 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:17:33 -0500 Message-Id: <20180723201748.25573-85-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::230 Subject: [Qemu-devel] [PATCH 84/99] target/arm: Implement FMOV (immediate) for fp16 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: Richard Henderson , =?utf-8?q?Alex_Benn?= =?utf-8?b?w6ll?= , qemu-stable@nongnu.org, Peter Maydell Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Alex Bennée All the hard work is already done by vfp_expand_imm, we just need to make sure we pick up the correct size. Cc: qemu-stable@nongnu.org Reviewed-by: Peter Maydell Signed-off-by: Alex Bennée Tested-by: Alex Bennée Signed-off-by: Richard Henderson Message-id: 20180512003217.9105-11-richard.henderson@linaro.org [rth: Merge unallocated_encoding check with TCGMemOp conversion.] Signed-off-by: Richard Henderson Signed-off-by: Peter Maydell (cherry picked from commit 6ba28ddb9be37bdb67e3e38007a53ccbdcd010df) Signed-off-by: Michael Roth --- target/arm/translate-a64.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 7075f27e05..f4587c3814 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -5431,11 +5431,25 @@ static void disas_fp_imm(DisasContext *s, uint32_t insn) { int rd = extract32(insn, 0, 5); int imm8 = extract32(insn, 13, 8); - int is_double = extract32(insn, 22, 2); + int type = extract32(insn, 22, 2); uint64_t imm; TCGv_i64 tcg_res; + TCGMemOp sz; - if (is_double > 1) { + switch (type) { + case 0: + sz = MO_32; + break; + case 1: + sz = MO_64; + break; + case 3: + sz = MO_16; + if (arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { + break; + } + /* fallthru */ + default: unallocated_encoding(s); return; } @@ -5444,7 +5458,7 @@ static void disas_fp_imm(DisasContext *s, uint32_t insn) return; } - imm = vfp_expand_imm(MO_32 + is_double, imm8); + imm = vfp_expand_imm(sz, imm8); tcg_res = tcg_const_i64(imm); write_fp_dreg(s, rd, tcg_res); From patchwork Mon Jul 23 20:17:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948066 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="D+Xa2p7n"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZDxV3Ffbz9s3N for ; Tue, 24 Jul 2018 07:23:26 +1000 (AEST) Received: from localhost ([::1]:36740 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhiIe-0000mV-2j for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 17:23:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43304) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhKz-0004AO-42 for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:21:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhKy-0005Vk-8V for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:21:45 -0400 Received: from mail-oi0-x22c.google.com ([2607:f8b0:4003:c06::22c]:36040) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhKy-0005VQ-2V; Mon, 23 Jul 2018 16:21:44 -0400 Received: by mail-oi0-x22c.google.com with SMTP id n21-v6so3501487oig.3; Mon, 23 Jul 2018 13:21:44 -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=8+VpBNagLMbQDxPV1taJiZlYPM1RVAX3Yfi4C69c1rI=; b=D+Xa2p7nMMop5XnNCmJo61G5BcBYtHZNnd9xjSU8KgOZLK3BGSmXIQGwPRly+PqCrP +hs6WAk/1GbWTRzJkKk7E0U6bz0gy/M6J/5H3Sw6LbmVx1A6YDYdaF/aLIxX0Y+vHLx8 fQstbXHNsr9kTea2SvBjwEFYcosKNfhmUXsgVn1DLGiknmfymY885AfeBRxICn/FBdC7 Zoh75O+eUpEetvXHa+iuhoHshteZz1FD0rq4KzooBoMph956WnivFee+pcCpD6zB+6Q0 arjzXrIMw3uCFV9OLdiAjh2snptc7ijzp5Ea5bER/ee8LoPiweKochc/PvWkc0dkEtGY /epw== 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=8+VpBNagLMbQDxPV1taJiZlYPM1RVAX3Yfi4C69c1rI=; b=TFReOWXQJo0FO5BhpeR2ehiVjUFfXLSxdWYpJGnUWSwTNgbm+EazWvPRY9PrfrPiEy sPy4IRGxDYF3MYanyQ9teoTqpSvFsT+fM2TMgaVTVT+OyILu6o+o8o6iK7mfoLxgxgIP hQAwF/0z5VNF5Y5JWl36M7hK3q3h7CrQONrkNUjZy7m/HaVpKhZ5mi5YUQ9EIJLg7jhA KIIdvpXY0wuWB753UXvQEQ3Twy1GZEsFCIGGkTvk8w9PreSBXghTI6Y0BEeXmmkPzIC0 ERSHN9osr7xdwHHoqoOwbUQQv+gSrPH8m2H+Tyw29BXZ3pDwa1lIzRPxWKJgCaeClQBo L+PA== X-Gm-Message-State: AOUpUlFLxefl91xcf3DZb7ZwYX8jX4GEXLNbez7fVGNc96GwRfRsGaC+ Ycyy1V8ICwSo1dYkLMTlRRxo/viemEJK3g== X-Google-Smtp-Source: AAOMgpfXrkgAHNf/U42sxxI7N2NWY9kQ0YsO9MdGQQV77jfqCDO0Y8Hrn4nVJjv/Ysvu4nz5jjpbkg== X-Received: by 2002:aca:cd41:: with SMTP id d62-v6mr262099oig.207.1532377302953; Mon, 23 Jul 2018 13:21:42 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id q63-v6sm1776773oia.54.2018.07.23.13.21.41 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:21:41 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:17:34 -0500 Message-Id: <20180723201748.25573-86-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::22c Subject: [Qemu-devel] [PATCH 85/99] target/arm: Fix sqrt_f16 exception raising 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: Richard Henderson , =?utf-8?q?Alex_Benn?= =?utf-8?b?w6ll?= , qemu-stable@nongnu.org, Peter Maydell Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Alex Bennée We are meant to explicitly pass fpst, not cpu_env. Cc: qemu-stable@nongnu.org Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson Signed-off-by: Richard Henderson Tested-by: Alex Bennée Message-id: 20180512003217.9105-12-richard.henderson@linaro.org Signed-off-by: Peter Maydell (cherry picked from commit 905edee9101c54cda5b72286b7f7607cf1c3c4d1) Signed-off-by: Michael Roth --- target/arm/translate-a64.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index f4587c3814..618f5268cc 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -4733,7 +4733,8 @@ static void handle_fp_1src_half(DisasContext *s, int opcode, int rd, int rn) tcg_gen_xori_i32(tcg_res, tcg_op, 0x8000); break; case 0x3: /* FSQRT */ - gen_helper_sqrt_f16(tcg_res, tcg_op, cpu_env); + fpst = get_fpstatus_ptr(true); + gen_helper_sqrt_f16(tcg_res, tcg_op, fpst); break; case 0x8: /* FRINTN */ case 0x9: /* FRINTP */ From patchwork Mon Jul 23 20:17:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948071 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="GW5/hb0L"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZF0d6VdDz9s3N for ; Tue, 24 Jul 2018 07:26:09 +1000 (AEST) Received: from localhost ([::1]:36764 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhiLG-00039B-B3 for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 17:26:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43372) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhL3-0004Fa-Hz for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:21:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhL0-0005XH-Gl for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:21:49 -0400 Received: from mail-oi0-x242.google.com ([2607:f8b0:4003:c06::242]:41193) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhL0-0005Wu-A0; Mon, 23 Jul 2018 16:21:46 -0400 Received: by mail-oi0-x242.google.com with SMTP id k12-v6so3471708oiw.8; Mon, 23 Jul 2018 13:21:46 -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=XsX1EfwzxLyNCkb8W94bPS3FZCOVUqOQnXVP2BsHDx8=; b=GW5/hb0LmMkNUZc8PghYqRxPkQnDpr2G8Vlccw0gWfZycebFdIfIK/8UhIWpkozGil EIGxQuoxxnwXpiQmZ6eDY+T34JYZydtsyHCa3J9uLwZXR0tS+QXYOveIAvRjuIvg35gj V7M+m4CZF1hkw/J08wXRkf3Q+/7f5x0cMQWua/zmJkG/kYeR30rO0TFKWJkYor52sqBr VsXXb8+VP7A9m7GOaGJFhMnSX2cVLYuFNnvpC2D/e0g3qEVkolHWRaNGB0d7xqxRwpQU vYHgTynzk6vzvjbFsjt58H+1ZeyMmoStGM202+YLWBBUJuKvASfs/WY3so3j97LS/UHI KaPg== 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=XsX1EfwzxLyNCkb8W94bPS3FZCOVUqOQnXVP2BsHDx8=; b=Ku5dvInUzezEJilBQuJDJDv/SrrwdKHsckKqbHWs5ZKqSuMMvJeEzaZ7ekJ552tXcA x2Dj8GMthGojs9I3jB1meZNI5ElDak7RmmMjJICwkFeyyyUCG7r6ZXn2mYUHztIxe/OZ W/WZ4oEOHYrn8dD/pNbx85jSJ8J796ONt1OZywpxDw2A2tjXtsVEZa/nVLVwpS1NldAo xGRXB4S7pzUYfrRXiZljSsPI45Y2kgc22cHtD0vVkUrGhFjnXUdg7i3tBnS+fsXpEJ2C ncGYSFIvTc9gXpdniIe+gfqtYSPSXCZgR1LBQwtm2542UNKdtgrTI7FEh0lBUIrm9M77 2vRg== X-Gm-Message-State: AOUpUlGfqixTZzNJ8+cjgeTvPOuvRksGiFYHbSqznLNXLUAttG2HO7MA 4St5nRhQBZ4FKt+DUjgfbdLq8WQHvk1vBg== X-Google-Smtp-Source: AAOMgpfeGgXdgR4OUlZ27XVbshysPOlK2KDSxas1Bn+d8CcQb8VMIO2/EAh4RyDVYkAnuR96PSBxUQ== X-Received: by 2002:aca:4886:: with SMTP id v128-v6mr319298oia.69.1532377305143; Mon, 23 Jul 2018 13:21:45 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id r133-v6sm7512020oia.33.2018.07.23.13.21.43 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:21:44 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:17:35 -0500 Message-Id: <20180723201748.25573-87-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::242 Subject: [Qemu-devel] [PATCH 86/99] hw/isa/superio: Fix inconsistent use of Chardev->be 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: Paolo Bonzini , qemu-stable@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé 4c3119a6e3e and cd9526ab7c0 introduced an incorrect and inconsistent use of Chardev->be. Also, this CharBackend member is private and is not supposed to be accessible. Fix it by removing the inconsistent check. Cc: qemu-stable@nongnu.org Reported-by: Marc-André Lureau Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20180515152500.19460-2-f4bug@amsat.org> Signed-off-by: Paolo Bonzini Reviewed-by: Marc-André Lureau (cherry picked from commit d4c8fcd91abba584f2788dfe5fba5245cea380f0) Conflicts: hw/isa/isa-superio.c * avoid context dep on 9bca0edb28 Signed-off-by: Michael Roth --- hw/isa/isa-superio.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/isa/isa-superio.c b/hw/isa/isa-superio.c index b95608a003..8ae6ea6f7b 100644 --- a/hw/isa/isa-superio.c +++ b/hw/isa/isa-superio.c @@ -43,7 +43,7 @@ static void isa_superio_realize(DeviceState *dev, Error **errp) if (!k->parallel.is_enabled || k->parallel.is_enabled(sio, i)) { /* FIXME use a qdev chardev prop instead of parallel_hds[] */ chr = parallel_hds[i]; - if (chr == NULL || chr->be) { + if (chr == NULL) { name = g_strdup_printf("discarding-parallel%d", i); chr = qemu_chr_new(name, "null"); } else { @@ -81,9 +81,9 @@ static void isa_superio_realize(DeviceState *dev, Error **errp) break; } if (!k->serial.is_enabled || k->serial.is_enabled(sio, i)) { - /* FIXME use a qdev chardev prop instead of serial_hds[] */ + /* FIXME use a qdev chardev prop instead of serial_hd() */ chr = serial_hds[i]; - if (chr == NULL || chr->be) { + if (chr == NULL) { name = g_strdup_printf("discarding-serial%d", i); chr = qemu_chr_new(name, "null"); } else { From patchwork Mon Jul 23 20:17:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948082 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="qbJpmyK6"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZF4T2MmNz9s3N for ; Tue, 24 Jul 2018 07:29:29 +1000 (AEST) Received: from localhost ([::1]:36782 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhiOV-00066g-0j for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 17:29:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43376) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhL3-0004Fj-KY for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:21:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhL2-0005Xu-Fz for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:21:49 -0400 Received: from mail-oi0-x242.google.com ([2607:f8b0:4003:c06::242]:38130) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhL2-0005Xk-9z; Mon, 23 Jul 2018 16:21:48 -0400 Received: by mail-oi0-x242.google.com with SMTP id v8-v6so3486682oie.5; Mon, 23 Jul 2018 13:21:48 -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=lqvoAYL159Jh93cDBgN9Dg7cMaopWq90JlyalzKM9cY=; b=qbJpmyK6QjC8u68Yn4VpU8xzNU2Y5O6fKOF/qvVp2pNGmeJGK0IrT4tlqhmn0AHUTZ xE+VBQRQfJUmOQOnypesBcyympMrr07HtJTe3z1SyqZA0RVtEe0RXHjAUPey7GH/3DgI X0V5IaEe55enRc4PbyXBf+evKagmZE8xDNqH6AjE/JVE7iMqCNlzfPPCRikMf8YvPsit uiVZ1dRz8SCEDgHRnHE3HkkDh0iF/fUZKaJ0hPGly+sZkX0ZSDrgDAfnv4f8nyp4g0wY Y8DnG0AQYQCvWnjOaxtimLKMzCl50TmuaHlceo5nxKUwhbzVi0TAlijPRvv9xaFvqbZD 6Tsw== 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=lqvoAYL159Jh93cDBgN9Dg7cMaopWq90JlyalzKM9cY=; b=sUhpxh1E+4pDgoP1w2xmng3HhrbR5I1WZD6VlWkBgouAcOq7H6OY6bgzEDQFQLMZl8 JxHOapDNDt0VsrFHVJjDiTEWST1WpCz0NjwJYVeyHL9bkdV6Nfcy8L9ZJwe8AZQatOGm sG8tP0kk6/lvSFZWD0ot2SsxhqxGDlPsYTjev5OrFNO02SHKd5bOFQPxdPbMa3ec6qBc H+KiSCTLSKN2uLhuB7nID4o90zIquUuKiur8tCwJnt9iYIc5cezsWOFoQtVkQstr1y0H EqYPVFwny5GUzQrqfJOCqJ6QjlmProkyFiBMOEnsUifsLvuEBCSq0UQI74B59S8FhCQm bZFA== X-Gm-Message-State: AOUpUlG/7ZSya7CGvSPz6s/3nBQw/mB9JtCaoSjruAREiJnkg2ymmGVd EyWw24ap23gGVOk6V/Tz+4v7p/qhqVIpDA== X-Google-Smtp-Source: AAOMgpfpUNuOOVw8nqGeF/n/55onmDcGBGYJeshXgqfrxPGPQxUTLSyA214C+IQY7/vepam4wueK1g== X-Received: by 2002:aca:c141:: with SMTP id r62-v6mr272904oif.179.1532377307152; Mon, 23 Jul 2018 13:21:47 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id e204-v6sm2764896oif.21.2018.07.23.13.21.45 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:21:46 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:17:36 -0500 Message-Id: <20180723201748.25573-88-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::242 Subject: [Qemu-devel] [PATCH 87/99] mux: fix ctrl-a b again 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: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , qemu-stable@nongnu.org, Paolo Bonzini Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Marc-André Lureau Commit fb5e19d2e1472e96d72d5e4d89c20033f8ab345c originally fixed the regression, but was inadvertently broken again in merge commit 2d6752d38d8acda. Fixes: https://bugs.launchpad.net/qemu/+bug/1654137 Cc: qemu-stable@nongnu.org Signed-off-by: Marc-André Lureau Reviewed-by: Peter Maydell Message-Id: <20180515152500.19460-3-f4bug@amsat.org> Signed-off-by: Paolo Bonzini (cherry picked from commit eeaa6715050ed3f9cbedd322220f31570a503217) Signed-off-by: Michael Roth --- chardev/char-mux.c | 1 + tests/test-char.c | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/chardev/char-mux.c b/chardev/char-mux.c index 1b925c8dec..6055e76293 100644 --- a/chardev/char-mux.c +++ b/chardev/char-mux.c @@ -304,6 +304,7 @@ void mux_set_focus(Chardev *chr, int focus) } d->focus = focus; + chr->be = d->backends[focus]; mux_chr_send_event(d, d->focus, CHR_EVENT_MUX_IN); } diff --git a/tests/test-char.c b/tests/test-char.c index 306c728335..b81b1e8e05 100644 --- a/tests/test-char.c +++ b/tests/test-char.c @@ -214,6 +214,10 @@ static void char_mux_test(void) g_assert_cmpint(h2.last_event, ==, -1); /* switch focus */ + qemu_chr_be_write(base, (void *)"\1b", 2); + g_assert_cmpint(h1.last_event, ==, 42); + g_assert_cmpint(h2.last_event, ==, CHR_EVENT_BREAK); + qemu_chr_be_write(base, (void *)"\1c", 2); g_assert_cmpint(h1.last_event, ==, CHR_EVENT_MUX_IN); g_assert_cmpint(h2.last_event, ==, CHR_EVENT_MUX_OUT); @@ -227,6 +231,10 @@ static void char_mux_test(void) g_assert_cmpstr(h1.read_buf, ==, "hello"); h1.read_count = 0; + qemu_chr_be_write(base, (void *)"\1b", 2); + g_assert_cmpint(h1.last_event, ==, CHR_EVENT_BREAK); + g_assert_cmpint(h2.last_event, ==, CHR_EVENT_MUX_OUT); + /* remove first handler */ qemu_chr_fe_set_handlers(&chr_be1, NULL, NULL, NULL, NULL, NULL, NULL, true); From patchwork Mon Jul 23 20:17:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948081 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="QTcK5EH8"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZF4G2CFwz9s3N for ; Tue, 24 Jul 2018 07:29:18 +1000 (AEST) Received: from localhost ([::1]:36781 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhiOJ-0005wY-RX for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 17:29:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43399) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhL5-0004HV-8j for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:21:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhL4-0005Yg-Bm for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:21:51 -0400 Received: from mail-oi0-x232.google.com ([2607:f8b0:4003:c06::232]:42550) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhL4-0005YV-62; Mon, 23 Jul 2018 16:21:50 -0400 Received: by mail-oi0-x232.google.com with SMTP id n84-v6so3474865oib.9; Mon, 23 Jul 2018 13:21:50 -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=B3mPa80GccDx82r8PLfrwi9rXV+l9VnjPsY4TDa0+QU=; b=QTcK5EH8uR62WnR6U6mFdmZCOgaWpb1P3DI5dIrFD7J9ZIzNWQT40SQkAhNh2cdfLP Q0gjZD3D91lUbBxWgzJjRt5asE6TCcwWJ8Ofhy6Uuzgaob9kISHzIn+WHEj0aqTNGxKW 8vLKooCogIQGeYZeTGn0CLmtEgnKaES8ZqRlgnIbVJpid6s5nyaQE+Lim/2BK2tXf+6a 3wskdJHHouyDW1kA8TtRQH06mORlwyfQFyy+ntkMthekA1vtUw/017mwH665rbsUR2bQ rytxGZ1wQTQ97yyypCSVg3Ng9jzQ9na6fT6F/Y/KArpgThMGl/PaZn3CO9Xnz6D1SjaB 7Zkg== 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=B3mPa80GccDx82r8PLfrwi9rXV+l9VnjPsY4TDa0+QU=; b=ZmaAyigHy/um6BbdmfAG/Rb/JWlkgF9niJz9/7CHx75v3ahkm6EIuDk2GvhbHoqtel uuDZdM7B+1CRgx3EAC6E1MR8lxHu9+stqUHpdzmCP6ulPycRnz0VCgCNB13URWMZP3NM PH4ZaKPduIHc01ZNkYDNCNt8JAmuCTgF8z/0KrwWeMoLFAwpEoWbRdV8BV/FrSCn27vV wXT/zLAr6UBR/GTvz51KWaHaTfTlwDNQA+C3O8vihnm/IftkRc1kNXHP948FUM4RE/6R D98q7Et1lmeMpBBjjQsvvUukY2WT/lNGS5+ErAxkEjjAoj+Uu7S/Ow6SZs1sHeotqkw0 kzFQ== X-Gm-Message-State: AOUpUlFAYSIiMV3wCISD3cHMgZNQDkWtNJ2MBSjAggh8CXG581djG6kr qfmHfwrV2y7KejdRhRCc/d43LjSSGq0H0w== X-Google-Smtp-Source: AAOMgpe7FRkE7EOOHULG7xc2YItivj002vBssku6yraG36+/47818zSjFucB1rOcRUfoRUVU6TeqZA== X-Received: by 2002:aca:c355:: with SMTP id t82-v6mr284623oif.327.1532377309079; Mon, 23 Jul 2018 13:21:49 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id i204-v6sm19825050oia.41.2018.07.23.13.21.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:21:47 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:17:37 -0500 Message-Id: <20180723201748.25573-89-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::232 Subject: [Qemu-devel] [PATCH 88/99] nfs: Remove processed options from QDict 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: Kevin Wolf , Jeff Cody , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Kevin Wolf Commit c22a03454 QAPIfied option parsing in the NFS block driver, but forgot to remove all the options we processed. Therefore, we get an error in bdrv_open_inherit(), which thinks the remaining options are invalid. Trying to open an NFS image will result in an error like this: Block protocol 'nfs' doesn't support the option 'server.host' Remove all options from the QDict to make the NFS driver work again. Cc: qemu-stable@nongnu.org Signed-off-by: Kevin Wolf Message-id: 20180516160816.26259-1-kwolf@redhat.com Reviewed-by: Eric Blake Reviewed-by: Jeff Cody Signed-off-by: Jeff Cody (cherry picked from commit c82be42cc803b36fd7aed5dceec68312c7056fd5) Signed-off-by: Michael Roth --- block/nfs.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/block/nfs.c b/block/nfs.c index 2577df4b26..dc12d5000d 100644 --- a/block/nfs.c +++ b/block/nfs.c @@ -557,6 +557,7 @@ static BlockdevOptionsNfs *nfs_options_qdict_to_qapi(QDict *options, BlockdevOptionsNfs *opts = NULL; QObject *crumpled = NULL; Visitor *v; + const QDictEntry *e; Error *local_err = NULL; crumpled = qdict_crumple(options, errp); @@ -573,6 +574,12 @@ static BlockdevOptionsNfs *nfs_options_qdict_to_qapi(QDict *options, return NULL; } + /* Remove the processed options from the QDict (the visitor processes + * _all_ options in the QDict) */ + while ((e = qdict_first(options))) { + qdict_del(options, e->key); + } + return opts; } From patchwork Mon Jul 23 20:17:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948085 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="n6YGcnQ7"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZF7d1rl9z9s3Z for ; Tue, 24 Jul 2018 07:32:13 +1000 (AEST) Received: from localhost ([::1]:36799 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhiR8-00008K-Pb for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 17:32:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43442) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhL7-0004KG-P5 for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:21:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhL6-0005bb-Pv for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:21:53 -0400 Received: from mail-oi0-x235.google.com ([2607:f8b0:4003:c06::235]:34581) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhL6-0005aB-L0; Mon, 23 Jul 2018 16:21:52 -0400 Received: by mail-oi0-x235.google.com with SMTP id 13-v6so3512136ois.1; Mon, 23 Jul 2018 13:21:52 -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=4SyDR+Kw4vS5a97h8bY2MM7EppQZY1jY1eIWeTlc2fc=; b=n6YGcnQ7ULlYVoMfSM4T04hiNzSTqYxH+A3V14rmkOODtqOc4XPTNHsgrRDmkYYc2Z ZBGfwUc8A+/4EyhIWYCO1AS7LieD82d3RmLB2kRrWMmTyGcf5qGHzgT/En3tmZdUsUun HaEKuU871sz9/HtTwIpFSnvD2xbgA2suUOXC0OXSNLXTsh2CHlQjA8ethDAmBlVaGyuP iOeicUtwr7zOdCAgjGsqqD6INTVAwXOhLpmFHD/skWAoNVEDLMc9mrliGtjsPevsEyQk IU3oubEcOHBMEACz7B9++tMSAiIPRm5U9EkYXYcHo6RFMRwso4q1mWf02L8TzRHKRjcY Czbw== 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=4SyDR+Kw4vS5a97h8bY2MM7EppQZY1jY1eIWeTlc2fc=; b=soNR7IuFXvYnUokvTA6rzNCQ/hNi0BJdmQ4/I0Wqk8ePQ5CtlNyx53+SjL/NWfIAIe PRnyWQuPordd+XTfFgiB2cVAFBnjLLnqQJMTRIlYl/pUp27w4gMiH8YYGxXR+uoUWPG+ 7FBzlz5/4YfNAPel+e3E109CdteZUpcxDXK7CUKTcqTsd0Rffifp/t8r3YqmscJHgiif uqvuhioEhuUUYIH28j0XbxW6kgp8HHZ+k4DlimwmhQ9HziZ733JRJ/LYpf0AL/P9uehb qaFfI10UB1g5OoLQvwXfiAce37iHJpkfReGPBVa+WjKQmOOG46LivgrGergT/qAscBkM Mxvw== X-Gm-Message-State: AOUpUlFxqfNOjcRD4A91eqNkoH2Yl7f+hCHO3Z119WAlYdIl3o5eEW3G iXux1/syWl523lA2coKFSfEFTg4jkcqoiw== X-Google-Smtp-Source: AAOMgpduSZJX0piHRpqIAYQhCXbpIKiJgLizpfT+6Dm3e9VLkJql6vXLejs7oK//nJlJZJqrrSC1lg== X-Received: by 2002:aca:ea57:: with SMTP id i84-v6mr295050oih.266.1532377311430; Mon, 23 Jul 2018 13:21:51 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id s142-v6sm8877489oie.48.2018.07.23.13.21.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:21:50 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:17:38 -0500 Message-Id: <20180723201748.25573-90-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::235 Subject: [Qemu-devel] [PATCH 89/99] replace functions which are only available in glib-2.24 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: Olaf Hering , Michael Tokarev , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Olaf Hering Currently the minimal supported version of glib is 2.22. Since testing is done with a glib that claims to be 2.22, but in fact has APIs from newer version of glib, this bug was not caught during submit of the patch referenced below. Replace g_realloc_n, which is available only since 2.24, with g_renew. Fixes commit 418026ca43 ("util: Introduce vfio helpers") Signed-off-by: Olaf Hering Reviewed-by: Thomas Huth Reviewed-by: Cornelia Huck Signed-off-by: Michael Tokarev CC: qemu-stable@nongnu.org (cherry picked from commit d29eb678bcfbb2fbf4b79423797253ee02f5c6cf) Signed-off-by: Michael Roth --- util/vfio-helpers.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c index 006674c916..1d9272efa4 100644 --- a/util/vfio-helpers.c +++ b/util/vfio-helpers.c @@ -522,8 +522,7 @@ static IOVAMapping *qemu_vfio_add_mapping(QEMUVFIOState *s, assert(index >= 0); s->nr_mappings++; - s->mappings = g_realloc_n(s->mappings, sizeof(s->mappings[0]), - s->nr_mappings); + s->mappings = g_renew(IOVAMapping, s->mappings, s->nr_mappings); insert = &s->mappings[index]; shift = s->nr_mappings - index - 1; if (shift) { @@ -577,8 +576,7 @@ static void qemu_vfio_undo_mapping(QEMUVFIOState *s, IOVAMapping *mapping, memmove(mapping, &s->mappings[index + 1], sizeof(s->mappings[0]) * (s->nr_mappings - index - 1)); s->nr_mappings--; - s->mappings = g_realloc_n(s->mappings, sizeof(s->mappings[0]), - s->nr_mappings); + s->mappings = g_renew(IOVAMapping, s->mappings, s->nr_mappings); } /* Check if the mapping list is (ascending) ordered. */ From patchwork Mon Jul 23 20:17:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948086 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="bqcEBdZA"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZF7h1T0Zz9s3Z for ; Tue, 24 Jul 2018 07:32:16 +1000 (AEST) Received: from localhost ([::1]:36802 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhiRB-0000Dy-LI for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 17:32:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43470) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhL9-0004M7-FV for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:21:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhL8-0005dn-K3 for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:21:55 -0400 Received: from mail-oi0-x241.google.com ([2607:f8b0:4003:c06::241]:37289) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhL8-0005dN-FZ; Mon, 23 Jul 2018 16:21:54 -0400 Received: by mail-oi0-x241.google.com with SMTP id k81-v6so3485786oib.4; Mon, 23 Jul 2018 13:21:54 -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=ISv87QyZL4IXVgflJF8x7nhss/gySbFuvqHcd8Zg8uk=; b=bqcEBdZAZjQfevvOqNFP/ydGhrvAyao9vw2NRQMIKRudc/m6fULCV3GGUxTsLKZZCX c2MdLb3GsGHgBsZJTUZEJ8uWNjjx/+HLPh/CAQf7BaDjdwEoum4hzy3F+5bQenPu0aAt OAONgNpJ0TlSxYUzu61gbpCiDh/Cd6t77Iw5i01Sh5W0hIhVJVkeapGK0vqDzGn1tG5H JA7xoAifCuQcsgd4gGQPS3WJE2a3Sg/j3vQsykxJsCQTV+LPAkwTxh/DhC0Cxc0oIZID 9wBXMhxwx+dmbg/0JPAZKvAcpblNixmZ6kpi1ix9jm2kClUU0RY4f+2Q7HCpUxgSRrLh bxUA== 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=ISv87QyZL4IXVgflJF8x7nhss/gySbFuvqHcd8Zg8uk=; b=ctIb5LbTTfAzAVhzzkYhc8nLlRxKsBJoLQvIZ9GSv3Luh0VFaayKM1W3c425cmtUzJ VTUZMWVUpRe+uzNESF80vq6E6USZaj20R7Iwc7xWNoSrX+gCqiUSkSsVsD3XZAIr2C6r t4LZHcaW3tLyQIh97vIc1z0HCrO4UMgRDPKk+nny1Rz9zY+DTUOu9wKZDUjPzFycsZYd YiXHODD/jGmqeHZn1wOEvWLZ+2JeAQ5W8Apunozo+LVq9A3SYc/zjpOYVdflWJhc6nUU vaZTyGE7akWgv5l4BLqEnSGym3cuGxPPrNgeTmHK4njHbbX8YebfZsk9ZlcBJXeL87TD Gv+A== X-Gm-Message-State: AOUpUlHRpg54xjM8SPcWqdvJvK+y/elO8A44XZGT+CQdY7BYSRlZgrek S8tgJ2GhqG1DYxoKzrtlt9MAy3sanx9g2Q== X-Google-Smtp-Source: AAOMgpedXcjI8oYzgOrbVTU4YGNZcaJB0Lepjg1paUtsSnpTiB7NkHwFetvRdmnoSaGPPzw7DPzb0Q== X-Received: by 2002:aca:b208:: with SMTP id b8-v6mr315442oif.144.1532377313376; Mon, 23 Jul 2018 13:21:53 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id u144-v6sm8706925oie.14.2018.07.23.13.21.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:21:52 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:17:39 -0500 Message-Id: <20180723201748.25573-91-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::241 Subject: [Qemu-devel] [PATCH 90/99] vfio/pci: Default display option to "off" 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: Alex Williamson , qemu-stable@nongnu.org, Gerd Hoffmann Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Alex Williamson Commit a9994687cb9b ("vfio/display: core & wireup") added display support to vfio-pci with the default being "auto", which breaks existing VMs when the vGPU requires GL support but had no previous requirement for a GL compatible configuration. "Off" is the safer default as we impose no new requirements to VM configurations. Fixes: a9994687cb9b ("vfio/display: core & wireup") Cc: qemu-stable@nongnu.org Cc: Gerd Hoffmann Signed-off-by: Alex Williamson (cherry picked from commit 8151a9c56d31eeeea872b8103c8b86d03c411667) Signed-off-by: Michael Roth --- hw/vfio/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index b9bc6cd310..1a806ea684 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -3154,7 +3154,7 @@ static Property vfio_pci_dev_properties[] = { DEFINE_PROP_PCI_HOST_DEVADDR("host", VFIOPCIDevice, host), DEFINE_PROP_STRING("sysfsdev", VFIOPCIDevice, vbasedev.sysfsdev), DEFINE_PROP_ON_OFF_AUTO("display", VFIOPCIDevice, - display, ON_OFF_AUTO_AUTO), + display, ON_OFF_AUTO_OFF), DEFINE_PROP_UINT32("x-intx-mmap-timeout-ms", VFIOPCIDevice, intx.mmap_timeout, 1100), DEFINE_PROP_BIT("x-vga", VFIOPCIDevice, features, From patchwork Mon Jul 23 20:17:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948094 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ON6wYdSg"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZFKJ4JQbz9s3N for ; Tue, 24 Jul 2018 07:40:36 +1000 (AEST) Received: from localhost ([::1]:36861 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhiZG-0001UP-79 for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 17:40:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43522) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhLE-0004Q4-2k for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:22:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhLD-0005gc-4g for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:21:59 -0400 Received: from mail-oi0-x235.google.com ([2607:f8b0:4003:c06::235]:39371) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhLC-0005gM-Us; Mon, 23 Jul 2018 16:21:59 -0400 Received: by mail-oi0-x235.google.com with SMTP id d189-v6so3490426oib.6; Mon, 23 Jul 2018 13:21:58 -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=oAlSN3aovbzYgH1i2BDjkdCAxHzSEFSOL/6OpmZBUnU=; b=ON6wYdSgBsiv6H11belnQTiGeJ18Tyypw6GPn7d2hz2osWimo9bybRvkdThMkq3RPL aJknTT0/Ph3Ep21pHaCaZ/EJDBn+8DCLcbskUejg3aJm2uTa+S32ANuyu4MnzNfbz7/q /Ty7Wc5nR+lzEaMaiaU4nRFlxWH+5SjyHkfGt/HpzLWy9N5gFDzbirG1beCtR5ozCs++ SASo6LcDXVimSizBUZaCZxQ6FZK3S4I7+DwFysg7d/8e2D4RvzK/pDoU1qKwzHOnbWGW HrcXdjn2OYpgz4rkr6VZxL3Zg9zYJKHnYr9A0OucXYuZdEEunBThGNtE/WcqioBmdHp3 yQRg== 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=oAlSN3aovbzYgH1i2BDjkdCAxHzSEFSOL/6OpmZBUnU=; b=RBpFfopCSE6Kc3N1mLUpVtbRDNvU8OYi9TJYCkzGZAcfeB0KK+1IQR8GSZzEPgQJGs aXNA9bmKKNc811ylt/4Xm8sQ124RRN0a5dsBaH9NEv8bZW+fH4eKeeENY2OIsjrSyOOR 3w8FRMByOMDEobMQOQiosRGdgW9BVL2TJmN3aOnBPK2KNm6oIZ7xVKXoAZO3Ax7n6BJA 7ahXeHNCLKiMtMOZ7zyqkLSNeVpmw1SFf5n17AsBy++EQc8ih/WtAvqgpx/x6r3Mr1as i8VKwkInKmBZSJi4ez/6YmKllrxsvurITNjSte5/VQTbylU07JTSw2RuhJWjPbzjig+/ Lp/g== X-Gm-Message-State: AOUpUlHTmRhx1fvqQ8VFL3evSOUamrtpZyKb9rZYeA/PLZ8jFHOUI6kY bAYVQl4qede6tYxGZR4zVwMwMXbIRF+Zsg== X-Google-Smtp-Source: AAOMgpfWPZn1J/sy3LRDpYpU/dWPXrSLrzCQjTY1og7VHtt59eoRzPFDj2HU28K4UR9G5tq2EOVWVw== X-Received: by 2002:aca:fd01:: with SMTP id b1-v6mr253538oii.307.1532377317818; Mon, 23 Jul 2018 13:21:57 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id r133-v6sm7512308oia.33.2018.07.23.13.21.56 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:21:56 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:17:40 -0500 Message-Id: <20180723201748.25573-92-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::235 Subject: [Qemu-devel] [PATCH 91/99] migration/block-dirty-bitmap: fix dirty_bitmap_load 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: Vladimir Sementsov-Ogievskiy , qemu-stable@nongnu.org, "Dr . David Alan Gilbert" Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Vladimir Sementsov-Ogievskiy dirty_bitmap_load_header return code is obtained but not handled. Fix this. Bug was introduced in b35ebdf076d697bc "migration: add postcopy migration of dirty bitmaps" with the whole function. Signed-off-by: Vladimir Sementsov-Ogievskiy Message-Id: <20180530112424.204835-1-vsementsov@virtuozzo.com> Reviewed-by: Eric Blake Reviewed-by: John Snow Signed-off-by: Dr. David Alan Gilbert (cherry picked from commit a36f6ff46f115672cf86d0e1e7cdb1c2fa4d304b) Signed-off-by: Michael Roth --- migration/block-dirty-bitmap.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/migration/block-dirty-bitmap.c b/migration/block-dirty-bitmap.c index 8819aabe3a..2c541c985d 100644 --- a/migration/block-dirty-bitmap.c +++ b/migration/block-dirty-bitmap.c @@ -672,6 +672,9 @@ static int dirty_bitmap_load(QEMUFile *f, void *opaque, int version_id) do { ret = dirty_bitmap_load_header(f, &s); + if (ret < 0) { + return ret; + } if (s.flags & DIRTY_BITMAP_MIG_FLAG_START) { ret = dirty_bitmap_load_start(f, &s); From patchwork Mon Jul 23 20:17:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948096 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="CVYcqBBI"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZFNM1RmJz9s3Z for ; Tue, 24 Jul 2018 07:43:15 +1000 (AEST) Received: from localhost ([::1]:36889 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhibo-0003po-Qw for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 17:43:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43550) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhLH-0004RB-7I for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:22:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhLF-0005hM-M1 for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:22:03 -0400 Received: from mail-oi0-x242.google.com ([2607:f8b0:4003:c06::242]:40416) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhLF-0005hG-EC; Mon, 23 Jul 2018 16:22:01 -0400 Received: by mail-oi0-x242.google.com with SMTP id w126-v6so3485384oie.7; Mon, 23 Jul 2018 13:22:01 -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=eyN2xqzxccTS5JZm6NGArfM+iXBtgcgfJ9nYhuRKytg=; b=CVYcqBBIHpbgV/1+8ESTQJhrGxpcQG3Qy9rvftIp16dHZ/RgTBKsmAE4wH80jcShct w3yrO5SblVEXmKRQjZIxqB7AedkPu1r8d1GOK/6zL+xFMHSpGQt480vUfl0ipAosvyyY PJZ/j83RockF6HPyayE4rv0nc+yVBGnqkgV9eyeudY6EwAO/zqU1u6HX6dbsSk/YdbwE 72XYK+6A9HXxA4aqOCjvsqaRdMPzA0FCGyNnCW+JUxyBX3DiZ9j6+t0Rsf2eLRySGoR0 Uqxn74ViVwsOYveCLnsBqwaRmWHHtYmymjQawMiSP8TFqUJuV8UHGhw/aWUK18GMhT3r Cb3Q== 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=eyN2xqzxccTS5JZm6NGArfM+iXBtgcgfJ9nYhuRKytg=; b=BPsPV6VdHCqE2IMRy0p7A2lMtag+dg1JdIqA56BOVEGgR5fdqFiIjI4TShItzuW1Ub 4RKh3IETttFFHQnJTKjpIr6CezjPJliNsXuJHdy4yLotJtaWYuwQP8m8e9LZWx/H9p0B CHIY7VFKU3OE5Oy/tM+TmVaMZFXtvNQwqnG5rR42eI+RzrgUz74SrNgNyDlKDWth9Lh0 CuCKnsaJbzAiSpmdgawQkHjRqs+oecHkJv928SUE5rVyFhk/6A6+89tWVg9/MEufSpoy Shn/JFpuHiGk8dYafR/s3tahOs+uVVyCdUfS16kSG9CwnR0VEhXqsXYinIGC58XEqPDf jlBQ== X-Gm-Message-State: AOUpUlGS99lJT08lt77CUCNvvyOOhgoIaGYZe6WQbfnx+94ge1DOMlbl /cFW8M2yBxecf68n7QIZtin4Liw1nOPmSg== X-Google-Smtp-Source: AAOMgpd7SJ4B6BOQCHd7oh3ECTg7LwqEKlOuCKxVAspPdeqN2lZm/tPkpg9KWUIW92ndeCRuGEKyZA== X-Received: by 2002:aca:4808:: with SMTP id v8-v6mr261314oia.259.1532377320130; Mon, 23 Jul 2018 13:22:00 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id a8-v6sm7950609oia.24.2018.07.23.13.21.58 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:21:59 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:17:41 -0500 Message-Id: <20180723201748.25573-93-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::242 Subject: [Qemu-devel] [PATCH 92/99] tcg: Reduce max TB opcode count 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: Richard Henderson , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Also, assert that we don't overflow any of two different offsets into the TB. Both unwind and goto_tb both record a uint16_t for later use. This fixes an arm-softmmu test case utilizing NEON in which there is a TB generated that runs to 7800 opcodes, and compiles to 96k on an x86_64 host. This overflows the 16-bit offset in which we record the goto_tb reset offset. Because of that overflow, we install a jump destination that goes to neverland. Boom. With this reduced op count, the same TB compiles to about 48k for aarch64, ppc64le, and x86_64 hosts, and neither assertion fires. Cc: qemu-stable@nongnu.org Reported-by: "Jason A. Donenfeld" Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson (cherry picked from commit 9f754620651d3432114f4bb89c7f12cbea814b3e) Signed-off-by: Michael Roth --- tcg/aarch64/tcg-target.inc.c | 2 +- tcg/arm/tcg-target.inc.c | 2 +- tcg/i386/tcg-target.inc.c | 2 +- tcg/mips/tcg-target.inc.c | 2 +- tcg/ppc/tcg-target.inc.c | 4 ++-- tcg/s390/tcg-target.inc.c | 2 +- tcg/sparc/tcg-target.inc.c | 4 ++-- tcg/tcg.c | 13 ++++++++++++- tcg/tcg.h | 6 ++++-- tcg/tci/tcg-target.inc.c | 2 +- 10 files changed, 26 insertions(+), 13 deletions(-) diff --git a/tcg/aarch64/tcg-target.inc.c b/tcg/aarch64/tcg-target.inc.c index be3192078d..4562d36d1b 100644 --- a/tcg/aarch64/tcg-target.inc.c +++ b/tcg/aarch64/tcg-target.inc.c @@ -1733,7 +1733,7 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, tcg_out_insn(s, 3305, LDR, offset, TCG_REG_TMP); } tcg_out_insn(s, 3207, BR, TCG_REG_TMP); - s->tb_jmp_reset_offset[a0] = tcg_current_code_size(s); + set_jmp_reset_offset(s, a0); break; case INDEX_op_goto_ptr: diff --git a/tcg/arm/tcg-target.inc.c b/tcg/arm/tcg-target.inc.c index 56a32a470f..e1fbf465cb 100644 --- a/tcg/arm/tcg-target.inc.c +++ b/tcg/arm/tcg-target.inc.c @@ -1822,7 +1822,7 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcode opc, tcg_out_movi32(s, COND_AL, base, ptr - dil); } tcg_out_ld32_12(s, COND_AL, TCG_REG_PC, base, dil); - s->tb_jmp_reset_offset[args[0]] = tcg_current_code_size(s); + set_jmp_reset_offset(s, args[0]); } break; case INDEX_op_goto_ptr: diff --git a/tcg/i386/tcg-target.inc.c b/tcg/i386/tcg-target.inc.c index 5357909fff..ccde8801a5 100644 --- a/tcg/i386/tcg-target.inc.c +++ b/tcg/i386/tcg-target.inc.c @@ -2245,7 +2245,7 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcode opc, tcg_out_modrm_offset(s, OPC_GRP5, EXT5_JMPN_Ev, -1, (intptr_t)(s->tb_jmp_target_addr + a0)); } - s->tb_jmp_reset_offset[a0] = tcg_current_code_size(s); + set_jmp_reset_offset(s, a0); break; case INDEX_op_goto_ptr: /* jmp to the given host address (could be epilogue) */ diff --git a/tcg/mips/tcg-target.inc.c b/tcg/mips/tcg-target.inc.c index ca5f1d4894..cff525373b 100644 --- a/tcg/mips/tcg-target.inc.c +++ b/tcg/mips/tcg-target.inc.c @@ -1744,7 +1744,7 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcode opc, tcg_out_opc_reg(s, OPC_JR, 0, TCG_TMP0, 0); } tcg_out_nop(s); - s->tb_jmp_reset_offset[a0] = tcg_current_code_size(s); + set_jmp_reset_offset(s, a0); break; case INDEX_op_goto_ptr: /* jmp to the given host address (could be epilogue) */ diff --git a/tcg/ppc/tcg-target.inc.c b/tcg/ppc/tcg-target.inc.c index 86f7de5f7e..c2f729ee8f 100644 --- a/tcg/ppc/tcg-target.inc.c +++ b/tcg/ppc/tcg-target.inc.c @@ -2025,10 +2025,10 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg *args, } tcg_out32(s, MTSPR | RS(TCG_REG_TB) | CTR); tcg_out32(s, BCCTR | BO_ALWAYS); - s->tb_jmp_reset_offset[args[0]] = c = tcg_current_code_size(s); + set_jmp_reset_offset(s, args[0]); if (USE_REG_TB) { /* For the unlinked case, need to reset TCG_REG_TB. */ - c = -c; + c = -tcg_current_code_size(s); assert(c == (int16_t)c); tcg_out32(s, ADDI | TAI(TCG_REG_TB, TCG_REG_TB, c)); } diff --git a/tcg/s390/tcg-target.inc.c b/tcg/s390/tcg-target.inc.c index 9af6dcef05..17c435ade5 100644 --- a/tcg/s390/tcg-target.inc.c +++ b/tcg/s390/tcg-target.inc.c @@ -1783,7 +1783,7 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcode opc, /* and go there */ tcg_out_insn(s, RR, BCR, S390_CC_ALWAYS, TCG_REG_TB); } - s->tb_jmp_reset_offset[a0] = tcg_current_code_size(s); + set_jmp_reset_offset(s, a0); /* For the unlinked path of goto_tb, we need to reset TCG_REG_TB to the beginning of this TB. */ diff --git a/tcg/sparc/tcg-target.inc.c b/tcg/sparc/tcg-target.inc.c index bc673bd8c6..04bdc3df5e 100644 --- a/tcg/sparc/tcg-target.inc.c +++ b/tcg/sparc/tcg-target.inc.c @@ -1388,12 +1388,12 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, tcg_out_arithi(s, TCG_REG_G0, TCG_REG_TB, 0, JMPL); tcg_out_nop(s); } - s->tb_jmp_reset_offset[a0] = c = tcg_current_code_size(s); + set_jmp_reset_offset(s, a0); /* For the unlinked path of goto_tb, we need to reset TCG_REG_TB to the beginning of this TB. */ if (USE_REG_TB) { - c = -c; + c = -tcg_current_code_size(s); if (check_fit_i32(c, 13)) { tcg_out_arithi(s, TCG_REG_TB, TCG_REG_TB, c, ARITH_ADD); } else { diff --git a/tcg/tcg.c b/tcg/tcg.c index 66997cc653..9c1de541d6 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -293,6 +293,14 @@ TCGLabel *gen_new_label(void) return l; } +static void set_jmp_reset_offset(TCGContext *s, int which) +{ + size_t off = tcg_current_code_size(s); + s->tb_jmp_reset_offset[which] = off; + /* Make sure that we didn't overflow the stored offset. */ + assert(s->tb_jmp_reset_offset[which] == off); +} + #include "tcg-target.inc.c" static void tcg_region_bounds(size_t curr_region, void **pstart, void **pend) @@ -3354,7 +3362,10 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) break; case INDEX_op_insn_start: if (num_insns >= 0) { - s->gen_insn_end_off[num_insns] = tcg_current_code_size(s); + size_t off = tcg_current_code_size(s); + s->gen_insn_end_off[num_insns] = off; + /* Assert that we do not overflow our stored offset. */ + assert(s->gen_insn_end_off[num_insns] == off); } num_insns++; for (i = 0; i < TARGET_INSN_START_WORDS; ++i) { diff --git a/tcg/tcg.h b/tcg/tcg.h index 17cf764565..755860e50d 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -848,9 +848,11 @@ static inline bool tcg_op_buf_full(void) /* This is not a hard limit, it merely stops translation when * we have produced "enough" opcodes. We want to limit TB size * such that a RISC host can reasonably use a 16-bit signed - * branch within the TB. + * branch within the TB. We also need to be mindful of the + * 16-bit unsigned offsets, TranslationBlock.jmp_reset_offset[] + * and TCGContext.gen_insn_end_off[]. */ - return tcg_ctx->nb_ops >= 8000; + return tcg_ctx->nb_ops >= 4000; } /* pool based memory allocation */ diff --git a/tcg/tci/tcg-target.inc.c b/tcg/tci/tcg-target.inc.c index cc949bea85..62ed097254 100644 --- a/tcg/tci/tcg-target.inc.c +++ b/tcg/tci/tcg-target.inc.c @@ -574,7 +574,7 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg *args, /* Indirect jump method. */ TODO(); } - s->tb_jmp_reset_offset[args[0]] = tcg_current_code_size(s); + set_jmp_reset_offset(s, args[0]); break; case INDEX_op_br: tci_out_label(s, arg_label(args[0])); From patchwork Mon Jul 23 20:17:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948092 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="nA0jY4rs"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZFGv6lVFz9s3Z for ; Tue, 24 Jul 2018 07:38:31 +1000 (AEST) Received: from localhost ([::1]:36852 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhiXF-0006w5-J9 for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 17:38:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43592) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhLL-0004Vj-4P for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:22:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhLH-0005iL-V0 for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:22:07 -0400 Received: from mail-oi0-x22e.google.com ([2607:f8b0:4003:c06::22e]:38220) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhLH-0005i4-PS; Mon, 23 Jul 2018 16:22:03 -0400 Received: by mail-oi0-x22e.google.com with SMTP id v8-v6so3487938oie.5; Mon, 23 Jul 2018 13:22: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=uhtN4B6lzqouWLStU3aNeInL/uWL5A7nLQfzGQKmqwo=; b=nA0jY4rspZLfcEBKhKstTjdrDd4BL6OT/OPacaDzkKhckXaWDRrV+7LtVa02gdL/V8 0qY/Dl0FWXykhuF/Kxu9u8zfanNDMu3JsrD0a9ohK7hcp5vH+bBh5PL/t2tidhILW06S BSHsUladWdzLfs8b44WIdWpLUdVbPUp80Gbgu3sclmtwmkMGSdU2NEsmOMHh/sbI6usV IeOKa1HZTlehonZIadO6QWpFEjb/A5xOMqvAdVDCPyGQNY3GuiyMy12VLsiDSEoYwR15 LwhwM9FZE7Qrs3aHm0M+RYi2qZrz6gj8e6CmCjesEBCnOjBG8/vJDSkNKIMjgbp3pkDZ os5A== 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=uhtN4B6lzqouWLStU3aNeInL/uWL5A7nLQfzGQKmqwo=; b=KcSXu1izGPfM5N8OodwE9MBaHkt7W5gB/B7GTk3aqvfUZxpVI+sRWk7zvlYIemFInG eaW5TDXtRIcOPgAPD9R1luasiG9n0TiVlLmBSM9sOVjQhxMEfDLsmsH3uLUfJEy/cCbJ 0fTNPdo/SXRLbbT8D1hhuFUlf9BHZc99gmgyp/nQs+tncG6ZmGkBRwPMfHsk+xLKFZBM Qac2Gsnw7u90ZFge+OvL8pCPOSTm1z1UmP4gkEt6N7a+Ey0JsQtT3PFyBGa7vs3+sUeC co8P/tfQVy03wHpAVCiR+r86P2MuHU/FN4wAwKesqug4TV77m0bQlfPlv8y3Lg1wQedg KLbQ== X-Gm-Message-State: AOUpUlHBj9bX2L9JtnjPgBa2CL1rwz6LzvWxksdpJBlrJ94UpRYIjalL ZcFo7fZ5+SLhJH09HrFFZhCB73Nvbi9NgQ== X-Google-Smtp-Source: AAOMgpdsd0zfQ7As26Wfzk6zrSxAYUnC/OoUnwcSm1a5zmZLuTiEIAQXymY1KbHBRN6f+ECyYmUN8g== X-Received: by 2002:aca:cdc2:: with SMTP id d185-v6mr329199oig.350.1532377322536; Mon, 23 Jul 2018 13:22:02 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id q63-v6sm1777701oia.54.2018.07.23.13.22.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:22:01 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:17:42 -0500 Message-Id: <20180723201748.25573-94-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::22e Subject: [Qemu-devel] [PATCH 93/99] nbd/server: Reject 0-length block status request 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: qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Eric Blake The NBD spec says that behavior is unspecified if the client requests 0 length for block status; but since the structured reply is documenting as returning a non-zero length, it's easier to just diagnose this with an EINVAL error than to figure out what to return. CC: qemu-stable@nongnu.org Signed-off-by: Eric Blake Message-Id: <20180621124937.166549-1-eblake@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy (cherry picked from commit d8b20291cba6aa9bb295885a34f2b5f05d59d1b2) Signed-off-by: Michael Roth --- nbd/server.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nbd/server.c b/nbd/server.c index 9e1f227178..493a926e06 100644 --- a/nbd/server.c +++ b/nbd/server.c @@ -2007,6 +2007,10 @@ static coroutine_fn int nbd_handle_request(NBDClient *client, "discard failed", errp); case NBD_CMD_BLOCK_STATUS: + if (!request->len) { + return nbd_send_generic_reply(client, request->handle, -EINVAL, + "need non-zero length", errp); + } if (client->export_meta.valid && client->export_meta.base_allocation) { return nbd_co_send_block_status(client, request->handle, blk_bs(exp->blk), request->from, From patchwork Mon Jul 23 20:17:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948095 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="M4JuyeT7"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZFKt2n9Wz9s3N for ; Tue, 24 Jul 2018 07:41:06 +1000 (AEST) Received: from localhost ([::1]:36873 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhiZk-0001y7-2w for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 17:41:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43595) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhLL-0004Vl-5E for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:22:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhLJ-0005j6-Uj for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:22:07 -0400 Received: from mail-oi0-x244.google.com ([2607:f8b0:4003:c06::244]:38134) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhLJ-0005j0-PY; Mon, 23 Jul 2018 16:22:05 -0400 Received: by mail-oi0-x244.google.com with SMTP id v8-v6so3488085oie.5; Mon, 23 Jul 2018 13:22: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=KHDB3ViD2usAI7nMTG5GgvqASHBvAf3zxB0DB0TVGx8=; b=M4JuyeT7keJ11O1MzygTgvzDIvxsyyGLNS008X3TAxIfxLBLOSxe4mvYVxVx5wcVZI jTyo+Dy1gMCRYUFrVMfn4CpJ7MsuOhjjhYvR7UJAhdeeXXYhWbo8lCvi+gL5B/VHcLrb qJZP4kt3ZcyoIeIdFS8dJfbPe1YQf57Ds0TWeEd4qtAX4lv11kuyNDMuUgeCyPYXoKe+ sxiKkFDC/iuAhoWuxpF5IbxX1v7FX+LA8/iCGBsb7RfzY8RdwTpj4YyUSlZllgCO2HqT Bkj0ATZek3ikY9dfx0pKAyHz+pWrAsnwRVD4+O1fXXQocHWa6Mtd+5XYltr1GR95ihTG dq8g== 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=KHDB3ViD2usAI7nMTG5GgvqASHBvAf3zxB0DB0TVGx8=; b=EZQln9q2CPS8/tLy8qBXF3o38fC7sCsOIPo5JTXWknLWHpWKSpzlOfsorAHp6iRpF+ PEu8oTJKC49Atxg5Dd/5aWS3WMMiEu1L/bJo+mdQfJn6YyVKTHHxuTnUTpzyXLegq59n ybjmWPw8muPbEqxNU+vbahXL07ohWbD5tZ4asuxKJcGdIBftQYAtRHUE3TghffuI6F1N F2H5IYGaDviWxWY6qVU3zcyglosY+Ep30LjABCadpwvLEdiDWCCC8KvDifAayAPlOWE0 QhtxwbS0C5PoVrMi3CTR3WdtLRjrbII5vcFzANp+r9LBJWH7Lcy/s04jAo+eqpz0WyqQ gwrw== X-Gm-Message-State: AOUpUlEYrdaLRMe2gJM+lKjidNuAl5TEoaPFtReDmYwfAhRPfwgHWOze JI4PZ4YyphYH9xnKOnIYyvzjquOuz9g/iw== X-Google-Smtp-Source: AAOMgpeGMkvLPXjK0OFufner5LgJD8Zf9tc5H+pFc0fayqlbmv/8uVZ6A/l1rjmAVaFdGVLF8IiDVw== X-Received: by 2002:aca:a94c:: with SMTP id s73-v6mr323265oie.68.1532377324614; Mon, 23 Jul 2018 13:22:04 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id s142-v6sm8878163oie.48.2018.07.23.13.22.03 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:22:03 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:17:43 -0500 Message-Id: <20180723201748.25573-95-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::244 Subject: [Qemu-devel] [PATCH 94/99] iscsi: Avoid potential for get_status overflow 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: qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Eric Blake Detected by Coverity: Multiplying two 32-bit int and assigning the result to a 64-bit number is a risk of overflow. Prior to the conversion to byte-based interfaces, the block layer took care of ensuring that a status request never exceeded 2G in the driver; but after that conversion, the block layer expects drivers to deal with any size request (the driver can always truncate the request size back down, as long as it makes progress). So, in the off-chance that someone makes a large request, we are at the mercy of whether iscsi_get_lba_status_task() will cap things to at most INT_MAX / iscsilun->block_size when it populates lbasd->num_blocks; since I could not easily audit that, it's better to be safe than sorry by just forcing a 64-bit multiply. Fixes: 92809c36 CC: qemu-stable@nongnu.org Signed-off-by: Eric Blake Message-Id: <20180508212718.1482663-1-eblake@redhat.com> Reviewed-by: Philippe Mathieu-Daudé (cherry picked from commit 8ee1cef4593a7bda076891470c0620e79333c0d0) Signed-off-by: Michael Roth --- block/iscsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/iscsi.c b/block/iscsi.c index f5aecfc883..871947feae 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -732,7 +732,7 @@ retry: goto out_unlock; } - *pnum = lbasd->num_blocks * iscsilun->block_size; + *pnum = (int64_t) lbasd->num_blocks * iscsilun->block_size; if (lbasd->provisioning == SCSI_PROVISIONING_TYPE_DEALLOCATED || lbasd->provisioning == SCSI_PROVISIONING_TYPE_ANCHORED) { From patchwork Mon Jul 23 20:17:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948097 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="O8QQSx62"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZFNw1PP3z9s0R for ; Tue, 24 Jul 2018 07:43:44 +1000 (AEST) Received: from localhost ([::1]:36901 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhicH-0004Ey-Is for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 17:43:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43626) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhLN-0004Xm-7v for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:22:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhLM-0005jl-9i for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:22:09 -0400 Received: from mail-oi0-x243.google.com ([2607:f8b0:4003:c06::243]:40418) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhLM-0005jb-4U; Mon, 23 Jul 2018 16:22:08 -0400 Received: by mail-oi0-x243.google.com with SMTP id w126-v6so3485918oie.7; Mon, 23 Jul 2018 13:22:08 -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=XRI5SBS5RpBzOViBiFp15yPGNFkoOKkwfNAtq1Rxf+0=; b=O8QQSx629XztAQrLB+Hkq7PRkiJHSMjfsL7HGR4abX4mGNQ5RlWz93RgYuRG1Z67Yo tlPM8qLF9xA56s8+RKZ4pZ4+56GrO7lq0Ek7Yg8m1cOiNjIbJ+qTOeILvLCg5nxMAG3Z +OzcCLkV8r6CZegRIGuS8cewxc50vyzKzdY9GBmNOQPYO2AE5BVq7l25Uycj9a/uGqLe AOM5PpQoVxNf/NW8aNc8gzlxTVj4fglOuW+TosnMRDyFn48qnB5q+NhTPAGv5RgJWrQs eVO52mGoEtDuercvLGJF0xUN9FrMBmsJMG+Wdjln2Z1ScmHaX14rkaqRLZCh41nZI7YU DPSA== 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=XRI5SBS5RpBzOViBiFp15yPGNFkoOKkwfNAtq1Rxf+0=; b=dqEjp3g1pbCXi8+ttUsiyrlnk+i9F+8YLWSLCTrnAga+5HD7r75tr9LFQYFS7gIC0X eqUo9hWVqHP/ypR57buYksgY/gOwQn4FfXnY17LJv8zBn5Cau87WU2ry73XXCJdD8Xs6 4Wu2VxYhVs3HOOJY+PSi6Nyqfd3OlVtXDwOyFK4hhOQ3fELGdPpH0xMcBdg6bAd9ChIH pxAu4UTzUkGmoEXKzF4U+yKgiRRnMkL3mtfUZAEziXDDVRinxbDEmy5cBdExIhdPahMo TXXuXT2m5V2/IEdHNOo3ZTfrFxgaMPtjjDJp/bthgxEL4m6auzrIgXVceH6TapQpmsre 8KiQ== X-Gm-Message-State: AOUpUlEAntwAMyazYXk0odAJ6yk2HWnkxWFNBsTB7Srv+Z4VOgJgFc1N ipsfKfRV5tx7hZoXu18hFaR1cqfmSJrvhQ== X-Google-Smtp-Source: AAOMgpfyDcHXOXdcgxph2idukc0UUZ1KSlUfKNJ4QV5YcgTfmyH2eYR1uspZ0HZEuqw5e3mOwUwgPw== X-Received: by 2002:aca:6cc6:: with SMTP id h189-v6mr344256oic.140.1532377326840; Mon, 23 Jul 2018 13:22:06 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id b3-v6sm6698475oiy.11.2018.07.23.13.22.05 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:22:05 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:17:44 -0500 Message-Id: <20180723201748.25573-96-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::243 Subject: [Qemu-devel] [PATCH 95/99] virtio-rng: process pending requests on DRIVER_OK 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: Pankaj Gupta , qemu-stable@nongnu.org, Stefan Hajnoczi , "Michael S . Tsirkin" Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Pankaj Gupta virtio-rng device causes old guest kernels(2.6.32) to hang on latest qemu. The driver attempts to read from the virtio-rng device too early in it's initialization. Qemu detects guest is not ready and returns, resulting in hang. To fix handle pending requests when guest is running and driver status is set to 'VIRTIO_CONFIG_S_DRIVER_OK'. CC: qemu-stable@nongnu.org Reported-by: Sergio lopez Signed-off-by: Stefan Hajnoczi Signed-off-by: Pankaj Gupta Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin (cherry picked from commit 5d9c9ea22ab4f3b3ee497523e34b6f4d3281f62d) Signed-off-by: Michael Roth --- hw/virtio/virtio-rng.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/hw/virtio/virtio-rng.c b/hw/virtio/virtio-rng.c index 289bbcac03..855f1b41d1 100644 --- a/hw/virtio/virtio-rng.c +++ b/hw/virtio/virtio-rng.c @@ -156,6 +156,19 @@ static void check_rate_limit(void *opaque) vrng->activate_timer = true; } +static void virtio_rng_set_status(VirtIODevice *vdev, uint8_t status) +{ + VirtIORNG *vrng = VIRTIO_RNG(vdev); + + if (!vdev->vm_running) { + return; + } + vdev->status = status; + + /* Something changed, try to process buffers */ + virtio_rng_process(vrng); +} + static void virtio_rng_device_realize(DeviceState *dev, Error **errp) { VirtIODevice *vdev = VIRTIO_DEVICE(dev); @@ -261,6 +274,7 @@ static void virtio_rng_class_init(ObjectClass *klass, void *data) vdc->realize = virtio_rng_device_realize; vdc->unrealize = virtio_rng_device_unrealize; vdc->get_features = get_features; + vdc->set_status = virtio_rng_set_status; } static const TypeInfo virtio_rng_info = { From patchwork Mon Jul 23 20:17:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948093 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="VN7GerCB"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZFJ15gf3z9s3N for ; Tue, 24 Jul 2018 07:39:29 +1000 (AEST) Received: from localhost ([::1]:36854 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhiYB-0008QQ-BA for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 17:39:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43657) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhLP-0004ah-Gu for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:22:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhLO-0005ku-EB for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:22:11 -0400 Received: from mail-oi0-x242.google.com ([2607:f8b0:4003:c06::242]:46072) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhLO-0005kg-7d; Mon, 23 Jul 2018 16:22:10 -0400 Received: by mail-oi0-x242.google.com with SMTP id q11-v6so3459262oic.12; Mon, 23 Jul 2018 13:22:10 -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=MyIGE6LzMk2vXNjZpmHXXX4cDfH+h6iDmYr4BXEzbKs=; b=VN7GerCBYDduANiRmu7chP54FD+zuIU+05ZAxUyAv5vwXxXdugVzkboLWfvn1BN6C7 31oZFDwyhUqI1iVEp7dlbJ7iZnqOsHQvMjWyolP1scnbe6nkW3MrE9OcTTKxbSfXH/Pr WVrZPrBz7NXM3cMZho71jFGeaJtFLlbCt02ytiyfPxajqnLrrT5hFQqDE7xw5JJUo9p9 CbmjW3vHufa6bsucNqs0d5OwqjqHWrineB9hE7x0seFCimh2JMvUoptM0/qb8FiOoFqT aXSJooUFW8bxl/vWpl6ByoY5G4Ygl4zqvpB3UWZhlaqaqKONi27gAccCUNn9rpraRN/6 VeqA== 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=MyIGE6LzMk2vXNjZpmHXXX4cDfH+h6iDmYr4BXEzbKs=; b=J4ZXlOkpu+d9vVgI/nrUWvX6A8gmMCRKDBZUzMnQlMrnZyidvRIODKLE0tYAeHtdqW xRB1OlHAykAvnuUDY0+jAeDBOglr8SM3Qoti6djfqsoPHLcJwHPnQdn3JDmnNgOzitLF DRxZTEnhca/Blm4fQr6jGJXV+DIA207e4uoXFQJ0RfhgG7n1Sn17sNwteQuumVGfOvhF /nPKMJBYZ31L0EvL4M6BAJUsFVVdeuOlNXwlVpiBIdgUGXtBcIf0Mi7QkLo0ZfRofxSg K38z5v5Hny14c3yKn1v8cAHLfGSqWPlK4B2bQVOIYaHoP8nTS/xeZRHP9VhuLk5Yfa36 GXkw== X-Gm-Message-State: AOUpUlFWPnssZZoWXeZfJiW5Ej1YJGCPAneVdF7MARMi/aB5+HYrdRyk M3Mdgv63FAeXOE8F6ZrMQjxJfJQBCyTFRg== X-Google-Smtp-Source: AAOMgpfiEs6BJf0UKK3e7Gt3SS1pxVkfWg/Aan3NGl8Jb9nIncZY8ALcu4CHmFuXPNVHXg0R2Hpxgw== X-Received: by 2002:aca:bf88:: with SMTP id p130-v6mr292648oif.344.1532377329075; Mon, 23 Jul 2018 13:22:09 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id s142-v6sm8878382oie.48.2018.07.23.13.22.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:22:08 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:17:45 -0500 Message-Id: <20180723201748.25573-97-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::242 Subject: [Qemu-devel] [PATCH 96/99] target/ppc: set is_jmp on ppc_tr_breakpoint_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: , Cc: "Emilio G. Cota" , qemu-stable@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" The use of GDB breakpoints was broken by b0c2d52 ("target/ppc: convert to TranslatorOps", 2018-02-16). Fix it by setting is_jmp, so that we break from the translation loop as originally intended. Tested-by: Mark Cave-Ayland Reported-by: Mark Cave-Ayland Signed-off-by: Emilio G. Cota Signed-off-by: David Gibson (cherry picked from commit 2a8ceefca23bc2aaafe711f8afd7585be3c27064) Signed-off-by: Michael Roth --- target/ppc/translate.c | 1 + 1 file changed, 1 insertion(+) diff --git a/target/ppc/translate.c b/target/ppc/translate.c index 3457d29f8e..c535cd76f2 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -7296,6 +7296,7 @@ static bool ppc_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *cs, DisasContext *ctx = container_of(dcbase, DisasContext, base); gen_debug_exception(ctx); + dcbase->is_jmp = DISAS_NORETURN; /* The address covered by the breakpoint must be included in [tb->pc, tb->pc + tb->size) in order to for it to be properly cleared -- thus we increment the PC here so that From patchwork Mon Jul 23 20:17:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948098 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="CIC9jDb7"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZFRr5wf2z9s0R for ; Tue, 24 Jul 2018 07:46:16 +1000 (AEST) Received: from localhost ([::1]:36928 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhiek-0006Qn-Fj for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 17:46:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43689) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhLR-0004d5-Nd for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:22:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhLQ-0005lr-PC for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:22:13 -0400 Received: from mail-oi0-x244.google.com ([2607:f8b0:4003:c06::244]:46074) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhLQ-0005lZ-IQ; Mon, 23 Jul 2018 16:22:12 -0400 Received: by mail-oi0-x244.google.com with SMTP id q11-v6so3459448oic.12; Mon, 23 Jul 2018 13:22:12 -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=RWOr/A6TE00pGF7W4hXfH4qpPjRI8MD+OTC4K1r7Y/I=; b=CIC9jDb7LgPXqcKP4Kkj1gvz5imBsa6lBDCfMFG3gwrHBflavORO9ja58MI6Yb8GAQ H+UnOmoUUbzjidpyp1piZPj+EftO1KAo8zisq0Zj+60ceFWBrF1yj939z4Jhvl2RqkwL PzO2fRxesxl02mNtUjcD4I+I/yDipEOE11CZn2hr6hea+vNbyw88Hc5YChhI/yZge9HU pWlvAtVic/sLc1XdN2XEMKPJbWJZ3UsEMfctiAzDDb7uECGr7q3LKvBnrIYuGwZTwtdo m/IUVwg1HAWk3joVpLcazaRKkY2ZRq8Rv3oIVzBKaHEpendiwWS+IqENjq6nLonfmC70 rldQ== 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=RWOr/A6TE00pGF7W4hXfH4qpPjRI8MD+OTC4K1r7Y/I=; b=BAvyq78o7ohCgONniGkD284tI+4zZsaYD3mVnuwqPDU5LIR/lXW6/uhAPmHRPtGAyW SLyR/8ZEF9ng/Ibvs+hWJKnLWEHu9b9gbb6LJze1RjE2afm9tJNrnzWc6NlRunXR1gC2 vGapnsdupgrLCdL7jIoHxrIZkg8j9Bl35Zw0Wl4jvKi7ABwEiCzIC3szoITQpmCAFhjs uoFe/51MY+TqdnFqBnv390UOE02kIrXo/Mr25+YgvT2LaFBHgO1/JSGc33wN6/mobbee 4aYLxdvEngVu9q8NlMBOlhSEjRhq30WDLZZij5o6Zbjl66pLXFRD9vadcDqSypP2VSP2 amYA== X-Gm-Message-State: AOUpUlFm3PhAtuPZB3K2J06L4d2et5wdTP9VoFVeJ3X1nAQ0PK+PEbhJ gNSuiG3D6Zq5xrRyqrWICumm0slWucD3PA== X-Google-Smtp-Source: AAOMgpc+zxC7MkgaBntnkjV6edJvFb5xY2zo9UQ3IaWxm+oYXPzY2hOdEGE8RAHvrcph+YJjLYklcg== X-Received: by 2002:aca:d0d7:: with SMTP id j84-v6mr264556oiy.189.1532377331455; Mon, 23 Jul 2018 13:22:11 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id m203-v6sm25503729oig.42.2018.07.23.13.22.09 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:22:10 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:17:46 -0500 Message-Id: <20180723201748.25573-98-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::244 Subject: [Qemu-devel] [PATCH 97/99] tap: fix memory leak on success to create a tap device 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: Jason Wang , Yunjian Wang , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Yunjian Wang The memory leak on success to create a tap device. And the nfds and nvhosts may not be the same and need to be processed separately. Fixes: 07825977 ("tap: fix memory leak on failure to create a multiqueue tap device") Fixes: 264986e2 ("tap: multiqueue support") Cc: qemu-stable@nongnu.org Signed-off-by: Yunjian Wang Signed-off-by: Jason Wang (cherry picked from commit 323e7c117754e4d4ce6b4282d74ad01c99d67714) Signed-off-by: Michael Roth --- net/tap.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/net/tap.c b/net/tap.c index 89c4e19162..e807e0ea2f 100644 --- a/net/tap.c +++ b/net/tap.c @@ -805,7 +805,8 @@ int net_init_tap(const Netdev *netdev, const char *name, } else if (tap->has_fds) { char **fds; char **vhost_fds; - int nfds, nvhosts; + int nfds = 0, nvhosts = 0; + int ret = 0; if (tap->has_ifname || tap->has_script || tap->has_downscript || tap->has_vnet_hdr || tap->has_helper || tap->has_queues || @@ -825,6 +826,7 @@ int net_init_tap(const Netdev *netdev, const char *name, if (nfds != nvhosts) { error_setg(errp, "The number of fds passed does not match " "the number of vhostfds passed"); + ret = -1; goto free_fail; } } @@ -833,6 +835,7 @@ int net_init_tap(const Netdev *netdev, const char *name, fd = monitor_fd_param(cur_mon, fds[i], &err); if (fd == -1) { error_propagate(errp, err); + ret = -1; goto free_fail; } @@ -843,6 +846,7 @@ int net_init_tap(const Netdev *netdev, const char *name, } else if (vnet_hdr != tap_probe_vnet_hdr(fd)) { error_setg(errp, "vnet_hdr not consistent across given tap fds"); + ret = -1; goto free_fail; } @@ -852,21 +856,21 @@ int net_init_tap(const Netdev *netdev, const char *name, vnet_hdr, fd, &err); if (err) { error_propagate(errp, err); + ret = -1; goto free_fail; } } - g_free(fds); - g_free(vhost_fds); - return 0; free_fail: + for (i = 0; i < nvhosts; i++) { + g_free(vhost_fds[i]); + } for (i = 0; i < nfds; i++) { g_free(fds[i]); - g_free(vhost_fds[i]); } g_free(fds); g_free(vhost_fds); - return -1; + return ret; } else if (tap->has_helper) { if (tap->has_ifname || tap->has_script || tap->has_downscript || tap->has_vnet_hdr || tap->has_queues || tap->has_vhostfds) { From patchwork Mon Jul 23 20:17:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 948090 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="pPgSkMhz"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZFCk2JFQz9s3N for ; Tue, 24 Jul 2018 07:35:46 +1000 (AEST) Received: from localhost ([::1]:36825 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhiUZ-0003kh-VV for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 17:35:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43745) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhLU-0004gR-Ul for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:22:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhLS-0005n1-SF for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:22:16 -0400 Received: from mail-oi0-x234.google.com ([2607:f8b0:4003:c06::234]:34583) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhLS-0005mg-MF; Mon, 23 Jul 2018 16:22:14 -0400 Received: by mail-oi0-x234.google.com with SMTP id 13-v6so3513838ois.1; Mon, 23 Jul 2018 13:22:14 -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=zl5gJC5obhC0MBm28OD2j4AFk6EnvP2x7EwRP0sNiDk=; b=pPgSkMhzwekaU0ui3nydfipqfOYf9eXcP0UF2Qnv3AupDJM5l1ZcLp4dP1GvEAe1t/ tb97DRgsZ54Axg6HwgbLaSXJ1WKp9V9PRffCZuWFrJP7Ehz8RNgBvNuBKN7vZdjujp4V DS+MQr9cxzmPtNatSdX1bPMG2yWQoQkdnfKQYUa6nr+KRxcGNpRc1VXm4tkmO+3mNfeK uFYCzyyBrmLXjZYfYYNcRp69GB6AsnSx/OS4KvTVVbQTND4SCkXsqy79u992Vv33oWm6 aL+lkHUGNV5u/BIUCiBx8vUQugKtdhduhgbnk5YzW47r4sdVxk+YCtOyGJzNstO2gX/Y tG4w== 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=zl5gJC5obhC0MBm28OD2j4AFk6EnvP2x7EwRP0sNiDk=; b=SgH9gw2RfxSZCkYlc2/pIKtLkeowqh12pMq6FtOZwGiV2x9Ev2H7Zt3CPTtUONhGmI tRXvPAGNdtDR5L0ejnXn3uYbkRgJ5f+geXCmwX1tiYTAF1Nnm4aOqa1WHDakDaLsCGJH NgohHVRELHODpJURCAu9yd9GSkhlXeFeYTarTWU72SehCU/DlDbeYkjy2s8bKGROzxrL xqMI4TnKToh2dAIbOCjNkcvLAufjK1CHac5jBuiKAS2pngYAaKhpjh0nq33hN9RI9SCR 84q4GPgVTZfx5jlnmNndbGUZXL7WXSEtS5N4+g//W8HnDabp8lFmA17Rah247+uU6TRH w0Ow== X-Gm-Message-State: AOUpUlFBnE6cystoqBH2MiSUXY6gnQfSES6jxl0gu7u3o5cFiSlkN174 xmN5N70U9DsKhkTJg3RQ2QLQDGIZttTmzQ== X-Google-Smtp-Source: AAOMgpc184YUTKezIQORGGPwDd8yHP2N8lIqgFTzNtdeujcUpYZE4Pa2CV8Izpn4BMGb7+XRYqY03Q== X-Received: by 2002:aca:f0d7:: with SMTP id o206-v6mr344765oih.200.1532377333456; Mon, 23 Jul 2018 13:22:13 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id c9-v6sm7630018oia.1.2018.07.23.13.22.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:22:12 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:17:47 -0500 Message-Id: <20180723201748.25573-99-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::234 Subject: [Qemu-devel] [PATCH 98/99] qemu-img: avoid overflow of min_sparse parameter 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: Kevin Wolf , Peter Lieven , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Peter Lieven the min_sparse convert parameter can overflow (e.g. -S 1024G) in the conversion from int64_t to int resulting in a negative min_sparse parameter. Avoid this by limiting the valid parameters to sane values. In fact anything exceeding the convert buffer size is also pointless. While at it also forbid values that are non multiple of 512 to avoid undesired behaviour. For instance, values between 1 and 511 were legal, but resulted in full allocation. Cc: qemu-stable@nongnu.org Signed-off-by: Peter Lieven Signed-off-by: Kevin Wolf (cherry picked from commit 6360ab278cc1ac3e1235e0755e4cba1f918e6f3c) Signed-off-by: Michael Roth --- qemu-img.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index a8e2b53dc6..1a055b4424 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -1912,6 +1912,8 @@ static int convert_do_copy(ImgConvertState *s) return s->ret; } +#define MAX_BUF_SECTORS 32768 + static int img_convert(int argc, char **argv) { int c, bs_i, flags, src_flags = 0; @@ -2008,8 +2010,12 @@ static int img_convert(int argc, char **argv) int64_t sval; sval = cvtnum(optarg); - if (sval < 0) { - error_report("Invalid minimum zero buffer size for sparse output specified"); + if (sval < 0 || sval & (BDRV_SECTOR_SIZE - 1) || + sval / BDRV_SECTOR_SIZE > MAX_BUF_SECTORS) { + error_report("Invalid buffer size for sparse output specified. " + "Valid sizes are multiples of %llu up to %llu. Select " + "0 to disable sparse detection (fully allocates output).", + BDRV_SECTOR_SIZE, MAX_BUF_SECTORS * BDRV_SECTOR_SIZE); goto fail_getopt; } @@ -2297,9 +2303,9 @@ static int img_convert(int argc, char **argv) } /* increase bufsectors from the default 4096 (2M) if opt_transfer - * or discard_alignment of the out_bs is greater. Limit to 32768 (16MB) - * as maximum. */ - s.buf_sectors = MIN(32768, + * or discard_alignment of the out_bs is greater. Limit to + * MAX_BUF_SECTORS as maximum which is currently 32768 (16MB). */ + s.buf_sectors = MIN(MAX_BUF_SECTORS, MAX(s.buf_sectors, MAX(out_bs->bl.opt_transfer >> BDRV_SECTOR_BITS, out_bs->bl.pdiscard_alignment >> From patchwork Mon Jul 23 20:17:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 947959 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="WZR7BSt0"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41ZCWt70QWz9s4Z for ; Tue, 24 Jul 2018 06:19:37 +1000 (AEST) Received: from localhost ([::1]:36321 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhIp-0001Hl-Vr for incoming@patchwork.ozlabs.org; Mon, 23 Jul 2018 16:19:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40499) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhI1-0001HW-Sd for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:18:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhHx-00021p-Uh for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:18:41 -0400 Received: from mail-oi0-x241.google.com ([2607:f8b0:4003:c06::241]:36708) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhHx-000210-PW; Mon, 23 Jul 2018 16:18:37 -0400 Received: by mail-oi0-x241.google.com with SMTP id n21-v6so3485944oig.3; Mon, 23 Jul 2018 13:18:37 -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=biOW1GJVIC0Bmz/mcpkMKH6ikxHoUwXFzn86ZR5EJ2Q=; b=WZR7BSt0MrVWFJkMwqKb2h+T4BYA3T0aABP1DpPzVrfjoNwtNPhTiPQrJcFBwhbMJK 6NTxK/iFk2+iNOWCyDX6F9mfaGVpAYJhRR7752c6Ith2vRSQR15ePrfIRlIpECHKIAXL T+SDjcxPcEQxK5h7XejuDdk9MzdsXlkSyY15N0vv6dCIKug207M7BHu74CYLx+meW7O/ cBkGgNkrPg8v8Vx4HBVFRTCbM/GB/x2HZXp8HAD9GSBmgsoJvUXkyrOsTFPCIy8WRFsH z9dNI4kmzNh9K4fhHvZWHfYEhFS5ATTW8AQiEQgIlu5GCiNzDILoGYTuEF99jSXqCYiy dQ0Q== 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=biOW1GJVIC0Bmz/mcpkMKH6ikxHoUwXFzn86ZR5EJ2Q=; b=MNfHZu+ifMUPf2z3e1iVEMM8EPBZr7Aim8gkyTBm91MxqauK6dYInUZSVQFLyLki5n upJsQWsBs1U4E8DvP3D1P7ip4SA6vfUu8sorGJS6DYmMErjXXH2yFxOob9IU6LqHsAiQ HFunXM8fRQT3MgdMZtvkI6fN/PppqF7H0UceS2iFyTB14Ef4fSkJAZfodlGsQ696lCBy LB1TKdC8PSoM2R6hXU9CVgtO91YpKzsoNCnDE3mxxYxVmsUnatByYOzY3Rkg/gZZSIIv eEQ18aXNmGypqQ4+7Q0C4Rss73wL90xz4OQ3GshdClsIuI1Ds57zc8smJK0ww7mHeK60 4ffQ== X-Gm-Message-State: AOUpUlGTLkcLZ4zrEyae2JAmq/cBxPxRyLpod0c6KtFgF7UlkwzZ1xHW 92NZJttKnLw8DtEcNYEXnLf70xUaPc0= X-Google-Smtp-Source: AAOMgpfS/zYHcVfk4FndhQo3MQQ4J6DUuuLMErGp5Bgx5FFF6D7oAfQbMkhAR+zNpicgOy2Nhqp/8w== X-Received: by 2002:aca:4083:: with SMTP id n125-v6mr290474oia.167.1532377116011; Mon, 23 Jul 2018 13:18:36 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id d191-v6sm11780876oig.16.2018.07.23.13.18.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:18:34 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:17:48 -0500 Message-Id: <20180723201748.25573-100-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::241 Subject: [Qemu-devel] [PATCH 99/99] tcg/i386: Mark xmm registers call-clobbered 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: Richard Henderson , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson When host vector registers and operations were introduced, I failed to mark the registers call clobbered as required by the ABI. Fixes: 770c2fc7bb7 Cc: qemu-stable@nongnu.org Reported-by: Jason A. Donenfeld Signed-off-by: Richard Henderson (cherry picked from commit 672189cd586ea38a2c1d8ab91eb1f9dcff5ceb05) Signed-off-by: Michael Roth --- tcg/i386/tcg-target.inc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tcg/i386/tcg-target.inc.c b/tcg/i386/tcg-target.inc.c index ccde8801a5..5727999bb3 100644 --- a/tcg/i386/tcg-target.inc.c +++ b/tcg/i386/tcg-target.inc.c @@ -3529,7 +3529,7 @@ static void tcg_target_init(TCGContext *s) tcg_target_available_regs[TCG_TYPE_V256] = ALL_VECTOR_REGS; } - tcg_target_call_clobber_regs = 0; + tcg_target_call_clobber_regs = ALL_VECTOR_REGS; tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_EAX); tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_EDX); tcg_regset_set_reg(tcg_target_call_clobber_regs, TCG_REG_ECX);