From patchwork Tue Jun 19 01:41: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: 931270 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="E8jTrwiF"; 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 418s472RLwz9s2t for ; Tue, 19 Jun 2018 12:15:03 +1000 (AEST) Received: from localhost ([::1]:38542 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6Af-0006qi-0K for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:15:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45215) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5hQ-00010X-TY for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5hP-000844-Ti for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:48 -0400 Received: from mail-ot0-x22d.google.com ([2607:f8b0:4003:c0f::22d]:40166) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5hP-00083x-OL; Mon, 18 Jun 2018 21:44:47 -0400 Received: by mail-ot0-x22d.google.com with SMTP id w9-v6so20744296otj.7; Mon, 18 Jun 2018 18:44: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=MVi4npPwBscy6kPVWn04VlJlshfdAar9kxYtJjYaQVA=; b=E8jTrwiF6nfDfIRii8iLUvLGBQjr+FfBLGQmFbFruoyjU2lSAZamXid5EV3l/ei4XR GyUNYrPW2y1kmFBjY2g9H3hAfqyfQt5oxJQ8i69DOu6CEV6S+SOdPtuBbONlDl+rObC7 AKEv8opNtyE6Yk4lmnf2umGf55JqQnrPSERtZ70Ffn8tlsG+RjyPH7kbo8pQPyPDmDHU J5qEXmzri8AHfO/7X9MeGpjZxHsIOZodSU1P7U3Wsma28WSol0JApeufLgr2dstIVuYu ij2MWDu/XJFZWhWeqEGClQkyh8RxjuxpJCL6L+CpyVpyJzXyT02cYRHgQpnXzHjhbocY QwMQ== 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=MVi4npPwBscy6kPVWn04VlJlshfdAar9kxYtJjYaQVA=; b=FlA1PM7NszSBm6KaJjz6SCH8Vvkp77byzETuytGFtf5ekBJI314JtcDh/0KNxlKI9Q y/ECGQpccS+9/UxO/j6i3o1XZ69sJJgkwFb2WG/+gxP46eUZH6PaPR4+6+Is4wf2ILOH dVUSOg4NfS3xSs3vXT92uRwvYMbUkeJBesJMoxnohXRv5Sf0RCU++S8eZsJ03uqxRfOZ Pkd1i30fp5zVxxefFn6lODo6kN/zf+yecIV5x/oK9kkE5alTAlyd573tegm5fyfevZJp UPnO3XnfQ9YXopb5kqBQV0BrNgIp1zFG1GnRXNsECigAQ3hiqacnoGDbc99CiQAlZgzs Z2KQ== X-Gm-Message-State: APt69E0Lq7dlukoBgtnyw0PaRvdlSy5FW/vrAWgIyq9xHDbq0qzdAIyR pshxbrZbp4YiFvyRbzq30Lha+Jvc X-Google-Smtp-Source: ADUXVKL6fVoJyeyNlTyTifG+JVwHj3wE1XBTRhbNuwpZr8N/SKhCg6FkWjrMiBBni3ck98dOPy8boQ== X-Received: by 2002:a9d:1339:: with SMTP id f54-v6mr9689180ote.307.1529372686553; Mon, 18 Jun 2018 18:44:46 -0700 (PDT) Received: from localhost ([2600:1700:70:e488:b0ee:9bda:ee6f:91be]) by smtp.gmail.com with ESMTPSA id m62-v6sm7707536otc.71.2018.06.18.18.44.45 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:44:45 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:41:27 -0500 Message-Id: <20180619014319.28272-2-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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:c0f::22d Subject: [Qemu-devel] [PATCH 001/113] block/ssh: fix possible segmentation fault when .desc is not null-terminated 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 , Max Reitz , qemu-stable@nongnu.org, Murilo Opsfelder Araujo Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Murilo Opsfelder Araujo This patch prevents a possible segmentation fault when .desc members are checked against NULL. The ssh_runtime_opts was added by commit 8a6a80896d6af03b8ee0c17cdf37219eca2588a7 ("block/ssh: Use QemuOpts for runtime options"). This fix was inspired by http://lists.nongnu.org/archive/html/qemu-devel/2018-01/msg00883.html. Fixes: 8a6a80896d6af03b8ee0c17cdf37219eca2588a7 ("block/ssh: Use QemuOpts for runtime options") Cc: Max Reitz Cc: Eric Blake Signed-off-by: Murilo Opsfelder Araujo Reviewed-by: Eric Blake Reviewed-by: Jeff Cody Signed-off-by: Jeff Cody (cherry picked from commit fbd5c4c0db47e578e3fdd88a0ebc4314a1ed3d42) Signed-off-by: Michael Roth --- block/ssh.c | 1 + 1 file changed, 1 insertion(+) diff --git a/block/ssh.c b/block/ssh.c index b049a16eb9..8890a0c4ba 100644 --- a/block/ssh.c +++ b/block/ssh.c @@ -556,6 +556,7 @@ static QemuOptsList ssh_runtime_opts = { .type = QEMU_OPT_STRING, .help = "Defines how and what to check the host key against", }, + { /* end of list */ } }, }; From patchwork Tue Jun 19 01:41: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: 931279 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="B7ksLXbs"; 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 418sF65hCHz9s37 for ; Tue, 19 Jun 2018 12:22:50 +1000 (AEST) Received: from localhost ([::1]:38587 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6IC-0004XP-BH for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:22:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45593) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5hn-0001NW-Np for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5hm-0008GJ-NO for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:11 -0400 Received: from mail-ot0-x242.google.com ([2607:f8b0:4003:c0f::242]:41798) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5hm-0008F0-II; Mon, 18 Jun 2018 21:45:10 -0400 Received: by mail-ot0-x242.google.com with SMTP id d19-v6so20756290oti.8; Mon, 18 Jun 2018 18:45: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=zSRIdxM346fc9dvuF02xB4T4y4i0o2MA9xesv1qFtTg=; b=B7ksLXbs/2wQU0gPBH+lw81R0arujm7pBdl8e4GJeyF7nqDxgN/IF8lT+7cdp68MC1 zTfQTI4/DBepIVUbKyx8N06PYurKi0Q9/EHyTdYfS9h72W9lvxZjZc4n304rPteUeCW+ 0Nwu8aIkQgxnbPq/5WgfbSlYIjrw4MXQMYeMvIC6wdTjuwFNtEDugXHvvxqceTY/w2pO 3xkwvyLEYo01D3VXtaSpgCttbYR40gmqngcG1i71PSq4nJZbtvjSc1gO6sWxoNb6I9s7 b/a/sYUdXfEFD2uJTksKdceZ8NdxizbAE/mj0w0pho61XFrteJpThKuIyEti260NS/zq fT1Q== 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=zSRIdxM346fc9dvuF02xB4T4y4i0o2MA9xesv1qFtTg=; b=aKeDe3J67q7KYc7O0rx4IpDkpT5kVPhewDN7YLrKSQrqMmy4hjjwXgyWTrNag3LrhZ PGEAcI68i85hTS2QilLRI6+hR0AiF4MnfKdpc7KOK6cDO3h17KJZS/PRWnUeG9u8eG/q mtLzzwo1bp2KH3ZYYS2sCCNub3P1e6GuyFwbfjf0Jhn1F4cRKxZog7fEzHNrNo9FAumL LZLdukWZQ7WCKFwHnqGzEhRgPM0p35aRipOkK6BgaDmbXClgi/+YoBPlQWpzuxC6/T9/ XSw2H+aJqGorMvAiIyRXsi9scTy9oWYVow2HYyCKQuhdvA0sSV511bkJyYfpyh8PrBUA 0k5A== X-Gm-Message-State: APt69E1fwBgWPDxtO9DLx3QMpJ6O5ORidpPg42Q7MudcaLo+8ewDeUal wi/eir879TRJuYHg/V586cg5izgs X-Google-Smtp-Source: ADUXVKIZp67iyMUQRrx+B0kl6mrGk58F2L4BrpyE+lhg+JI3zu4IDxISErqshMF7lhjmWUpIFOmrIA== X-Received: by 2002:a9d:12c9:: with SMTP id g67-v6mr8586462otg.350.1529372709387; Mon, 18 Jun 2018 18:45:09 -0700 (PDT) Received: from localhost ([2600:1700:70:e488:b0ee:9bda:ee6f:91be]) by smtp.gmail.com with ESMTPSA id t4-v6sm16637380otd.40.2018.06.18.18.45.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:45:08 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:41:28 -0500 Message-Id: <20180619014319.28272-3-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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:c0f::242 Subject: [Qemu-devel] [PATCH 002/113] pci-bridge/i82801b11: clear bridge registers on platform 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: Marcel Apfelbaum , Laszlo Ersek , qemu-stable@nongnu.org, "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Laszlo Ersek The "i82801b11-bridge" device model is a descendant of "base-pci-bridge" (TYPE_PCI_BRIDGE). However, unlike other similar devices, such as - pci-bridge, - pcie-pci-bridge, - PCIE Root Port, - xio3130 switch upstream and downstream ports, - dec-21154-p2p-bridge, - pbm-bridge, - xilinx-pcie-root, "i82801b11-bridge" does not clear the bridge specific registers at platform reset. This is a problem because devices on "i82801b11-bridge" continue to respond to config space cycles after platform reset, when addressed with the bus number that was previously programmed into the secondary bus number register of "i82801b11-bridge". This error breaks OVMF's search for extra (PXB) root buses, for example. The device class reset method for "i82801b11-bridge" is currently NULL; set it directly to pci_bridge_reset(), like the last three bridge models in the above listing do. Cc: "Michael S. Tsirkin" Cc: Marcel Apfelbaum Cc: qemu-stable@nongnu.org Ref: https://bugzilla.redhat.com/show_bug.cgi?id=1541839 Signed-off-by: Laszlo Ersek Reviewed-by: Marcel Apfelbaum Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin (cherry picked from commit ed247f40db84c8bd4bb7d10948702cd47cc4d5ae) Signed-off-by: Michael Roth --- hw/pci-bridge/i82801b11.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/pci-bridge/i82801b11.c b/hw/pci-bridge/i82801b11.c index cb522bf30c..ebf7f5f0e8 100644 --- a/hw/pci-bridge/i82801b11.c +++ b/hw/pci-bridge/i82801b11.c @@ -98,6 +98,7 @@ static void i82801b11_bridge_class_init(ObjectClass *klass, void *data) k->realize = i82801b11_bridge_realize; k->config_write = pci_bridge_write_config; dc->vmsd = &i82801b11_bridge_dev_vmstate; + dc->reset = pci_bridge_reset; set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories); } From patchwork Tue Jun 19 01:41: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: 931290 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="CRdUMzMw"; 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 418sRf04BCz9s37 for ; Tue, 19 Jun 2018 12:31:58 +1000 (AEST) Received: from localhost ([::1]:38653 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6R1-0003U6-Is for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:31:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45989) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5iB-0001me-DN for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5iA-0008TQ-IN for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:35 -0400 Received: from mail-ot0-x22f.google.com ([2607:f8b0:4003:c0f::22f]:43001) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5iA-0008Sy-CV; Mon, 18 Jun 2018 21:45:34 -0400 Received: by mail-ot0-x22f.google.com with SMTP id 92-v6so20759825otw.9; Mon, 18 Jun 2018 18:45: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=ZKw+r7bk5hiEPkua1fk1T201N1pmVswNZ5NoMgzHu00=; b=CRdUMzMwTz33etAQXO5a3qP3MtO24cllNm8cwa+vccpRlfpnikapVDLCiJvoU6vZqj Z7OSb9MR/hzRqqnsWU0aOVc08+oOZGjdLTyTcO1EfFSJeCzAvOX6wjhhl4l0/4pdJgcN 5YOC4Esyf/8u+CU2TdWhxTHlhEZ5IyUWaXM/fEHdxH/5hqy5jcNnfumPQ33J6mWBTjAu v5DZMe1oJDwZxEhY9ogmPqrD4aLxNH1Hi/ZxtFyZ9xhgDPgudHKiyFI8Bc+1enPZdxMv qCcWiRHdR3Ix9Qb8dcTosxClO5YJhfsWO1q4rlY2avpRKeKOCusfCkOVHqVD2YowPvcL 6EjA== 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=ZKw+r7bk5hiEPkua1fk1T201N1pmVswNZ5NoMgzHu00=; b=V1kBKSzdgbAwePONA7WIfmEHMLT8FKTFql6Z82aRSDCAemTaY1ODVMHEpe2hhAEjwY 9irbnkhilUiI1hXBoVaFWhGclfFG2ICTAl4LGQC5xiPFNrbfO9x9kYPQ8YacfeHHlcDy 7wYBGtI/9BngAWjR//pTzQNAm+WSt2D8TDa/0WadJRUqSuL0ndM120TR3lAhkPu0igHO E6H/chA6RvTkAkXgifWpRf1QPFgMjar0CLPnz5gIt3a/+79dm3VlaxCVQaIw1NZDxkWl 1tUabnh442qE5NEvS5vCJi7mxkj319r3fsg0M69V5HCeTaXyBDp6kPn5iYmCnyGZUHh1 EB6w== X-Gm-Message-State: APt69E3Qc6oR0Yp2d7Lm5+XcbizggOYeO4ikjHL50UtpH2K2ki4Ohy2a qb5NZfmrcm16tJsy77xVggP/i/MD X-Google-Smtp-Source: ADUXVKJVmtC2dwSxZFqQ+LX/ibtvBO3p6iDndhPkUHhLDZxmgCPTGox6aRP1wwwYHajKGfevv6wntQ== X-Received: by 2002:a9d:5550:: with SMTP id h16-v6mr8511244oti.24.1529372733229; Mon, 18 Jun 2018 18:45:33 -0700 (PDT) Received: from localhost ([2600:1700:70:e488:b0ee:9bda:ee6f:91be]) by smtp.gmail.com with ESMTPSA id w88-v6sm8268593ota.48.2018.06.18.18.45.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:45:32 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:41:29 -0500 Message-Id: <20180619014319.28272-4-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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:c0f::22f Subject: [Qemu-devel] [PATCH 003/113] virtio-balloon: unref the memory region before continuing 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, Tiwei Bie , "Michael S . Tsirkin" Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Tiwei Bie Signed-off-by: Tiwei Bie Cc: qemu-stable@nongnu.org Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin (cherry picked from commit b86107ab43b804e899a226fe287e34ab8acef596) Signed-off-by: Michael Roth --- hw/virtio/virtio-balloon.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c index 37cde38982..651fa70ca6 100644 --- a/hw/virtio/virtio-balloon.c +++ b/hw/virtio/virtio-balloon.c @@ -234,6 +234,7 @@ static void virtio_balloon_handle_output(VirtIODevice *vdev, VirtQueue *vq) memory_region_is_rom(section.mr) || memory_region_is_romd(section.mr)) { trace_virtio_balloon_bad_addr(pa); + memory_region_unref(section.mr); continue; } From patchwork Tue Jun 19 01:41: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: 931300 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="hD9tfqPj"; 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 418sfq4ksSz9s1R for ; Tue, 19 Jun 2018 12:41:38 +1000 (AEST) Received: from localhost ([::1]:38708 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6aM-0002p9-SJ for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:41:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46284) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5iY-0002Aw-E9 for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5iX-0000CZ-J7 for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:58 -0400 Received: from mail-oi0-x231.google.com ([2607:f8b0:4003:c06::231]:34780) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5iX-0000CO-E4; Mon, 18 Jun 2018 21:45:57 -0400 Received: by mail-oi0-x231.google.com with SMTP id i205-v6so16712402oib.1; Mon, 18 Jun 2018 18:45:57 -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=PvBPJxOdkKrJhmmVj5S5R7vK9KAnKhVKbrbt4jZYNoY=; b=hD9tfqPj1JLeGgbHbqapi+ggnIezA+1s0nO55Y/1vTz9CF+X5rmufJJ6qKU++s2FiE r5wfO8Qo0usXw7tX/d1zUrpkkTN6/E3M71/LmO/Pla6rHMD/9MesjIl+Iv9osX5071tC S2+pxFCdmrOaolwp+3B2026vua2nnGHeMALHZb34JnhJ9wImUBfKENXfeStGtbf0Lp5I aW9aBzSa6B9O8isvtWEYVfYBiXPuJ/nKxFJ3P65jjUtwNY0W5xcsC8jRQXRMBKDKL1K5 CGA/r8M8NTdf8ltS3L6wqfKkFM8svlUeSOjhx1IvHHuDLwqAz0oBypCUdBSPm6uuHjaA k5jQ== 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=PvBPJxOdkKrJhmmVj5S5R7vK9KAnKhVKbrbt4jZYNoY=; b=tr8HKqjZy0rmVIR0iesDwf2nXbzgookx/WiZAD407xRJ6AfokM3sotnHA3/UhDY/iD z0BmWwzvtvzOb+vKgh03mlJ2AyRKZeC+34aRqDMo2fIpJvMs4LaqJIND7jL23nSZLQG5 B3vCBTq9UtiF2nIA3enTVkyi2NVuIe0bvNbYYu7A/tGZzjjDU8qEYYFRGH/ZLydUnuRv tK5O++PYRn4MSNeuYbnSTEcR6kkUDw5N//1P26QlapYBYowaBPVkMUzVQ9TtVEUB0YnV QPGmAQaX1SKRwRZuZbzh9wajQewU4FCdSA7obRFqk8+Gy4R2YWTskZ/WYK6eE7pdVe92 Ko8Q== X-Gm-Message-State: APt69E259DVnBoQ0L5ByIlYkR8Wfxcmrp8R+w0QSaKxErHUTS5hJ8e9K Loq8jQNh1t8NU+uFubwxabgltVcK X-Google-Smtp-Source: ADUXVKIMjFGyXyNcCNjyNzDfNCJRos8Hf2bXN7NgstXNoFi2SH1UFujfOBkBLaYqDTpA7hDyYQM2aw== X-Received: by 2002:aca:f594:: with SMTP id t142-v6mr8777949oih.56.1529372756211; Mon, 18 Jun 2018 18:45:56 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id 97-v6sm7800810oth.15.2018.06.18.18.45.54 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:45:55 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:41:30 -0500 Message-Id: <20180619014319.28272-5-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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::231 Subject: [Qemu-devel] [PATCH 004/113] memfd: fix configure test 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 , Greg Kurz , qemu-stable@nongnu.org, =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Paolo Bonzini Recent glibc added memfd_create in sys/mman.h. This conflicts with the definition in util/memfd.c: /builddir/build/BUILD/qemu-2.11.0-rc1/util/memfd.c:40:12: error: static declaration of memfd_create follows non-static declaration Fix the configure test, and remove the sys/memfd.h inclusion since the file actually does not exist---it is a typo in the memfd_create(2) man page. Cc: Marc-André Lureau Signed-off-by: Paolo Bonzini (cherry picked from commit 75e5b70e6b5dcc4f2219992d7cffa462aa406af0) Signed-off-by: Greg Kurz --- configure | 2 +- util/memfd.c | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/configure b/configure index 0c6e7572db..087a82ac50 100755 --- a/configure +++ b/configure @@ -3920,7 +3920,7 @@ fi # check if memfd is supported memfd=no cat > $TMPC << EOF -#include +#include int main(void) { diff --git a/util/memfd.c b/util/memfd.c index 4571d1aba8..412e94a405 100644 --- a/util/memfd.c +++ b/util/memfd.c @@ -31,9 +31,7 @@ #include "qemu/memfd.h" -#ifdef CONFIG_MEMFD -#include -#elif defined CONFIG_LINUX +#if defined CONFIG_LINUX && !defined CONFIG_MEMFD #include #include From patchwork Tue Jun 19 01:41: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: 931321 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="OMuk1wWP"; 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 418t3V3CLzz9s1R for ; Tue, 19 Jun 2018 12:59:34 +1000 (AEST) Received: from localhost ([::1]:38817 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6rj-0000ky-SJ for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:59:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46553) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5iv-0002XT-Oj for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:46:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5iu-0000LM-Qn for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:46:21 -0400 Received: from mail-oi0-x241.google.com ([2607:f8b0:4003:c06::241]:43745) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5iu-0000LD-LR; Mon, 18 Jun 2018 21:46:20 -0400 Received: by mail-oi0-x241.google.com with SMTP id t133-v6so16697218oif.10; Mon, 18 Jun 2018 18:46:20 -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=NSpIqHS91PWtWrPGwktNZIvLNLAFG3D5cbNSNNPVDIQ=; b=OMuk1wWPUNt9N52aEroLsW1BJ4bVEd/P9YfJSE2hAztPyISbrrGq+hmevm7Hrmvg8o yAQtGifkFiCNH94DafHXAWESnYG6lNtEuTi0iO0P/fLlT0jnfxL8VUBw0YTNC4ykNkAg pbpPr61j98/c8nvuqIUwtiJ6WUiUPwExKLBAuN6/HRAYrWj3wCUxnR+BRpig2lu4ClbK T9sFzu3XdRX7o15M/qkS5AgEbUO82yDHXIXIgdaDsIOw5zJb44N3yEJw+ycoGGTaaN3P QZJqx6+slQSAcbUVzYJvuwh1zK8USU7Pbam40QxY1ZiFXTaTRjqQqnOxt5pY6cMEAAtF ULCQ== 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=NSpIqHS91PWtWrPGwktNZIvLNLAFG3D5cbNSNNPVDIQ=; b=A7BRnLZAVVsqecrliNYQTzq9vosvlDjqxVV8uoGhQnQiKrQaCZKvGFev6RdRAF8qJm C2pUDKhCMdpb4Pc5wApotBOB29PM/0nnIkCNIMbSyOjaUyAQKdIk6BeFrW9kO1FgQ8WO 2kIl9zvc5BaOucKwaAfT8dkXZirutKxZvMGy6NZsMN3n0Xe/siICCIzx5zoNAr4V9Ubz b5HjKQ+OKi8ugOHwkIAIYmS0gBblzrIrEesk+eqErAfVhqAf6NUjKvMbIJkxEamlmix3 Y0ohke71SQ1jAiBIW3s/0y50Me2+pjVHJneZN1yby7smSvjMcVj5Ws/jnj5rmlq3564D ajqQ== X-Gm-Message-State: APt69E18R+BccecdeWsDu/PJAzNXVki6uj7sCNIL4rGNLI0JeuNLNXGb oQzTfYGx9nJJkrOWUxJwqyWMhm0lsaY= X-Google-Smtp-Source: ADUXVKLO9lUlnK0vy+2QOemQCBCACxylZL0xp3tSlH3d5JjzCjggjBgeWph0yjVdRqAQxE5lTPEfBg== X-Received: by 2002:aca:3409:: with SMTP id b9-v6mr7631817oia.10.1529372779486; Mon, 18 Jun 2018 18:46:19 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id j196-v6sm8557781oib.14.2018.06.18.18.46.18 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:46:18 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:41:31 -0500 Message-Id: <20180619014319.28272-6-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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 005/113] sdl: workaround bug in sdl 2.0.8 headers X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Greg Kurz , qemu-stable@nongnu.org, Gerd Hoffmann Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Gerd Hoffmann https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=892087 Signed-off-by: Gerd Hoffmann Reviewed-by: Daniel P. Berrangé Message-id: 20180307154258.9313-1-kraxel@redhat.com (cherry picked from commit 2ca5c43091324a68772dc348cdf157c63888c168) Signed-off-by: Greg Kurz --- configure | 1 + 1 file changed, 1 insertion(+) diff --git a/configure b/configure index 087a82ac50..3c8e66c750 100755 --- a/configure +++ b/configure @@ -2788,6 +2788,7 @@ if test "$sdl" != "no" ; then int main( void ) { return SDL_Init (SDL_INIT_VIDEO); } EOF sdl_cflags=$($sdlconfig --cflags 2>/dev/null) + sdl_cflags="$sdl_cflags -Wno-undef" # workaround 2.0.8 bug if test "$static" = "yes" ; then if $pkg_config $sdlname --exists; then sdl_libs=$($pkg_config $sdlname --static --libs 2>/dev/null) From patchwork Tue Jun 19 01:41: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: 931337 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="SNqid+0u"; 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 418tKD2yLkz9s1R for ; Tue, 19 Jun 2018 13:11:28 +1000 (AEST) Received: from localhost ([::1]:38925 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV73G-0002Pv-2q for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 23:11:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46846) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5jK-0002rv-8D for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:46:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5jJ-0000bD-5E for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:46:46 -0400 Received: from mail-ot0-x242.google.com ([2607:f8b0:4003:c0f::242]:34694) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5jI-0000aa-W7; Mon, 18 Jun 2018 21:46:45 -0400 Received: by mail-ot0-x242.google.com with SMTP id r18-v6so20784391otk.1; Mon, 18 Jun 2018 18:46: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; bh=TQeRTsFw7TCwjoTDQG9AEckG7e4A2HEOIhT0Wo4z+AE=; b=SNqid+0unnjwwW8/DailOb3Gz63Km8+pMW7Wf4OwNd14cr4f3wMYTSYpw/ZEcg3PKM IZSeZUEyXuH9LkS5HRAzUH1m0BHh54PSDCzvIoI5z5h/C+GDyFB1ARJyr7C8O2AHgvTM MNCa5apxTbpzLxjuRRVJu17LnyhhJ6YqkB9mBFj8tI+HvLTLgWqKiZGefIrlqjmfMl/H WP4c9DKqh3nl8EgsFLQjcHqrHqNj58TJedy0KGFegX2I4CrJ+M5NGxQwX6imwL2yQD7t mvBLaUalXmvCG6xEebN0XuAIxpB7sg5nmjnCu2Km64zyLO8E8J7F57j2NWdQE0/lo/I6 RJ9A== 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=TQeRTsFw7TCwjoTDQG9AEckG7e4A2HEOIhT0Wo4z+AE=; b=SXvqfP36ci2emr4N3/3XfSwapdHorWu8TcMlEP3VTijypoDevTuEzJpHl5wnR/JdJM hextlXX8rcb+HKys0VJooH6KgVyfDcpPwTyrn/VET0hYhB5U5AiK+cz/oIMSAGJjoGx0 Qn9g8R57LKzxQsfvtFBLkzGTlRIBfSr+wqrQEg704R18vdIIs0PRWDE6VVLbE50JxAr7 gdbxbCy74MLNw/MK6ApRAn3dko+M+wd4NMhURYK0qyP6Q3UzWygSlflvvJxULvw5ZjzU ULyrDJqeKlw1ORPXrLStken3PxvGPMX5Ugcehpku9Sy+hPTmmHEB0kQLoDt44w8wIS+o c4gQ== X-Gm-Message-State: APt69E2fS4dbxMBicNLKk1hiXizx4w5sdI+en8ulxi4GAKHDAeOQLlVr PJhGvdYXrWVmFdoIry8AyIJOPkXkSFE= X-Google-Smtp-Source: ADUXVKK0U/GntJFCuqX0JP/tFuAjLfPpKZZTBaPQjIcC1fFSHlm365DOWidEhLd7taIOVTq6g2FKjQ== X-Received: by 2002:a9d:577d:: with SMTP id x58-v6mr9828321oti.196.1529372803862; Mon, 18 Jun 2018 18:46:43 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id k47-v6sm9223201otb.50.2018.06.18.18.46.42 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:46:42 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:41:32 -0500 Message-Id: <20180619014319.28272-7-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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:c0f::242 Subject: [Qemu-devel] [PATCH 006/113] spapr: Allow some cases where we can't set VSMT mode in the kernel X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Greg Kurz , qemu-stable@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: David Gibson At present if we require a vsmt mode that's not equal to the kernel's default, and the kernel doesn't let us change it (e.g. because it's an old kernel without support) then we always fail. But in fact we can cope with the kernel having a different vsmt as long as a) it's >= the actual number of vthreads/vcore (so that guest threads that are supposed to be on the same core act like it) b) it's a submultiple of the requested vsmt mode (so that guest threads spaced by the vsmt value will act like they're on different cores) Allowing this case gives us a bit more freedom to adjust the vsmt behaviour without breaking existing cases. Signed-off-by: David Gibson Reviewed-by: Laurent Vivier Tested-by: Greg Kurz Reviewed-by: Greg Kurz (cherry picked from commit 1f20f2e0ee61d91abff4e86ed1cda1b5244647d3) Signed-off-by: Greg Kurz --- hw/ppc/spapr.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index b57528baf4..37388f1416 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2291,17 +2291,29 @@ static void spapr_set_vsmt_mode(sPAPRMachineState *spapr, Error **errp) if (kvm_enabled() && (spapr->vsmt != kvm_smt)) { ret = kvmppc_set_smt_threads(spapr->vsmt); if (ret) { + /* Looks like KVM isn't able to change VSMT mode */ error_setg(&local_err, "Failed to set KVM's VSMT mode to %d (errno %d)", spapr->vsmt, ret); - if (!vsmt_user) { - error_append_hint(&local_err, "On PPC, a VM with %d threads/" - "core on a host with %d threads/core requires " - " the use of VSMT mode %d.\n", - smp_threads, kvm_smt, spapr->vsmt); + /* We can live with that if the default one is big enough + * for the number of threads, and a submultiple of the one + * we want. In this case we'll waste some vcpu ids, but + * behaviour will be correct */ + if ((kvm_smt >= smp_threads) && ((spapr->vsmt % kvm_smt) == 0)) { + warn_report_err(local_err); + local_err = NULL; + goto out; + } else { + if (!vsmt_user) { + error_append_hint(&local_err, + "On PPC, a VM with %d threads/core" + " on a host with %d threads/core" + " requires the use of VSMT mode %d.\n", + smp_threads, kvm_smt, spapr->vsmt); + } + kvmppc_hint_smt_possible(&local_err); + goto out; } - kvmppc_hint_smt_possible(&local_err); - goto out; } } /* else TCG: nothing to do currently */ From patchwork Tue Jun 19 01:41: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: 931330 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="sggz2EMF"; 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 418tBR17NNz9s1R for ; Tue, 19 Jun 2018 13:05:35 +1000 (AEST) Received: from localhost ([::1]:38886 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6xY-0005zM-OJ for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 23:05:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47122) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5jh-0003B9-OY for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:47:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5jg-0000tP-Aw for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:47:09 -0400 Received: from mail-oi0-x22b.google.com ([2607:f8b0:4003:c06::22b]:38225) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5jg-0000tG-4g; Mon, 18 Jun 2018 21:47:08 -0400 Received: by mail-oi0-x22b.google.com with SMTP id d5-v6so16700344oib.5; Mon, 18 Jun 2018 18:47: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=UiVv1Trnvv07dDzo/0bC0ktZxQ2Y/mNNYEq/Zu8XOFQ=; b=sggz2EMFIoaGxHiZVTqN4v+wzokLTPi/xs2N/cNIouN5OdoMQ9toV4MIH1/wt/ETEF 2MnRYnn37CF1x/v5e18Nag8SW9MA9v8OK6YUa9qXvkDLWGzz7ejJNVDUzuXcEnT0sAvl 1eEVmDl5DPcET2+Y1g5vg+nSpYP7PGG9MdomLVe1p67wFMXs0XMVD56EiqFdEXnOYrBv ZFDXBEO9VSXhrGcvOgnh7FTd1KGAV5KYSPQ1xDgo+LZEdK2ymNCDmwq5Uhf4vzAKuqky +YCAjmCFfVxl/dnYIAaQWkXE6Z8i1lwpoG7hG0vbbA4cbGjjqo0oAjmHezKGetCX8OJO FKkA== 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=UiVv1Trnvv07dDzo/0bC0ktZxQ2Y/mNNYEq/Zu8XOFQ=; b=LNdj1vQBCuAQlIEbnfPNjEmbXeTmgHthAlY/VPWXvkT6VRMfj5h3BcdP4nz8EG5Kig n+2QCMfkvxP5GDsoNUTF3g/R9wnTS9nsDLUGEHSn4QVhV8VX0Q5ESIVup3uXE3FW7I5y nSISGALkXVK6rLAyXvNZ97Buj4QxHRqFwH3yKBPXu2bfOOoKcNpbKqBHYoPhtl0EzMxa 9sIKysyyB5SCPtC6yLdnkKuVz9m+agi8nGFBKmVR8MYz3XU9BCkOrdgEift6fyuNIrRY txsmuGf55cGIMYF3Yu1ZNN0tauG5ewJ6E/AfsAzj/sBZawNgcu+R/uzmCOGRjWdlVGNz UFLg== X-Gm-Message-State: APt69E0Y7ks97EW73+1Im8HNGGPjOdisAd/Re2FgHQXkDMAnCXOeQ32e 9REfu6tSYYiJWWn2YEwwjL5plqQUE2g= X-Google-Smtp-Source: ADUXVKJlX0UIF3dzBdqNjdyp8itGwsLU66bN0rpMqzA+yyCqdzJasPTeYzq9vmDmhPzas2TGeyJrAQ== X-Received: by 2002:aca:4456:: with SMTP id r83-v6mr7999974oia.270.1529372826984; Mon, 18 Jun 2018 18:47:06 -0700 (PDT) Received: from localhost ([2600:1700:70:e488:b0ee:9bda:ee6f:91be]) by smtp.gmail.com with ESMTPSA id z44-v6sm9636793otc.46.2018.06.18.18.47.05 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:47:06 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:41:33 -0500 Message-Id: <20180619014319.28272-8-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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 007/113] spapr: Adjust default VSMT value for better migration compatibility X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Greg Kurz , qemu-stable@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: David Gibson fa98fbfc "PC: KVM: Support machine option to set VSMT mode" introduced the "vsmt" parameter for the pseries machine type, which controls the spacing of the vcpu ids of thread 0 for each virtual core. This was done to bring some consistency and stability to how that was done, while still allowing backwards compatibility for migration and otherwise. The default value we used for vsmt was set to the max of the host's advertised default number of threads and the number of vthreads per vcore in the guest. This was done to continue running without extra parameters on older KVM versions which don't allow the VSMT value to be changed. Unfortunately, even that smaller than before leakage of host configuration into guest visible configuration still breaks things. Specifically a guest with 4 (or less) vthread/vcore will get a different vsmt value when running on a POWER8 (vsmt==8) and POWER9 (vsmt==4) host. That means the vcpu ids don't line up so you can't migrate between them, though you should be able to. Long term we really want to make vsmt == smp_threads for sufficiently new machine types. However, that means that qemu will then require a sufficiently recent KVM (one which supports changing VSMT) - that's still not widely enough deployed to be really comfortable to do. In the meantime we need some default that will work as often as possible. This patch changes that default to 8 in all circumstances. This does change guest visible behaviour (including for existing machine versions) for many cases - just not the most common/important case. Following is case by case justification for why this is still the least worst option. Note that any of the old behaviours can still be duplicated after this patch, it's just that it requires manual intervention by setting the vsmt property on the command line. KVM HV on POWER8 host: This is the overwhelmingly common case in production setups, and is unchanged by design. POWER8 hosts will advertise a default VSMT mode of 8, and > 8 vthreads/vcore isn't permitted KVM HV on POWER7 host: Will break, but POWER7s allowing KVM were never released to the public. KVM HV on POWER9 host: Not yet released to the public, breaking this now will reduce other breakage later. KVM HV on PowerPC 970: Will theoretically break it, but it was barely supported to begin with and already required various user visible hacks to work. Also so old that I just don't care. TCG: This is the nastiest one; it means migration of TCG guests (without manual vsmt setting) will break. Since TCG is rarely used in production I think this is worth it for the other benefits. It does also remove one more barrier to TCG<->KVM migration which could be interesting for debugging applications. KVM PR: As with TCG, this will break migration of existing configurations, without adding extra manual vsmt options. As with TCG, it is rare in production so I think the benefits outweigh breakages. Signed-off-by: David Gibson Reviewed-by: Laurent Vivier Reviewed-by: Jose Ricardo Ziviani Reviewed-by: Greg Kurz (cherry picked from commit 8904e5a75005fe579c28806003892d8ae4a27dfa) Signed-off-by: Greg Kurz --- hw/ppc/spapr.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 37388f1416..0c6547faef 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2282,9 +2282,14 @@ static void spapr_set_vsmt_mode(sPAPRMachineState *spapr, Error **errp) } /* In this case, spapr->vsmt has been set by the command line */ } else { - /* Choose a VSMT mode that may be higher than necessary but is - * likely to be compatible with hosts that don't have VSMT. */ - spapr->vsmt = MAX(kvm_smt, smp_threads); + /* + * Default VSMT value is tricky, because we need it to be as + * consistent as possible (for migration), but this requires + * changing it for at least some existing cases. We pick 8 as + * the value that we'd get with KVM on POWER8, the + * overwhelmingly common case in production systems. + */ + spapr->vsmt = 8; } /* KVM: If necessary, set the SMT mode: */ From patchwork Tue Jun 19 01:41: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: 931351 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="rgyIyIOb"; 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 418thV3ymhz9s19 for ; Tue, 19 Jun 2018 13:28:10 +1000 (AEST) Received: from localhost ([::1]:39068 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV7JQ-0007Xl-7L for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 23:28:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47429) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5k4-0003VQ-MH for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:47:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5k3-00016k-QS for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:47:32 -0400 Received: from mail-ot0-x242.google.com ([2607:f8b0:4003:c0f::242]:46328) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5k3-00016A-Lt; Mon, 18 Jun 2018 21:47:31 -0400 Received: by mail-ot0-x242.google.com with SMTP id v24-v6so12230813otk.13; Mon, 18 Jun 2018 18:47:31 -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=VbHSHczm6kRZ3SxNutgNs35u4qeOQ6xR2EZdRxwnzos=; b=rgyIyIOb3DCWITIV9az4McNz83GmyIrfSN1q5rs0og7CME1YPEKZ2GPgVI/1t4U9Zw FjtW+3g0dVYtRJuSBm0vH3+p0VTJ6gfeWTDon0W0Ne34N2aIhxYKYzCcIYf2JB+NSJb2 4krzPWIBlVw6qD3az4Qzv3UjIVvB2xNxIklpWT7AaaOLn8ifzoXUszH+IaSHOTKIkYFZ hpntOqRT72gLTgrovYpViccd7N9QXP4wB5N6Nm0xgRE+UmTro+uh1zQC4drWV6gNB8E2 SZNM9k3w+yKheORn9Y9qCQDMlpEsrPk/hzqsa9rYHnimvtfGyYmRoO8fsppz6sZsN/ty nK/Q== 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=VbHSHczm6kRZ3SxNutgNs35u4qeOQ6xR2EZdRxwnzos=; b=mtLdiAIJXBTBDvfNUw9weF7zEr2IGmc5AsBhZ7ThFpdBVV6iG0BJ7ij8fiBfVw1Byf xNh9FGCzO/riCKh7oYF/BdgrlYaxYalSP613NugaqhpmTOVQw5t4YvR51K2O5bk4Kk9O giQaysbS8w2xSSmYwcgT36UK4YPpOwx4XqYubiBtgcWSJilY+GtZZKtn6OuQsVxI8b1g +1FLHeFUN5uTKhDPRr0Zdqgfx5hbhDtbq8RjVc0i4KlAgCG5WQz6eqD+7YlZcdFbkQPs 2bM5K4Vcak2O6AekMPjQBuUlLrIuJoktAkkwQx5sdKgurifqEFRhZ4WjV85WGBnVHIRs QghA== X-Gm-Message-State: APt69E0oi/A3+kYe+3aGe8WXurdPYa4aUPLHpF+wZAkU7swfYy05UTsZ Oo4dhfSePgD/HTy6oZzeA6Z2uiqBiYU= X-Google-Smtp-Source: ADUXVKL/LS6iw2Sw/g2urcVZNMs9Bu6vhb+pW+nFN1ENPihfz+Er6z+i642g1T+Nprihj+w9jhOTKQ== X-Received: by 2002:a9d:1012:: with SMTP id h18-v6mr8661669ote.364.1529372850537; Mon, 18 Jun 2018 18:47:30 -0700 (PDT) Received: from localhost ([2600:1700:70:e488:b0ee:9bda:ee6f:91be]) by smtp.gmail.com with ESMTPSA id v8-v6sm16551556oti.35.2018.06.18.18.47.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:47:29 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:41:34 -0500 Message-Id: <20180619014319.28272-9-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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:c0f::242 Subject: [Qemu-devel] [PATCH 008/113] spapr: set vsmt to MAX(8, smp_threads) 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: Laurent Vivier , Greg Kurz , qemu-stable@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Laurent Vivier We ignore silently the value of smp_threads when we set the default VSMT value, and if smp_threads is greater than VSMT kernel is going into trouble later. Fixes: 8904e5a750 ("spapr: Adjust default VSMT value for better migration compatibility") Signed-off-by: Laurent Vivier Reviewed-by: Greg Kurz Signed-off-by: David Gibson (cherry picked from commit 4ad64cbd0c3f9df15be5f7d1c920285551e802ca) Signed-off-by: Greg Kurz --- hw/ppc/spapr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 0c6547faef..6f78c1cf7a 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2289,7 +2289,7 @@ static void spapr_set_vsmt_mode(sPAPRMachineState *spapr, Error **errp) * the value that we'd get with KVM on POWER8, the * overwhelmingly common case in production systems. */ - spapr->vsmt = 8; + spapr->vsmt = MAX(8, smp_threads); } /* KVM: If necessary, set the SMT mode: */ From patchwork Tue Jun 19 01:41: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: 931246 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="KcunkjlN"; 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 418rYs5Lpfz9s0W for ; Tue, 19 Jun 2018 11:52:17 +1000 (AEST) Received: from localhost ([::1]:38395 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5od-0006AI-BF for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 21:52:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44419) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5gY-0008SJ-SV for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:43:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5gU-0007bg-An for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:43:54 -0400 Received: from mail-ot0-x242.google.com ([2607:f8b0:4003:c0f::242]:36216) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5gU-0007ar-3k; Mon, 18 Jun 2018 21:43:50 -0400 Received: by mail-ot0-x242.google.com with SMTP id c15-v6so20774662otl.3; Mon, 18 Jun 2018 18:43: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=lskHDsTshqm8kYT9BCkBdOyQU+5alT3xAZIZr1jbusk=; b=KcunkjlNljBT1UIhYdWLykUYvUghatIclLIHll1d4DBP0GT3PisjnbJY1WMqa8TMZR hvIllE0nY5bZE+2jp04TgR6/xQ7k8TD+UAUpcvfzVk13RB4pAFS91OxQNjtN37cYZY6j gwaylvtYSLxzFy5Q/Xoi32PD2iy12pOU3euZsFIbnfh5uo+0jJVFfoMlPn07wZVl0H3+ f8IU8IK4HLNm2SUujrjiFAfvCec8fmiZLVgGoShDZdyXQkk8AQJsYB0LnGCitMJld1Py LYU8QlINLboapNTzGA1phNnt7pNE39Scjq3QBUl1ExwR5GW/umNq/pbfIZxNc0qFm8Sv RZ5w== 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=lskHDsTshqm8kYT9BCkBdOyQU+5alT3xAZIZr1jbusk=; b=thmeYiMXBGulFEbfg+tVgaq5PEzRPlCUKIFDxSHCSxjcLQvrM/E1jGsUfqblLN3LJE 4ihLfRyRGVDdJAFuy+0Lu3uydXTCjLxlKqZJtUkdo4pcQMvH+myvK/lDuUhh+6DNL/I2 wEIpNueU/mIGv9GLANXa2VUA1nq/uL7ryojRQM9cwGKjAVv5jqE4Ce5VadD+o4lUPI87 rI0QOYPcAMfKz3lvvcoUWaXJqhX7gHw7fk6919aE8QX4YVareKAB1ZvjHpvfL+7cVXvW mdwufNbsovGMbNQZK3pKiAGBRLaO3es0PUaX8tZuCs7pxgwnlAVvru68df0cumJ13Zrg 6BUA== X-Gm-Message-State: APt69E1gaNEIakZO/BPjvUItPwYuF7B49ODKwz8PvwU1+YmSHroRzios hYdL0v32L7em4fvgoIKmZTmVi0Mi X-Google-Smtp-Source: ADUXVKL286qVFcHOOQFlsQYJiQPUifBZBZVV/F6qSp3kGo3R3ry3pj4wmfXMXaXcJiabnqDlTSNPGA== X-Received: by 2002:a9d:55d9:: with SMTP id z25-v6mr8695642oti.131.1529372628780; Mon, 18 Jun 2018 18:43: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 t4-v6sm16635209otd.40.2018.06.18.18.43.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:43:47 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:41:35 -0500 Message-Id: <20180619014319.28272-10-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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:c0f::242 Subject: [Qemu-devel] [PATCH 009/113] spapr: use spapr->vsmt to compute VCPU ids 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 Since the introduction of VSMT in 2.11, the spacing of VCPU ids between cores is controllable through a machine property instead of being only dictated by the SMT mode of the host: cpu->vcpu_id = (cc->core_id * spapr->vsmt / smp_threads) + i Until recently, the machine code would try to change the SMT mode of the host to be equal to VSMT or exit. This allowed the rest of the code to assume that kvmppc_smt_threads() == spapr->vsmt is always true. Recent commit "8904e5a75005 spapr: Adjust default VSMT value for better migration compatibility" relaxed the rule. If the VSMT mode cannot be set in KVM for some reasons, but the requested CPU topology is compatible with the current SMT mode, then we let the guest run with kvmppc_smt_threads() != spapr->vsmt. This breaks quite a few places in the code, in particular when calculating DRC indexes. This is what happens on a POWER host with subcores-per-core=2 (ie, supports up to SMT4) when passing the following topology: -smp threads=4,maxcpus=16 \ -device host-spapr-cpu-core,core-id=4,id=core1 \ -device host-spapr-cpu-core,core-id=8,id=core2 qemu-system-ppc64: warning: Failed to set KVM's VSMT mode to 8 (errno -22) This is expected since KVM is limited to SMT4, but the guest is started anyway because this topology can run on SMT4 even with a VSMT8 spacing. But when we look at the DT, things get nastier: cpus { ... ibm,drc-indexes = <0x4 0x10000000 0x10000004 0x10000008 0x1000000c>; This means that we have the following association: CPU core device | DRC | VCPU id -----------------+------------+--------- boot core | 0x10000000 | 0 core1 | 0x10000004 | 4 core2 | 0x10000008 | 8 core3 | 0x1000000c | 12 But since the spacing of VCPU ids is 8, the DRC for core1 points to a VCPU that doesn't exist, the DRC for core2 points to the first VCPU of core1 and and so on... ... PowerPC,POWER8@0 { ... ibm,my-drc-index = <0x10000000>; ... }; PowerPC,POWER8@8 { ... ibm,my-drc-index = <0x10000008>; ... }; PowerPC,POWER8@10 { ... No ibm,my-drc-index property for this core since 0x10000010 doesn't exist in ibm,drc-indexes above. ... }; }; ... interrupt-controller { ... ibm,interrupt-server-ranges = <0x0 0x10>; With a spacing of 8, the highest VCPU id for the given topology should be: 16 * 8 / 4 = 32 and not 16 ... linux,phandle = <0x7e7323b8>; interrupt-controller; }; And CPU hot-plug/unplug is broken: (qemu) device_del core1 pseries-hotplug-cpu: Cannot find CPU (drc index 10000004) to remove (qemu) device_del core2 cpu 4 (hwid 8) Ready to die... cpu 5 (hwid 9) Ready to die... cpu 6 (hwid 10) Ready to die... cpu 7 (hwid 11) Ready to die... These are the VCPU ids of core1 actually (qemu) device_add host-spapr-cpu-core,core-id=12,id=core3 (qemu) device_del core3 pseries-hotplug-cpu: Cannot find CPU (drc index 1000000c) to remove This patches all the code in hw/ppc/spapr.c to assume the VSMT spacing when manipulating VCPU ids. Fixes: 8904e5a75005 Signed-off-by: Greg Kurz Signed-off-by: David Gibson (cherry picked from commit 72194664c8a16b67865eb95054f984dd169cfa86) Signed-off-by: Greg Kurz Signed-off-by: Greg Kurz --- hw/ppc/spapr.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 6f78c1cf7a..094e75f97d 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -161,9 +161,9 @@ static void pre_2_10_vmstate_unregister_dummy_icp(int i) (void *)(uintptr_t) i); } -static inline int xics_max_server_number(void) +static int xics_max_server_number(sPAPRMachineState *spapr) { - return DIV_ROUND_UP(max_cpus * kvmppc_smt_threads(), smp_threads); + return DIV_ROUND_UP(max_cpus * spapr->vsmt, smp_threads); } static void xics_system_init(MachineState *machine, int nr_irqs, Error **errp) @@ -195,7 +195,7 @@ static void xics_system_init(MachineState *machine, int nr_irqs, Error **errp) if (smc->pre_2_10_has_unused_icps) { int i; - for (i = 0; i < xics_max_server_number(); i++) { + for (i = 0; i < xics_max_server_number(spapr); i++) { /* Dummy entries get deregistered when real ICPState objects * are registered during CPU core hotplug. */ @@ -338,7 +338,6 @@ static int spapr_fixup_cpu_dt(void *fdt, sPAPRMachineState *spapr) int ret = 0, offset, cpus_offset; CPUState *cs; char cpu_model[32]; - int smt = kvmppc_smt_threads(); uint32_t pft_size_prop[] = {0, cpu_to_be32(spapr->htab_shift)}; CPU_FOREACH(cs) { @@ -347,7 +346,7 @@ static int spapr_fixup_cpu_dt(void *fdt, sPAPRMachineState *spapr) int index = spapr_vcpu_id(cpu); int compat_smt = MIN(smp_threads, ppc_compat_max_threads(cpu)); - if ((index % smt) != 0) { + if (index % spapr->vsmt != 0) { continue; } @@ -614,7 +613,6 @@ static void spapr_populate_cpus_dt_node(void *fdt, sPAPRMachineState *spapr) CPUState *cs; int cpus_offset; char *nodename; - int smt = kvmppc_smt_threads(); cpus_offset = fdt_add_subnode(fdt, 0, "cpus"); _FDT(cpus_offset); @@ -632,7 +630,7 @@ static void spapr_populate_cpus_dt_node(void *fdt, sPAPRMachineState *spapr) DeviceClass *dc = DEVICE_GET_CLASS(cs); int offset; - if ((index % smt) != 0) { + if (index % spapr->vsmt != 0) { continue; } @@ -1105,7 +1103,7 @@ static void *spapr_build_fdt(sPAPRMachineState *spapr, _FDT(fdt_setprop_cell(fdt, 0, "#size-cells", 2)); /* /interrupt controller */ - spapr_dt_xics(xics_max_server_number(), fdt, PHANDLE_XICP); + spapr_dt_xics(xics_max_server_number(spapr), fdt, PHANDLE_XICP); ret = spapr_populate_memory(spapr, fdt); if (ret < 0) { @@ -2198,7 +2196,6 @@ static void spapr_init_cpus(sPAPRMachineState *spapr) MachineState *machine = MACHINE(spapr); MachineClass *mc = MACHINE_GET_CLASS(machine); const char *type = spapr_get_cpu_core_type(machine->cpu_type); - int smt = kvmppc_smt_threads(); const CPUArchIdList *possible_cpus; int boot_cores_nr = smp_cpus / smp_threads; int i; @@ -2233,7 +2230,7 @@ static void spapr_init_cpus(sPAPRMachineState *spapr) if (mc->has_hotpluggable_cpus) { spapr_dr_connector_new(OBJECT(spapr), TYPE_SPAPR_DRC_CPU, - (core_id / smp_threads) * smt); + (core_id / smp_threads) * spapr->vsmt); } if (i < boot_cores_nr) { @@ -3262,10 +3259,10 @@ static void spapr_core_unplug_request(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { + sPAPRMachineState *spapr = SPAPR_MACHINE(OBJECT(hotplug_dev)); int index; sPAPRDRConnector *drc; CPUCore *cc = CPU_CORE(dev); - int smt = kvmppc_smt_threads(); if (!spapr_find_cpu_slot(MACHINE(hotplug_dev), cc->core_id, &index)) { error_setg(errp, "Unable to find CPU core with core-id: %d", @@ -3277,7 +3274,7 @@ void spapr_core_unplug_request(HotplugHandler *hotplug_dev, DeviceState *dev, return; } - drc = spapr_drc_by_id(TYPE_SPAPR_DRC_CPU, index * smt); + drc = spapr_drc_by_id(TYPE_SPAPR_DRC_CPU, index * spapr->vsmt); g_assert(drc); spapr_drc_detach(drc); @@ -3296,7 +3293,6 @@ static void spapr_core_plug(HotplugHandler *hotplug_dev, DeviceState *dev, CPUState *cs = CPU(core->threads); sPAPRDRConnector *drc; Error *local_err = NULL; - int smt = kvmppc_smt_threads(); CPUArchId *core_slot; int index; bool hotplugged = spapr_drc_hotplugged(dev); @@ -3307,7 +3303,7 @@ static void spapr_core_plug(HotplugHandler *hotplug_dev, DeviceState *dev, cc->core_id); return; } - drc = spapr_drc_by_id(TYPE_SPAPR_DRC_CPU, index * smt); + drc = spapr_drc_by_id(TYPE_SPAPR_DRC_CPU, index * spapr->vsmt); g_assert(drc || !mc->has_hotpluggable_cpus); From patchwork Tue Jun 19 01:41: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: 931251 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="ZKpDYJ7g"; 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 418rfW5vHqz9s0W for ; Tue, 19 Jun 2018 11:56:19 +1000 (AEST) Received: from localhost ([::1]:38422 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5sX-0000mZ-Ar for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 21:56:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44723) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5gv-0000NM-7K for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5gt-0007nL-MI for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:17 -0400 Received: from mail-oi0-x242.google.com ([2607:f8b0:4003:c06::242]:40995) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5gt-0007mz-GZ; Mon, 18 Jun 2018 21:44:15 -0400 Received: by mail-oi0-x242.google.com with SMTP id a141-v6so16691792oii.8; Mon, 18 Jun 2018 18:44: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=1nyoRAdVyiFmu0+FgWK7Qu9UPHmyHAM39c9AxhYp7qE=; b=ZKpDYJ7gJFXw/tVQwCCefPQ+4j4Ys+6PnuEtpehkDQehlgskmDgM+72tHRMfCorGsM Rayrx2xAqXbLOWCdylX79rRjc0QlHTzNXJv/axaFNCVQCxf3O8dzKNiPkMUhBsWGFTpi 7sSvGZQkkbefJe3C+oEVzphBzIHn6z9sEbpIam39Ysq1O5n8nuEqoW/ecmRZ9WU6qZug dhOc3sscUPxV88hROVmMniGtecAi78hPyHmTEoJUvUSbsRbxXhBg4TbnGy97S2QJrxU1 I2aySAhmnNMEmjGgtdCOOCz2HYdWexa8+OWVg4mJs9BX3lBCfWfbnUi8FbSOSePacayE WhZQ== 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=1nyoRAdVyiFmu0+FgWK7Qu9UPHmyHAM39c9AxhYp7qE=; b=tGNWHIqzP11crj1OFK8QCzXTVmigogoG+uS8T7MUAxwy+y3VzaZD0rZaW6gg8bOV9S H8dMU/l0YFcBMlu2qMy3VESjUhRXNQWftlwq3oCptfMkwc1BZjgXiN5uPLzO0/X7nFej zspxHNRBESaBPEBm0Mn7ZQZZOJ9UZL6R2fnNHBVttgp6V78hC5kMLORsXH3L6bXSpw9+ FrtbEUrmvH6akx7GypsPVgH11CRiTwEjmG0xLxp6lvGBp9niOgH7fel+WSSueAPpDj+p d/knoHC0gpz8JNtlll9ZUUlFavMuRVaTCx4aY2uiY0M6QzX26AZO7/k0n5ASA9/74gm8 oTNw== X-Gm-Message-State: APt69E31+sZSE+pcoWnZuB+tZmSrTgCKXFOzUpKGzDq9Rs2QKNK5sbpU ta/v9EWN9HxvgBWLpFDjI4buYaJw X-Google-Smtp-Source: ADUXVKISkUdOFWW9RYggccV6qlHUVkx5X92RJWzwpiqEi7sPwJcOFx2lH3zc8UPVCb69Bdvx688DzA== X-Received: by 2002:aca:480d:: with SMTP id v13-v6mr8713605oia.244.1529372654280; Mon, 18 Jun 2018 18:44: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 q7-v6sm15879766otq.39.2018.06.18.18.44.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:44:13 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:41:36 -0500 Message-Id: <20180619014319.28272-11-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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 010/113] spapr: move VCPU calculation to core machine code 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 VCPU ids are currently computed and assigned to each individual CPU threads in spapr_cpu_core_realize(). But the numbering logic of VCPU ids is actually a machine-level concept, and many places in hw/ppc/spapr.c also have to compute VCPU ids out of CPU indexes. The current formula used in spapr_cpu_core_realize() is: vcpu_id = (cc->core_id * spapr->vsmt / smp_threads) + i where: cc->core_id is a multiple of smp_threads cpu_index = cc->core_id + i 0 <= i < smp_threads So we have: cpu_index % smp_threads == i cc->core_id / smp_threads == cpu_index / smp_threads hence: vcpu_id = (cpu_index / smp_threads) * spapr->vsmt + cpu_index % smp_threads; This formula was used before VSMT at the time VCPU ids where computed at the target emulation level. It has the advantage of being useable to derive a VPCU id out of a CPU index only. It is fitted for all the places where the machine code has to compute a VCPU id. This patch introduces an accessor to set the VCPU id in a PowerPCCPU object using the above formula. It is a first step to consolidate all the VCPU id logic in a single place. Signed-off-by: Greg Kurz Signed-off-by: David Gibson (cherry picked from commit 648edb64751ea0e550f36302fa66f9f11e480824) Signed-off-by: Greg Kurz --- hw/ppc/spapr.c | 19 +++++++++++++++++++ hw/ppc/spapr_cpu_core.c | 9 ++------- include/hw/ppc/spapr.h | 1 + 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 094e75f97d..f9505d926d 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3647,6 +3647,25 @@ int spapr_vcpu_id(PowerPCCPU *cpu) } } +void spapr_set_vcpu_id(PowerPCCPU *cpu, int cpu_index, Error **errp) +{ + sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine()); + int vcpu_id; + + vcpu_id = + (cpu_index / smp_threads) * spapr->vsmt + cpu_index % smp_threads; + + if (kvm_enabled() && !kvm_vcpu_id_is_valid(vcpu_id)) { + error_setg(errp, "Can't create CPU with id %d in KVM", vcpu_id); + error_append_hint(errp, "Adjust the number of cpus to %d " + "or try to raise the number of threads per core\n", + vcpu_id * smp_threads / spapr->vsmt); + return; + } + + cpu->vcpu_id = vcpu_id; +} + PowerPCCPU *spapr_find_cpu(int vcpu_id) { CPUState *cs; diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c index e8b0ffb1b1..1c508022aa 100644 --- a/hw/ppc/spapr_cpu_core.c +++ b/hw/ppc/spapr_cpu_core.c @@ -176,13 +176,8 @@ static void spapr_cpu_core_realize(DeviceState *dev, Error **errp) cs = CPU(obj); cpu = POWERPC_CPU(cs); cs->cpu_index = cc->core_id + i; - cpu->vcpu_id = (cc->core_id * spapr->vsmt / smp_threads) + i; - if (kvm_enabled() && !kvm_vcpu_id_is_valid(cpu->vcpu_id)) { - error_setg(&local_err, "Can't create CPU with id %d in KVM", - cpu->vcpu_id); - error_append_hint(&local_err, "Adjust the number of cpus to %d " - "or try to raise the number of threads per core\n", - cpu->vcpu_id * smp_threads / spapr->vsmt); + spapr_set_vcpu_id(cpu, cs->cpu_index, &local_err); + if (local_err) { goto err; } diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index 363ffd71c4..38a657426a 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -757,6 +757,7 @@ void spapr_do_system_reset_on_cpu(CPUState *cs, run_on_cpu_data arg); #define HTAB_SIZE(spapr) (1ULL << ((spapr)->htab_shift)) int spapr_vcpu_id(PowerPCCPU *cpu); +void spapr_set_vcpu_id(PowerPCCPU *cpu, int cpu_index, Error **errp); PowerPCCPU *spapr_find_cpu(int vcpu_id); int spapr_caps_pre_load(void *opaque); From patchwork Tue Jun 19 01:41: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: 931245 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="Lj9ssl+i"; 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 418rWm4gnYz9s2t for ; Tue, 19 Jun 2018 11:50:28 +1000 (AEST) Received: from localhost ([::1]:38383 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5ms-0004wn-8x for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 21:50:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44934) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5h5-0000du-K8 for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5h4-0007t0-G4 for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:27 -0400 Received: from mail-ot0-x241.google.com ([2607:f8b0:4003:c0f::241]:39246) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5h4-0007sn-AQ; Mon, 18 Jun 2018 21:44:26 -0400 Received: by mail-ot0-x241.google.com with SMTP id l15-v6so20759915oth.6; Mon, 18 Jun 2018 18:44: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=9u85GqDuv10LNFws7nG2TiUXyiSirr2MAc/8uq/9u2c=; b=Lj9ssl+iuOCXYXWg6pGa0Lwfzlcg42b2ccBXS0mu/3jFf8usXPgW/zsJnopm4TY4UB QieAaywdj9QqMRFPqdCH342Kgmv4LTTbexd/jF1XlsfZpxkc7oBeVbAAZ7eZR75o01or Cv1zm4IyyGfNhh/uCnV/jZsDuzYypIHqZ51VZKd6AOLPaT+4JCKHx/uSzelWr9enJoVa DFhjP29UXENwGOuh5fOhrSFfq7o54E9BQxq1O4/iU9ava/z4wPQ1kTBpSt2cceoOjKiP 773VTiR5CYI4JBABJxGWa1RAirB/eLjkIlypuvLmme3tsD08VTZsiuuAGNHDHj/0CwKv MnRA== 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=9u85GqDuv10LNFws7nG2TiUXyiSirr2MAc/8uq/9u2c=; b=lbAMxCm89EiaS28zU5hoqEPQe7aCUYVwJsvPagjehNKudwVC7wYDxS3iUg7houySbi Py8w1+v5LY8kFCrLbfmdyn+DAq4hqBuyCdeRW7iYh/rslCG1PIBr3omttbTmt8QbRirm Cve0dsOk/vNE1N+lwPfsVRdxLK12DdwteXAZUzqeiA/60MtvLYfUmPulmWDN+pXsEwLd EIL1sI6uwkmOlE1ZjyFSp/Y+wK4yZKhB19dnywmLtUJeSoHmjoGjKyOaqbNP2nflf5mf P/7z/7IVpV//6BXENRhKzQkw0p3VDBiYy9eqQxSNXaesblg+AKGZyqmDt7Qb2DCd28Id F2rQ== X-Gm-Message-State: APt69E1/LYitYAnF9z/8etUX71r4c1q0bNpHWsZVyhBbu9yhKEKAItuj mtsJwx+X9++pnCId0EKDHKzgPBfg X-Google-Smtp-Source: ADUXVKL3YlreFg3xdNVJI7MyCgtiQMVyLqIAJ6wbq4cxa87b2v2ZzBykXXf3s0N5B4kkYB85d/+aGw== X-Received: by 2002:a9d:5f09:: with SMTP id f9-v6mr9799064oti.386.1529372665050; Mon, 18 Jun 2018 18:44:25 -0700 (PDT) Received: from localhost ([2600:1700:70:e488:b0ee:9bda:ee6f:91be]) by smtp.gmail.com with ESMTPSA id e5-v6sm7306824otl.2.2018.06.18.18.44.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:44:24 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:41:37 -0500 Message-Id: <20180619014319.28272-12-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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:c0f::241 Subject: [Qemu-devel] [PATCH 011/113] target/ppc: Clarify compat mode max_threads value X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Greg Kurz , qemu-stable@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: David Gibson We recently had some discussions that were sidetracked for a while, because nearly everyone misapprehended the purpose of the 'max_threads' field in the compatiblity modes table. It's all about guest expectations, not host expectations or support (that's handled elsewhere). In an attempt to avoid a repeat of that confusion, rename the field to 'max_vthreads' and add an explanatory comment. Signed-off-by: David Gibson Reviewed-by: Laurent Vivier Reviewed-by: Greg Kurz Reviewed-by: Jose Ricardo Ziviani (cherry picked from commit abbc124753896f72e3715813ea20dd1924202ff0) Signed-off-by: Greg Kurz --- hw/ppc/spapr.c | 4 ++-- target/ppc/compat.c | 25 +++++++++++++++++-------- target/ppc/cpu.h | 2 +- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index f9505d926d..fc6ebe1b3a 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -344,7 +344,7 @@ static int spapr_fixup_cpu_dt(void *fdt, sPAPRMachineState *spapr) PowerPCCPU *cpu = POWERPC_CPU(cs); DeviceClass *dc = DEVICE_GET_CLASS(cs); int index = spapr_vcpu_id(cpu); - int compat_smt = MIN(smp_threads, ppc_compat_max_threads(cpu)); + int compat_smt = MIN(smp_threads, ppc_compat_max_vthreads(cpu)); if (index % spapr->vsmt != 0) { continue; @@ -502,7 +502,7 @@ static void spapr_populate_cpu_dt(CPUState *cs, void *fdt, int offset, size_t page_sizes_prop_size; uint32_t vcpus_per_socket = smp_threads * smp_cores; uint32_t pft_size_prop[] = {0, cpu_to_be32(spapr->htab_shift)}; - int compat_smt = MIN(smp_threads, ppc_compat_max_threads(cpu)); + int compat_smt = MIN(smp_threads, ppc_compat_max_vthreads(cpu)); sPAPRDRConnector *drc; int drc_index; uint32_t radix_AP_encodings[PPC_PAGE_SIZES_MAX_SZ]; diff --git a/target/ppc/compat.c b/target/ppc/compat.c index 276b5b52c2..807c906f68 100644 --- a/target/ppc/compat.c +++ b/target/ppc/compat.c @@ -32,7 +32,16 @@ typedef struct { uint32_t pvr; uint64_t pcr; uint64_t pcr_level; - int max_threads; + + /* + * Maximum allowed virtual threads per virtual core + * + * This is to stop older guests getting confused by seeing more + * threads than they think the cpu can support. Usually it's + * equal to the number of threads supported on bare metal + * hardware, but not always (see POWER9). + */ + int max_vthreads; } CompatInfo; static const CompatInfo compat_table[] = { @@ -45,28 +54,28 @@ static const CompatInfo compat_table[] = { .pcr = PCR_COMPAT_3_00 | PCR_COMPAT_2_07 | PCR_COMPAT_2_06 | PCR_COMPAT_2_05 | PCR_TM_DIS | PCR_VSX_DIS, .pcr_level = PCR_COMPAT_2_05, - .max_threads = 2, + .max_vthreads = 2, }, { /* POWER7, ISA2.06 */ .name = "power7", .pvr = CPU_POWERPC_LOGICAL_2_06, .pcr = PCR_COMPAT_3_00 | PCR_COMPAT_2_07 | PCR_COMPAT_2_06 | PCR_TM_DIS, .pcr_level = PCR_COMPAT_2_06, - .max_threads = 4, + .max_vthreads = 4, }, { .name = "power7+", .pvr = CPU_POWERPC_LOGICAL_2_06_PLUS, .pcr = PCR_COMPAT_3_00 | PCR_COMPAT_2_07 | PCR_COMPAT_2_06 | PCR_TM_DIS, .pcr_level = PCR_COMPAT_2_06, - .max_threads = 4, + .max_vthreads = 4, }, { /* POWER8, ISA2.07 */ .name = "power8", .pvr = CPU_POWERPC_LOGICAL_2_07, .pcr = PCR_COMPAT_3_00 | PCR_COMPAT_2_07, .pcr_level = PCR_COMPAT_2_07, - .max_threads = 8, + .max_vthreads = 8, }, { /* POWER9, ISA3.00 */ .name = "power9", @@ -80,7 +89,7 @@ static const CompatInfo compat_table[] = { * confusing if half of the threads disappear from the guest * if it announces it's POWER9 aware at CAS time. */ - .max_threads = 8, + .max_vthreads = 8, }, }; @@ -192,14 +201,14 @@ void ppc_set_compat_all(uint32_t compat_pvr, Error **errp) } } -int ppc_compat_max_threads(PowerPCCPU *cpu) +int ppc_compat_max_vthreads(PowerPCCPU *cpu) { const CompatInfo *compat = compat_by_pvr(cpu->compat_pvr); int n_threads = CPU(cpu)->nr_threads; if (cpu->compat_pvr) { g_assert(compat); - n_threads = MIN(n_threads, compat->max_threads); + n_threads = MIN(n_threads, compat->max_vthreads); } return n_threads; diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index 370b05e76e..1b317845e8 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -1382,7 +1382,7 @@ void ppc_set_compat(PowerPCCPU *cpu, uint32_t compat_pvr, Error **errp); #if !defined(CONFIG_USER_ONLY) void ppc_set_compat_all(uint32_t compat_pvr, Error **errp); #endif -int ppc_compat_max_threads(PowerPCCPU *cpu); +int ppc_compat_max_vthreads(PowerPCCPU *cpu); void ppc_compat_add_property(Object *obj, const char *name, uint32_t *compat_pvr, const char *basedesc, Error **errp); From patchwork Tue Jun 19 01:41: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: 931252 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="X6zzK0DR"; 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 418rgV2dLyz9s0W for ; Tue, 19 Jun 2018 11:57:10 +1000 (AEST) Received: from localhost ([::1]:38425 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5tL-0001NB-TS for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 21:57:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44959) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5h7-0000g6-HG for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5h6-0007th-Ep for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:29 -0400 Received: from mail-ot0-x242.google.com ([2607:f8b0:4003:c0f::242]:40769) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5h6-0007tZ-A0; Mon, 18 Jun 2018 21:44:28 -0400 Received: by mail-ot0-x242.google.com with SMTP id w9-v6so20743732otj.7; Mon, 18 Jun 2018 18:44: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=TAcX12DFcO/HBUJ37nxdU99y5mawzSYvl/Llw6IPiPE=; b=X6zzK0DRV/GmwVCx0lm+XF/b2SB+G/Jgu/HEkehuOa+oibPN8GzkOU8Osfo0hEefcE F6RY8rINb+gX1nyTgCGQttxag3dH/m3edoKnRLuY/CPJCAPW9zGe8RW/H86mBWutYa4g 29i3K7C8k2BieId5yJ3GhRX7P7ridnCnOIxYxJf0OeyFtnMo5jANgZdEjnh5j+jicacn FACpTrX/GgQbXoPNRYplcgV48VJvrpU8i/uAVYSLp//nyc4oI2rw8hpNyd/szhf0pGOk dUqxFjvtiuu2/JGOL310Y5e72SaytHENwWyGC4Q8c1J1SfL1E1G/YNPGIBptGH27MnrQ h1ZA== 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=TAcX12DFcO/HBUJ37nxdU99y5mawzSYvl/Llw6IPiPE=; b=Rci8SZuyPdSuqjFRs3B+so0x6ZNXuRetzmd1ZbD5erwQwfgFLJ5LLeK/lLJPYOB24o g4yr18eXscR6GW8Ge63Tso1d7c66+IiIBnNyJ0XKVt25Fr+hXk4b0KCE43u960kzFkIB F8xVRjcBXMLRNd/BKKn6MAZF3r5cqeJMzWdmnGS6xRhWdSp4UQc24RqBsC6T4sC06GvX COXOr1ewiy/eZSfYVhy2t3vIf1X5AD2yw6O+p27ZAhEgx36HlkYPgQ+MzUCxFxQlOvKl 81Xs5gjjI6KGt1clxO6PFA2zbYPY5ZLbceMkRs121DQTrsvCoDHxN/e/UM+cjxf30kNx /y6w== X-Gm-Message-State: APt69E3fDOgN8pP4aOL6duinolNkemimQ8uje6EO/TMQ8uhKKUVmxI5u YWhZ7xXXWZs5b/ALnoM05W50FRkl X-Google-Smtp-Source: ADUXVKKslmQhQ3N0GVtVbU/dQgcqyihKoO/r5z9Fu8LcK3LA1T5BowC4eFylpBJQ7WX2VTxMR66JSw== X-Received: by 2002:a9d:6283:: with SMTP id x3-v6mr8434632otk.111.1529372667080; Mon, 18 Jun 2018 18:44: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 v13-v6sm7344457otk.73.2018.06.18.18.44.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:44:26 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:41:38 -0500 Message-Id: <20180619014319.28272-13-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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:c0f::242 Subject: [Qemu-devel] [PATCH 012/113] spapr: rename spapr_vcpu_id() to spapr_get_vcpu_id() 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 spapr_vcpu_id() function is an accessor actually. Let's rename it for symmetry with the recently added spapr_set_vcpu_id() helper. The motivation behind this is that a later patch will consolidate the VCPU id formula in a function and spapr_vcpu_id looks like an appropriate name. Signed-off-by: Greg Kurz Signed-off-by: David Gibson (cherry picked from commit 14bb4486c819ea797a151b3e0fe53d6f5c7b3fc5) Signed-off-by: Greg Kurz --- hw/ppc/spapr.c | 16 ++++++++-------- include/hw/ppc/spapr.h | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index fc6ebe1b3a..0be60fb044 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -210,7 +210,7 @@ static int spapr_fixup_cpu_smt_dt(void *fdt, int offset, PowerPCCPU *cpu, int i, ret = 0; uint32_t servers_prop[smt_threads]; uint32_t gservers_prop[smt_threads * 2]; - int index = spapr_vcpu_id(cpu); + int index = spapr_get_vcpu_id(cpu); if (cpu->compat_pvr) { ret = fdt_setprop_cell(fdt, offset, "cpu-version", cpu->compat_pvr); @@ -239,7 +239,7 @@ static int spapr_fixup_cpu_smt_dt(void *fdt, int offset, PowerPCCPU *cpu, static int spapr_fixup_cpu_numa_dt(void *fdt, int offset, PowerPCCPU *cpu) { - int index = spapr_vcpu_id(cpu); + int index = spapr_get_vcpu_id(cpu); uint32_t associativity[] = {cpu_to_be32(0x5), cpu_to_be32(0x0), cpu_to_be32(0x0), @@ -343,7 +343,7 @@ static int spapr_fixup_cpu_dt(void *fdt, sPAPRMachineState *spapr) CPU_FOREACH(cs) { PowerPCCPU *cpu = POWERPC_CPU(cs); DeviceClass *dc = DEVICE_GET_CLASS(cs); - int index = spapr_vcpu_id(cpu); + int index = spapr_get_vcpu_id(cpu); int compat_smt = MIN(smp_threads, ppc_compat_max_vthreads(cpu)); if (index % spapr->vsmt != 0) { @@ -492,7 +492,7 @@ static void spapr_populate_cpu_dt(CPUState *cs, void *fdt, int offset, PowerPCCPU *cpu = POWERPC_CPU(cs); CPUPPCState *env = &cpu->env; PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cs); - int index = spapr_vcpu_id(cpu); + int index = spapr_get_vcpu_id(cpu); uint32_t segs[] = {cpu_to_be32(28), cpu_to_be32(40), 0xffffffff, 0xffffffff}; uint32_t tbfreq = kvm_enabled() ? kvmppc_get_tbfreq() @@ -626,7 +626,7 @@ static void spapr_populate_cpus_dt_node(void *fdt, sPAPRMachineState *spapr) */ CPU_FOREACH_REVERSE(cs) { PowerPCCPU *cpu = POWERPC_CPU(cs); - int index = spapr_vcpu_id(cpu); + int index = spapr_get_vcpu_id(cpu); DeviceClass *dc = DEVICE_GET_CLASS(cs); int offset; @@ -3213,7 +3213,7 @@ static void *spapr_populate_hotplug_cpu_dt(CPUState *cs, int *fdt_offset, { PowerPCCPU *cpu = POWERPC_CPU(cs); DeviceClass *dc = DEVICE_GET_CLASS(cs); - int id = spapr_vcpu_id(cpu); + int id = spapr_get_vcpu_id(cpu); void *fdt; int offset, fdt_size; char *nodename; @@ -3636,7 +3636,7 @@ static void spapr_pic_print_info(InterruptStatsProvider *obj, ics_pic_print_info(spapr->ics, mon); } -int spapr_vcpu_id(PowerPCCPU *cpu) +int spapr_get_vcpu_id(PowerPCCPU *cpu) { CPUState *cs = CPU(cpu); @@ -3673,7 +3673,7 @@ PowerPCCPU *spapr_find_cpu(int vcpu_id) CPU_FOREACH(cs) { PowerPCCPU *cpu = POWERPC_CPU(cs); - if (spapr_vcpu_id(cpu) == vcpu_id) { + if (spapr_get_vcpu_id(cpu) == vcpu_id) { return cpu; } } diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index 38a657426a..fa02539b07 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -756,7 +756,7 @@ void spapr_do_system_reset_on_cpu(CPUState *cs, run_on_cpu_data arg); #define HTAB_SIZE(spapr) (1ULL << ((spapr)->htab_shift)) -int spapr_vcpu_id(PowerPCCPU *cpu); +int spapr_get_vcpu_id(PowerPCCPU *cpu); void spapr_set_vcpu_id(PowerPCCPU *cpu, int cpu_index, Error **errp); PowerPCCPU *spapr_find_cpu(int vcpu_id); From patchwork Tue Jun 19 01:41: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: 931249 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="B1Qiq7JT"; 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 418rcT0H3qz9s0W for ; Tue, 19 Jun 2018 11:54:32 +1000 (AEST) Received: from localhost ([::1]:38410 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5qo-0007m7-Jf for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 21:54:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45010) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5h9-0000i3-Fq for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5h8-0007ux-F4 for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:31 -0400 Received: from mail-ot0-x242.google.com ([2607:f8b0:4003:c0f::242]:44058) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5h8-0007uV-8k; Mon, 18 Jun 2018 21:44:30 -0400 Received: by mail-ot0-x242.google.com with SMTP id w13-v6so20755671ote.11; Mon, 18 Jun 2018 18:44: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=Dw2InTU21LfLKSNCXgyLaAbOpeDjlXNHVGmcP9gC4vM=; b=B1Qiq7JTYP3A97G54uDtbfcYzdMJ0anmqHkoU2W1ot9TOMamvK0fnMdbM3ZxBLBn3Z q0gdjl/4W/q/jAfpWqk5SBRaK8XAOF6ftNZ7kgFLaevlGFZjlHIDgQNDuaQl8ARUmFHj Gk32xfWDFKNOyDn/cvxxbOzQSZH8JP+VmUHBSuSIpQrvaRZHXyiS+tV2kz7ah0wb5/64 0877WtyrCyi6ukwq9ro8WHNBUO5kWlywszx5DKH3JnMm2BXDI12aeKd6xa5cq4RcVVui b5R6ZVebqga2A643HSqUkwsx4zHQFR1Hj8LLnXlBA46k6NJTKS8/erqlWhG0SKj0YB+6 nwoA== 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=Dw2InTU21LfLKSNCXgyLaAbOpeDjlXNHVGmcP9gC4vM=; b=dBRlmWsq2Cu+lU6GnE94ggrTkLkl2TRU6qFXgSnxb+mOVbBqzQuNm4p64CrLfFlGiY n0fYk/KUeVQOc4MsDwg9jEszj9TyObzhbDI9frB7/HzX7iWulTrEIka2a0rpMq2YCzj2 fdPiDMXAI6PIvzHvHv/hDB4sgCKf5RFGIK8AQF+w4q0n2kHS1E0c8heTTxtOpLiY8v6Y rEqrlaph8T8XVlYVuzNP1SBgFHdeocQiUDFObpsTyrVcZhWDPp1akIDeGJ0mUVcM4FHC FYtesBSv4kiykV3OhVp2PUR+HT6ozEJGbaZQrcUVwEICaQWgr+rH44ntWiIzNkx/Hj1H R9Ng== X-Gm-Message-State: APt69E3TbwK93avWJ73qffxVe0KewvgMCsZ98J6ShwwvEVE+SVQ4gqN5 sfhl48qEb97gXiJqFILRDTmZF/YF X-Google-Smtp-Source: ADUXVKIb2L0Txr8n1T39WW41ivHfduOxgBmrMKDo27zTeMVyerWGcdr4DSa/iqeYGDpgul+yvENk3g== X-Received: by 2002:a9d:3684:: with SMTP id h4-v6mr9805418otc.186.1529372669160; Mon, 18 Jun 2018 18:44: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 w14-v6sm7383666otj.31.2018.06.18.18.44.27 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:44:28 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:41:39 -0500 Message-Id: <20180619014319.28272-14-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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:c0f::242 Subject: [Qemu-devel] [PATCH 013/113] spapr: consolidate the VCPU id numbering logic in a single place 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 Several places in the code need to calculate a VCPU id: (cpu_index / smp_threads) * spapr->vsmt + cpu_index % smp_threads (core_id / smp_threads) * spapr->vsmt (1 user) index * spapr->vsmt (2 users) or guess that the VCPU id of a given VCPU is the first thread of a virtual core: index % spapr->vsmt != 0 Even if the numbering logic isn't that complex, it is rather fragile to have these assumptions open-coded in several places. FWIW this was proved with recent issues related to VSMT. This patch moves the VCPU id formula to a single function to be called everywhere the code needs to compute one. It also adds an helper to guess if a VCPU is the first thread of a VCORE. Signed-off-by: Greg Kurz [dwg: Rename spapr_is_vcore() to spapr_is_thread0_in_vcore() for clarity] Signed-off-by: David Gibson (cherry picked from commit 5d0fb1508e2d279da74ef4a103e8def9b52c6304) Signed-off-by: Greg Kurz --- hw/ppc/spapr.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 0be60fb044..a36494b87b 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -100,6 +100,21 @@ #define PHANDLE_XICP 0x00001111 +/* These two functions implement the VCPU id numbering: one to compute them + * all and one to identify thread 0 of a VCORE. Any change to the first one + * is likely to have an impact on the second one, so let's keep them close. + */ +static int spapr_vcpu_id(sPAPRMachineState *spapr, int cpu_index) +{ + return + (cpu_index / smp_threads) * spapr->vsmt + cpu_index % smp_threads; +} +static bool spapr_is_thread0_in_vcore(sPAPRMachineState *spapr, + PowerPCCPU *cpu) +{ + return spapr_get_vcpu_id(cpu) % spapr->vsmt == 0; +} + static ICSState *spapr_ics_create(sPAPRMachineState *spapr, const char *type_ics, int nr_irqs, Error **errp) @@ -346,7 +361,7 @@ static int spapr_fixup_cpu_dt(void *fdt, sPAPRMachineState *spapr) int index = spapr_get_vcpu_id(cpu); int compat_smt = MIN(smp_threads, ppc_compat_max_vthreads(cpu)); - if (index % spapr->vsmt != 0) { + if (!spapr_is_thread0_in_vcore(spapr, cpu)) { continue; } @@ -630,7 +645,7 @@ static void spapr_populate_cpus_dt_node(void *fdt, sPAPRMachineState *spapr) DeviceClass *dc = DEVICE_GET_CLASS(cs); int offset; - if (index % spapr->vsmt != 0) { + if (!spapr_is_thread0_in_vcore(spapr, cpu)) { continue; } @@ -2230,7 +2245,7 @@ static void spapr_init_cpus(sPAPRMachineState *spapr) if (mc->has_hotpluggable_cpus) { spapr_dr_connector_new(OBJECT(spapr), TYPE_SPAPR_DRC_CPU, - (core_id / smp_threads) * spapr->vsmt); + spapr_vcpu_id(spapr, core_id)); } if (i < boot_cores_nr) { @@ -3274,7 +3289,8 @@ void spapr_core_unplug_request(HotplugHandler *hotplug_dev, DeviceState *dev, return; } - drc = spapr_drc_by_id(TYPE_SPAPR_DRC_CPU, index * spapr->vsmt); + drc = spapr_drc_by_id(TYPE_SPAPR_DRC_CPU, + spapr_vcpu_id(spapr, cc->core_id)); g_assert(drc); spapr_drc_detach(drc); @@ -3303,7 +3319,8 @@ static void spapr_core_plug(HotplugHandler *hotplug_dev, DeviceState *dev, cc->core_id); return; } - drc = spapr_drc_by_id(TYPE_SPAPR_DRC_CPU, index * spapr->vsmt); + drc = spapr_drc_by_id(TYPE_SPAPR_DRC_CPU, + spapr_vcpu_id(spapr, cc->core_id)); g_assert(drc || !mc->has_hotpluggable_cpus); @@ -3652,8 +3669,7 @@ void spapr_set_vcpu_id(PowerPCCPU *cpu, int cpu_index, Error **errp) sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine()); int vcpu_id; - vcpu_id = - (cpu_index / smp_threads) * spapr->vsmt + cpu_index % smp_threads; + vcpu_id = spapr_vcpu_id(spapr, cpu_index); if (kvm_enabled() && !kvm_vcpu_id_is_valid(vcpu_id)) { error_setg(errp, "Can't create CPU with id %d in KVM", vcpu_id); From patchwork Tue Jun 19 01:41:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 931262 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="Zx9UIs0S"; 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 418rvp1wtxz9s19 for ; Tue, 19 Jun 2018 12:07:50 +1000 (AEST) Received: from localhost ([::1]:38499 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV63f-00016c-PV for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:07:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45042) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5hB-0000iS-Hq for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5hA-0007xg-J8 for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:33 -0400 Received: from mail-oi0-x241.google.com ([2607:f8b0:4003:c06::241]:39684) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5hA-0007x3-Dt; Mon, 18 Jun 2018 21:44:32 -0400 Received: by mail-oi0-x241.google.com with SMTP id t22-v6so16699647oih.6; Mon, 18 Jun 2018 18:44: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 :mime-version:content-transfer-encoding; bh=XBIIn2zPumrey8jrcEZBqbza6n+jON531yb8z6m6xwk=; b=Zx9UIs0S2CmTKN5q6il6+CueIFlIZCJN6N1srZ0uBgjgIGrJ9Bs1nsB+8/0IAgqu9C lTbVKcLJJ/FliDyiQhwbGaAg/YziqeWl2Tiywe365ldvDe6Rh7eBD0dVdXWXEwIb3QUB 3KChPd8AgMMnDgNVc8OEFEzhTgAVws8ybdgPP4XcvlH96j47hlyp94GQqjSkrpR/ClBV xuGXEhYNpPizFeyTjIHiGYVDKVIUi4oqboeWaduNVoG3zsIN2ZVOyeuhLnt6vI9ItF2U afHJxAWg/1bwmIf9HOQXuLf6bMQNfwxWItWRW6SSOfA79sUTl0/8tJ0P+ZvmEAqIUtWB BWIA== 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=XBIIn2zPumrey8jrcEZBqbza6n+jON531yb8z6m6xwk=; b=muudwXP46Lf9+xAyW2cWGSGgmdZlEQIMXCBITjzDplEPyxTW9hVCUdLTVY8CXeZDfy gINC7KRhWlLU4icXNV/nGwZ2lGEZPo3uBC2QBBVpkCCbKajZFOAfBK3x/KW12HFqo+3M aJEB2CHZlYQESlIpVMnDWk6vrJXK1G2rmmu2EYyMZ2J5DY7I4uuYp5xRynypH289xWr8 a9nQ5+mik4GRuzB1uRQoIVFfj7q43udiDKzpHNMBc2lQWEAdWMxGfFk5NqqARbGS1ULv AVyrNLePX/iCUbUYqyOBj1PH2AqTwnP0rqNxolQJArJh3eGzeLMRUhTtv1d5uRONEHX4 MWGw== X-Gm-Message-State: APt69E3MG7aW4rEGvOhwUfI8spA+amSKRKWOzRPMmbVyJT4cCBqRtx4c HjTbK/+DBfowjEBRhEfO/KJYTyIC X-Google-Smtp-Source: ADUXVKISn1fhOr11ZuZQGHYW/FhsUwkiHRNHiitrAH1mXvrxQwn0JOn5YyCSAURHBr6Sd58Ym3LfkA== X-Received: by 2002:aca:3382:: with SMTP id z124-v6mr8788701oiz.49.1529372671268; Mon, 18 Jun 2018 18:44: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 d38-v6sm11477836otc.44.2018.06.18.18.44.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:44:30 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:41:40 -0500 Message-Id: <20180619014319.28272-15-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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 014/113] spapr: fix missing CPU core nodes in DT when running with TCG 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 Commit 5d0fb1508e2d "spapr: consolidate the VCPU id numbering logic in a single place" introduced a helper to detect thread0 of a virtual core based on its VCPU id. This is used to create CPU core nodes in the DT, but it is broken in TCG. $ qemu-system-ppc64 -nographic -accel tcg -machine dumpdtb=dtb.bin \ -smp cores=16,maxcpus=16,threads=1 $ dtc -f -O dts dtb.bin | grep POWER8 PowerPC,POWER8@0 { PowerPC,POWER8@8 { instead of the expected 16 cores that we get with KVM: $ dtc -f -O dts dtb.bin | grep POWER8 PowerPC,POWER8@0 { PowerPC,POWER8@8 { PowerPC,POWER8@10 { PowerPC,POWER8@18 { PowerPC,POWER8@20 { PowerPC,POWER8@28 { PowerPC,POWER8@30 { PowerPC,POWER8@38 { PowerPC,POWER8@40 { PowerPC,POWER8@48 { PowerPC,POWER8@50 { PowerPC,POWER8@58 { PowerPC,POWER8@60 { PowerPC,POWER8@68 { PowerPC,POWER8@70 { PowerPC,POWER8@78 { This happens because spapr_get_vcpu_id() maps VCPU ids to cs->cpu_index in TCG mode. This confuses the code in spapr_is_thread0_in_vcore(), since it assumes thread0 VCPU ids to have a spapr->vsmt spacing. spapr_get_vcpu_id(cpu) % spapr->vsmt == 0 Actually, there's no real reason to expose cs->cpu_index instead of the VCPU id, since we also generate it with TCG. Also we already set it explicitly in spapr_set_vcpu_id(), so there's no real reason either to call kvm_arch_vcpu_id() with KVM. This patch unifies spapr_get_vcpu_id() to always return the computed VCPU id both in TCG and KVM. This is one step forward towards KVM<->TCG migration. Fixes: 5d0fb1508e2d Reported-by: Cédric Le Goater Signed-off-by: Greg Kurz Signed-off-by: David Gibson (cherry picked from commit b1a568c1c2192f090536b8ac76d135ce1f46a0ee) Signed-off-by: Greg Kurz --- hw/ppc/spapr.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index a36494b87b..d53123c127 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3655,13 +3655,7 @@ static void spapr_pic_print_info(InterruptStatsProvider *obj, int spapr_get_vcpu_id(PowerPCCPU *cpu) { - CPUState *cs = CPU(cpu); - - if (kvm_enabled()) { - return kvm_arch_vcpu_id(cs); - } else { - return cs->cpu_index; - } + return cpu->vcpu_id; } void spapr_set_vcpu_id(PowerPCCPU *cpu, int cpu_index, Error **errp) From patchwork Tue Jun 19 01:41: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: 931256 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="UIqPXgw6"; 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 418rl44JY9z9s2t for ; Tue, 19 Jun 2018 12:00:16 +1000 (AEST) Received: from localhost ([::1]:38444 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5wL-0003wp-R9 for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:00:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45077) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5hE-0000kK-1t for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5hD-0007yU-0R for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:36 -0400 Received: from mail-ot0-x232.google.com ([2607:f8b0:4003:c0f::232]:36649) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5hC-0007yB-RI; Mon, 18 Jun 2018 21:44:34 -0400 Received: by mail-ot0-x232.google.com with SMTP id c15-v6so20775961otl.3; Mon, 18 Jun 2018 18:44: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=VezRNQfXglW/W0BokEbZqT2nWAl5NAFctJeiToebtKA=; b=UIqPXgw6DxfSiL4w/z6hcqyQLeVG6Nms1dJFsLKYxJKz05PuoL76PLPoj03FHWhLQ6 RBK/N+ZxcRQtxTSfLgFco7/ZbV2IXQVCTdq+1BEeJgYeByBktudLhcOx4dx2peXKa81+ 6gq/5b9Lq0iuvvR2Y3gRUZIkDNDpbuhIHsaH4e284XByHepJmBUSPpURP7VwOSbVMAUk rSu+xjwLI639GfmeWCiKjG6tww0k0ZMB89iPhyGF9aiaoevoiYk5mrWe5fr2pqcNy7VB Pa45KlnWF5Q+uPQjzEC2Z7Jh47XZce8/QvQUGrISGNnD77Vi4hmsiWeugjYG3eP6BX49 gqKQ== 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=VezRNQfXglW/W0BokEbZqT2nWAl5NAFctJeiToebtKA=; b=SIrqpZnrE84V2Tf57JO9nVHYoiwmeP3wgq9qlswYvHpMTzpHPZp0XccFTg3EoiYcpH 2M049FzaRvVJlg0L1COtJ0KvcXeW9Ix67mpQ1VOfO0528dqmujTe6FO+jkAUgkC8Nluj vp3FIgTpe1W9tWaHIlD2ukPOsJIKNANZiijd4Vzb0EEH13lY1kQDj2Nwqi9wDzW+5cso fPv9qWsMIG8JU6v/EAX00eF22T00xxjkreP0//K2qfPk9H7yDn1kbRwHXideCg59U7Zh Ubuq44vXhMnx8RiobOI6gSeFq8nQrJtOzRE5cexiiFpzWrIxEDJaQVgd+sahOqO9fZk3 cXXw== X-Gm-Message-State: APt69E3W6axp545Gxwg2xDNrHq7s38OEt3IK65PSA88iOoZoaJebhShF 5r76h/kwgMynhJU27mRn1iza1JUd X-Google-Smtp-Source: ADUXVKIjg3VAvg0/na96kZ/j1eMBd/R3dXiY5WIRcn1AGwkLFvoR7yYkLSqKA50qzP1HTHJ5ZSOO2Q== X-Received: by 2002:a9d:70d6:: with SMTP id w22-v6mr9686724otj.375.1529372673630; Mon, 18 Jun 2018 18:44:33 -0700 (PDT) Received: from localhost ([2600:1700:70:e488:b0ee:9bda:ee6f:91be]) by smtp.gmail.com with ESMTPSA id c2-v6sm7230601oia.53.2018.06.18.18.44.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:44:32 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:41:41 -0500 Message-Id: <20180619014319.28272-16-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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:c0f::232 Subject: [Qemu-devel] [PATCH 015/113] spapr: register dummy ICPs later 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 Some older machine types create more ICPs than needed. We hence need to register up to xics_max_server_number() dummy ICPs to accomodate the migration of these machine types. Recent VSMT rework changed xics_max_server_number() to return DIV_ROUND_UP(max_cpus * spapr->vsmt, smp_threads) instead of DIV_ROUND_UP(max_cpus * kvmppc_smt_threads(), smp_threads); The change is okay but it requires spapr->vsmt to be set, which isn't the case with the current code. This causes the formula to return zero and we don't create dummy ICPs. This breaks migration of older guests as reported here: https://bugzilla.redhat.com/show_bug.cgi?id=1549087 The dummy ICP workaround doesn't really have a dependency on XICS itself. But it does depend on proper VCPU id numbering and it must be applied before creating vCPUs (ie, creating real ICPs). So this patch moves the workaround to spapr_init_cpus(), which already assumes VSMT to be set. Fixes: 72194664c8a1 ("spapr: use spapr->vsmt to compute VCPU ids") Reported-by: Lukas Doktor Signed-off-by: Greg Kurz Signed-off-by: David Gibson (cherry picked from commit 72fdd4de8e5fdc1a6078e000835fb54592a3fe97) Signed-off-by: Greg Kurz --- hw/ppc/spapr.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index d53123c127..1a2dd1f597 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -184,7 +184,6 @@ static int xics_max_server_number(sPAPRMachineState *spapr) static void xics_system_init(MachineState *machine, int nr_irqs, Error **errp) { sPAPRMachineState *spapr = SPAPR_MACHINE(machine); - sPAPRMachineClass *smc = SPAPR_MACHINE_GET_CLASS(machine); if (kvm_enabled()) { if (machine_kernel_irqchip_allowed(machine) && @@ -206,17 +205,6 @@ static void xics_system_init(MachineState *machine, int nr_irqs, Error **errp) return; } } - - if (smc->pre_2_10_has_unused_icps) { - int i; - - for (i = 0; i < xics_max_server_number(spapr); i++) { - /* Dummy entries get deregistered when real ICPState objects - * are registered during CPU core hotplug. - */ - pre_2_10_vmstate_register_dummy_icp(i); - } - } } static int spapr_fixup_cpu_smt_dt(void *fdt, int offset, PowerPCCPU *cpu, @@ -2210,6 +2198,7 @@ static void spapr_init_cpus(sPAPRMachineState *spapr) { MachineState *machine = MACHINE(spapr); MachineClass *mc = MACHINE_GET_CLASS(machine); + sPAPRMachineClass *smc = SPAPR_MACHINE_GET_CLASS(machine); const char *type = spapr_get_cpu_core_type(machine->cpu_type); const CPUArchIdList *possible_cpus; int boot_cores_nr = smp_cpus / smp_threads; @@ -2240,6 +2229,17 @@ static void spapr_init_cpus(sPAPRMachineState *spapr) boot_cores_nr = possible_cpus->len; } + if (smc->pre_2_10_has_unused_icps) { + int i; + + for (i = 0; i < xics_max_server_number(spapr); i++) { + /* Dummy entries get deregistered when real ICPState objects + * are registered during CPU core hotplug. + */ + pre_2_10_vmstate_register_dummy_icp(i); + } + } + for (i = 0; i < possible_cpus->len; i++) { int core_id = i * smp_threads; From patchwork Tue Jun 19 01:41: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: 931266 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="SR5YZjAO"; 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 418rzQ2TzWz9s19 for ; Tue, 19 Jun 2018 12:10:58 +1000 (AEST) Received: from localhost ([::1]:38516 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV66h-0003ZC-Tr for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:10:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45108) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5hG-0000ni-UM for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5hF-0007zO-SS for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:38 -0400 Received: from mail-ot0-x241.google.com ([2607:f8b0:4003:c0f::241]:40769) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5hF-0007zB-Mu; Mon, 18 Jun 2018 21:44:37 -0400 Received: by mail-ot0-x241.google.com with SMTP id w9-v6so20744005otj.7; Mon, 18 Jun 2018 18:44: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=NQnr2tEHe1VXNjKBP7tf2rh8M6O8qDYmQa+JeJJs/sk=; b=SR5YZjAOjr7WCuS9LErdCY6QDAA452jSmxsDFhFqmsvb//PDEPg9wRnX6bQhRi0giQ 5ravscJTb8PS1v/uu7pISHGZoCJguseH1RyjF/XMsX3Qn9Ef0ss2lsg9MiyfqXRJbUs2 J3Qa00CPWreSioMVitlTZe4djA1l6UxRYCps2EpvhLy6nG1dvQ/wJ6khBC1xa0DgOIhr mcM0/l597QsHGK1a68kLGoCzQ6FPQz3TdZz6I6qCSzK8JzTljR0A7j466j5gBFu0349b NV+ugeaTPR084MR4Qp8L1eDA/dY/sijI2f8OHaiQz7cqES8S0lCQzD+uOqimwYTXEHxE RhSw== 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=NQnr2tEHe1VXNjKBP7tf2rh8M6O8qDYmQa+JeJJs/sk=; b=tkMmUBbw3tlcy/MwkA15zoYs0pWdA7HfHAwQbgoOcXfMDPzaxeBkCwCggntshiei8b wDzmS15IjSNlZjk5PLVxKAPSgsU+Io7T1H/Y17vws9Xa1+oH/N+ElxKz0vWAxKqVSI34 1YO9Wir6J9+kFTKI+nCWj67Rq2es72ak9jC92pO+7X0YD0ZucoQTyjXGKgP+7EWvWD0L g0CepbY0R6PUzfNsKpSFRUZG4VwmByqnvMrSQKbvNeMi1ERMxzis8bIwO0JL5uwks5qT ND/vg7xTsIQV1iPW+DUXc/ydT/eRnwIwzX+NpAr/jDvZZDulrDHiax0L/YPIlyn9Ztv9 gXJA== X-Gm-Message-State: APt69E1majvu3pYtbse0dSPAKg/8b0Ae7cjUbUSslkGy2NPMNKlTFUon egkJ/upy2Tl/+yqLjy8Wo2htWR/D X-Google-Smtp-Source: ADUXVKISVIE3RnpvRTey5ygKW8504Gv4azxKcOivsi5pvvyLQF+dvs7FVdWvPWgtockNzhetG6cY5w== X-Received: by 2002:a9d:4696:: with SMTP id z22-v6mr9702804ote.57.1529372676526; Mon, 18 Jun 2018 18:44:36 -0700 (PDT) Received: from localhost ([2600:1700:70:e488:b0ee:9bda:ee6f:91be]) by smtp.gmail.com with ESMTPSA id q23-v6sm10131771otd.25.2018.06.18.18.44.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:44:34 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:41:42 -0500 Message-Id: <20180619014319.28272-17-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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:c0f::241 Subject: [Qemu-devel] [PATCH 016/113] spapr: make pseries-2.11 the default machine type X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-stable@nongnu.org, Greg Kurz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Greg Kurz The spapr capability framework was introduced in QEMU 2.12. It allows to have an explicit control on how host features are exposed to the guest. This is especially needed to handle migration between hetero- geneous hosts (eg, POWER8 to POWER9). It is also used to expose fixes/ workarounds against speculative execution vulnerabilities to guests. The framework was hence backported to QEMU 2.11.1, especially these commits: 0fac4aa93074 spapr: Add pseries-2.12 machine type 9070f408f491 spapr: Treat Hardware Transactional Memory (HTM) as an optional capability 0fac4aa93074 has the confusing effect of making pseries-2.12 the default machine type for QEMU 2.11.1, instead of the expected pseries-2.11. This patch changes the default machine back to pseries-2.11. Unfortunately, 9070f408f491 enforces the HTM capability for pseries-2.11. This isn't supported by TCG and breaks 'make check'. So this patch also adds a hack to turn HTM off when using TCG. Signed-off-by: Greg Kurz --- hw/ppc/spapr.c | 4 ++-- hw/ppc/spapr_caps.c | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 1a2dd1f597..6499a86752 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3820,7 +3820,7 @@ static void spapr_machine_2_12_class_options(MachineClass *mc) /* Defaults for the latest behaviour inherited from the base class */ } -DEFINE_SPAPR_MACHINE(2_12, "2.12", true); +DEFINE_SPAPR_MACHINE(2_12, "2.12", false); /* * pseries-2.11 @@ -3842,7 +3842,7 @@ static void spapr_machine_2_11_class_options(MachineClass *mc) SET_MACHINE_COMPAT(mc, SPAPR_COMPAT_2_11); } -DEFINE_SPAPR_MACHINE(2_11, "2.11", false); +DEFINE_SPAPR_MACHINE(2_11, "2.11", true); /* * pseries-2.10 diff --git a/hw/ppc/spapr_caps.c b/hw/ppc/spapr_caps.c index 7b229517be..82043e60e7 100644 --- a/hw/ppc/spapr_caps.c +++ b/hw/ppc/spapr_caps.c @@ -285,6 +285,11 @@ static sPAPRCapabilities default_caps_with_cpu(sPAPRMachineState *spapr, caps = smc->default_caps; + /* HACK for 2.11.2: fix make check */ + if (tcg_enabled()) { + caps.caps[SPAPR_CAP_HTM] = SPAPR_CAP_OFF; + } + if (!ppc_check_compat(cpu, CPU_POWERPC_LOGICAL_2_07, 0, spapr->max_compat_pvr)) { caps.caps[SPAPR_CAP_HTM] = SPAPR_CAP_OFF; From patchwork Tue Jun 19 01:41: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: 931269 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="dmm9+i7E"; 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 418s3m3vBNz9s37 for ; Tue, 19 Jun 2018 12:14:44 +1000 (AEST) Received: from localhost ([::1]:38540 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6AM-0006Yn-4d for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:14:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45138) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5hI-0000py-Sz for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5hH-00080F-RF for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:40 -0400 Received: from mail-ot0-x236.google.com ([2607:f8b0:4003:c0f::236]:36653) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5hH-000802-NM; Mon, 18 Jun 2018 21:44:39 -0400 Received: by mail-ot0-x236.google.com with SMTP id c15-v6so20776119otl.3; Mon, 18 Jun 2018 18:44: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=5YqEmkB+l2PXxl690+87L+4eeF4z8lD2PjH9NlED+vE=; b=dmm9+i7EaUdFdiQx/cEwFWa9zCNLRIycd1ybpDOM5ra0FYcKWZJs6kktIbrclRSGbM jiokEt8l0BdxA5NsRlRw6bXfZQgitAW6sJDcqUcyWaSk8M85IBZ1Lbo7TFbiT7MoVtBA /t6g+WUUidfTgjIhx/rlAvGHskDFyg6WXpi2FS/y6eMGWT5sYIpgeal6iW1hgLL0QzbJ j5dCLRSDKa5n9FgctszpH186mKpRh/bvB0uZctu7Mdtc+RxeMozw/claGI7CS7HIPd+e THckYvDniJlgzXfLppGEj6nzrm0numkpCncou2Ytfc+RDC2lWfzcSeXMR0vwzS2itswj de4w== 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=5YqEmkB+l2PXxl690+87L+4eeF4z8lD2PjH9NlED+vE=; b=Csv6PEGP+/f//EBbcO51szKuGOVlgXZCEtVKIYH0MJavH8ycot8eLTXxTJkYimLP71 osQflv4Huhrde7IdCBOtTbFCsI7zweC9RpWkzD02kWqfzYzdZRY6cReeE3dEf/AIFY4E JNozQhIfSdermOnP//tzkr+CvvDnRSGEZwQKkjvOOQJi3FAbkNjdG3BdzoFeUXEn5poj RSQjUw3+0IfADVBGKzqr8P6Nt/ruIy6C+WLqFd0F3TmL0Hq7mQAp5g5sDWwWCR3FLfna h3QOc65d5ZcwKK23wl3vP0LFmMI138AZHSJcpsDV93Iuzmr2Kw3bO/uJKb9LapsuLgs3 JY/Q== X-Gm-Message-State: APt69E04a7Tg1VYBWjRGBsvXwPLFdGQYydqPKVBGhpqG1B9ABXngX2+p IrDVs+g0z5qZrlvEazPYgl5FOykc X-Google-Smtp-Source: ADUXVKIfTI7lS/YAz/EApinOuRYqf4K6bed5qu4ITtSBh5btZP26vW26AMxqF16Anw3FVc2bDyzVDg== X-Received: by 2002:a9d:1df4:: with SMTP id w49-v6mr9719677otw.8.1529372678547; Mon, 18 Jun 2018 18:44:38 -0700 (PDT) Received: from localhost ([2600:1700:70:e488:b0ee:9bda:ee6f:91be]) by smtp.gmail.com with ESMTPSA id k141-v6sm12951496oih.42.2018.06.18.18.44.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:44:37 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:41:43 -0500 Message-Id: <20180619014319.28272-18-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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:c0f::236 Subject: [Qemu-devel] [PATCH 017/113] nbd: Honor server's advertised minimum 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 Commit 79ba8c98 (v2.7) changed the setting of request_alignment to occur only during bdrv_refresh_limits(), rather than at at bdrv_open() time; but at the time, NBD was unaffected, because it still used sector-based callbacks, so the block layer defaulted NBD to use 512 request_alignment. Later, commit 70c4fb26 (also v2.7) changed NBD to use byte-based callbacks, without setting request_alignment. This resulted in NBD using request_alignment of 1, which works great when the server supports it (as is the case for qemu-nbd), but falls apart miserably if the server requires alignment (but only if qemu actually sends a sub-sector request; qemu-io can do it, but most qemu operations still perform on sectors or larger). Even later, the NBD protocol was updated to document that clients should learn the server's minimum alignment during NBD_OPT_GO; and recommended that clients should assume a minimum size of 512 unless the server understands NBD_OPT_GO and replied with a smaller size. Commit 081dd1fe (v2.10) attempted to do that, by assigning request_alignment to whatever was learned from the server; but it has two flaws: the assignment is done during bdrv_open() so it gets unconditionally wiped out back to 1 during any later bdrv_refresh_limits(); and the code is not using a default of 512 when the server did not report a minimum size. Fix these issues by moving the assignment to request_alignment to the right function, and by using a sane default when the server does not advertise a minimum size. CC: qemu-stable@nongnu.org Signed-off-by: Eric Blake Message-Id: <20180215032905.27146-1-eblake@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy (cherry picked from commit fd8d372dd36e839568a718684914d9960d8b1ebd) Signed-off-by: Michael Roth --- block/nbd-client.c | 3 --- block/nbd.c | 2 ++ 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/block/nbd-client.c b/block/nbd-client.c index 9206652e45..7b68499b76 100644 --- a/block/nbd-client.c +++ b/block/nbd-client.c @@ -846,9 +846,6 @@ int nbd_client_init(BlockDriverState *bs, if (client->info.flags & NBD_FLAG_SEND_WRITE_ZEROES) { bs->supported_zero_flags |= BDRV_REQ_MAY_UNMAP; } - if (client->info.min_block > bs->bl.request_alignment) { - bs->bl.request_alignment = client->info.min_block; - } qemu_co_mutex_init(&client->send_mutex); qemu_co_queue_init(&client->free_sema); diff --git a/block/nbd.c b/block/nbd.c index 8b8ba56cdd..c32ea9fd73 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -474,8 +474,10 @@ static int nbd_co_flush(BlockDriverState *bs) static void nbd_refresh_limits(BlockDriverState *bs, Error **errp) { NBDClientSession *s = nbd_get_client_session(bs); + uint32_t min = s->info.min_block; uint32_t max = MIN_NON_ZERO(NBD_MAX_BUFFER_SIZE, s->info.max_block); + bs->bl.request_alignment = min ? min : BDRV_SECTOR_SIZE; bs->bl.max_pdiscard = max; bs->bl.max_pwrite_zeroes = max; bs->bl.max_transfer = max; From patchwork Tue Jun 19 01:41: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: 931273 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="H4h44Y0E"; 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 418s7Q4XCPz9s3C for ; Tue, 19 Jun 2018 12:17:54 +1000 (AEST) Received: from localhost ([::1]:38558 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6DQ-0000dU-6k for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:17:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45160) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5hL-0000rz-0W for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5hJ-00081s-VJ for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:43 -0400 Received: from mail-oi0-x243.google.com ([2607:f8b0:4003:c06::243]:43741) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5hJ-00080n-Q3; Mon, 18 Jun 2018 21:44:41 -0400 Received: by mail-oi0-x243.google.com with SMTP id t133-v6so16694477oif.10; Mon, 18 Jun 2018 18:44: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=moPj3wj24eIc6ejZOSJOqyGu/mGmW+arqcOvgKc3ydI=; b=H4h44Y0EmfYcxrlI1woyUsmtgGZM5LMEOFqlKv6fLj0U0wG7JPxNPYxCIShmbxE8hD +WE1McZE+X0+6D7oCRNpEY35eoDhyjzVIkHboigzx2TY2+thCYMo2QLJ/r22nbqWkOG8 cFebG/fGk+Pl88AhnMOWG6Dzvo2FFBEzaZMnnw6B4qSXc8GWc46aBT9haGrpbCCWy2Oq BHM2dHOGzhiCkMpPF82CFqkNATt24BsZntb3x2fc4FRRuXT9e7iqlvCZyaaNS2UCkiq3 +uJLWtOhCSw3jMunS+ojiqFvDDFru4NZPwVMzFMy2H+Rzj9J0Kd4SmB3+NtkTinYgABz DgAg== 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=moPj3wj24eIc6ejZOSJOqyGu/mGmW+arqcOvgKc3ydI=; b=PALTyOrf4f9O2hp7h2ye+hBgfIaW4hSUsF9/WWKptyOriPfALsBRDa0KLZ2vaM53f/ /kY9i7yEXSnQOzEamJjbT+oHPz0rkUkFT7ftBECJq2qsSsEGVqhmORXC5DVw0/W4p/gr wic2Rjz/ZgiPQ4hcVgNA/qRlGbSZE0rexap02z+TlP2xwb7qrSBYwSTXMM57PQvUrszj buHUFj02iTMElfvv9r7FcrN+r9X0pIL6QXPmDpc0TObGmTT5shuWeI3TGvwsb8ZwXvN8 yZ8HjjIaYDuBNSmC3IcNU4roi/gN5SIjBuxYGMWdi5bG5A9phL+Qeztmyaf/VuZNI2r2 2h4w== X-Gm-Message-State: APt69E1CkHb1tI4VvQGW+CGkS3I16H3DMxZ65fB3/Hzq2bvH1xLZz7ro xsLT8wwuTtr0F8WYR723Nhy4+1Tm X-Google-Smtp-Source: ADUXVKISL/B92goOs8m+86Rj+PlT4s/KZz+YpqvAgcg+WbkURoRuVE0BdPGRmRvygMxpkMBCwEXNwQ== X-Received: by 2002:aca:f484:: with SMTP id s126-v6mr8628884oih.269.1529372680566; Mon, 18 Jun 2018 18:44:40 -0700 (PDT) Received: from localhost ([2600:1700:70:e488:b0ee:9bda:ee6f:91be]) by smtp.gmail.com with ESMTPSA id t15-v6sm8686180ott.6.2018.06.18.18.44.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:44:39 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:41:44 -0500 Message-Id: <20180619014319.28272-19-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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 018/113] specs/qcow2: Fix documentation of the compressed cluster descriptor 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 , Alberto Garcia , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Alberto Garcia This patch fixes several mistakes in the documentation of the compressed cluster descriptor: 1) the documentation claims that the cluster descriptor contains the number of sectors used to store the compressed data, but what it actually contains is the number of sectors *minus one* or, in other words, the number of additional sectors after the first one. 2) the width of the fields is incorrectly specified. The number of bits used by each field is x = 62 - (cluster_bits - 8) for the offset field y = (cluster_bits - 8) for the size field So the offset field's location is [0, x-1], not [0, x] as stated. 3) the size field does not contain the size of the compressed data, but rather the number of sectors where that data is stored. The compressed data starts at the exact point specified in the offset field and ends when there's enough data to produce a cluster of decompressed data. Both points can be in the middle of a sector, allowing several compressed clusters to be stored next to one another, sharing sectors if necessary. Cc: qemu-stable@nongnu.org Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf (cherry picked from commit 156b46ded3853dfc6b34c5afae019ff61798491b) Signed-off-by: Michael Roth --- docs/interop/qcow2.txt | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/docs/interop/qcow2.txt b/docs/interop/qcow2.txt index d7fdb1fee3..feb711fb6a 100644 --- a/docs/interop/qcow2.txt +++ b/docs/interop/qcow2.txt @@ -426,10 +426,20 @@ Standard Cluster Descriptor: Compressed Clusters Descriptor (x = 62 - (cluster_bits - 8)): - Bit 0 - x: Host cluster offset. This is usually _not_ aligned to a - cluster boundary! + Bit 0 - x-1: Host cluster offset. This is usually _not_ aligned to a + cluster or sector boundary! - x+1 - 61: Compressed size of the images in sectors of 512 bytes + x - 61: Number of additional 512-byte sectors used for the + compressed data, beyond the sector containing the offset + in the previous field. Some of these sectors may reside + in the next contiguous host cluster. + + Note that the compressed data does not necessarily occupy + all of the bytes in the final sector; rather, decompression + stops when it has produced a cluster of data. + + Another compressed cluster may map to the tail of the final + sector used by this compressed cluster. If a cluster is unallocated, read requests shall read the data from the backing file (except if bit 0 in the Standard Cluster Descriptor is set). If there is From patchwork Tue Jun 19 01:41: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: 931253 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="An633lVM"; 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 418rhc3D8Rz9s2t for ; Tue, 19 Jun 2018 11:58:08 +1000 (AEST) Received: from localhost ([::1]:38430 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5uI-00029R-35 for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 21:58:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45212) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5hQ-00010S-SQ for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5hM-00082y-0b for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:48 -0400 Received: from mail-oi0-x22f.google.com ([2607:f8b0:4003:c06::22f]:35622) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5hL-00082n-RR; Mon, 18 Jun 2018 21:44:43 -0400 Received: by mail-oi0-x22f.google.com with SMTP id e8-v6so16712101oii.2; Mon, 18 Jun 2018 18:44: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=24r6pz3b2UB9j7jdv4JlcbZq1czr6mU3n1Z/FUITnnA=; b=An633lVM1slnvzWd79udni8IjzkqUY/wDXHSQeM1fZRQXQ4w1TuGNduqNg7ieGTVFb u7kSY8gg/FrvtGA4zZa4kE6g74VJeWbnKnEL9kct86LZujBnnJXofk1acAyqvswgqufS ZoP4sHUYwKvDBGG94xqM4A6WFm5HvS7aoA/eaiBWTBXZkxfSZ6uEYtB/rzyHsCXORUbJ qMMqzeF5+odhqYyePje3v2lGkQjvWTlopccMGPAggm8vK2ZVe51bAvBJpmvTsSSjERIV U2M4UMcC2YCha4MW01HhdYvjKD5VGvV6zhj5EGwbRZ6SuHZhiQ8sq4BOs3f3d3TXNZSN OlPg== 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=24r6pz3b2UB9j7jdv4JlcbZq1czr6mU3n1Z/FUITnnA=; b=gTH8hAFwwQZ7+sEBNezt09cjZuDkH3r759jmntXEZ3qAAV4w/PgQo4KM1ydB+U/G6r SARB6Y3yR2JHShFCIRU3AsZ/FTbjlMZ/1LCCfZNX9Ykpy9cwTDT1xnw9bFpschA6jVWG GZNLjoJHYaV6UEdff4alGnvlvORpo2cX9RvQ7nCk5aajjRpkhEV9QuVIWBdJ3RGbGT6m CnC8h3LSIMLLCzB0wJqC8xCBb+W5N4mOZgjCnDXj0nCDLkGnc4iJOsvM9+2Tlw1kPnmC rM08nEOnCAYCfk1Z9jXNVBzvuujm3UTcgMwG0PBhHQHRYXZxZ0Cg/UwPt9iXRlh5nXZP QQtA== X-Gm-Message-State: APt69E1shD5i+JX0/jGCQ8J3NDWTU/tp2h3U3MnRB+VRfbF3vNcQLLLi ctRYsQ+TPR/NLsUbbsoJqeRRH9eI X-Google-Smtp-Source: ADUXVKKQrnm40GQgC1BG1iLS0g9R2laYQmGuafgHrq3scccx6x5tg4aEl2W3Md285RyyVDQvCCjpig== X-Received: by 2002:aca:907:: with SMTP id 7-v6mr8719695oij.300.1529372682668; Mon, 18 Jun 2018 18:44: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 5-v6sm7128300oid.50.2018.06.18.18.44.41 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:44:41 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:41:45 -0500 Message-Id: <20180619014319.28272-20-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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 019/113] rbd: Fix use after free in qemu_rbd_set_keypairs() error path 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: Kevin Wolf If we want to include the invalid option name in the error message, we can't free the string earlier than that. Cc: qemu-stable@nongnu.org Signed-off-by: Kevin Wolf Reviewed-by: Max Reitz Reviewed-by: Eric Blake (cherry picked from commit 71c87815f9e0386b6f3e22942adc956fd603c82f) Signed-off-by: Michael Roth --- block/rbd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/block/rbd.c b/block/rbd.c index a76a5e8755..2de434dfdd 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -265,13 +265,14 @@ static int qemu_rbd_set_keypairs(rados_t cluster, const char *keypairs_json, key = qstring_get_str(name); ret = rados_conf_set(cluster, key, qstring_get_str(value)); - QDECREF(name); QDECREF(value); if (ret < 0) { error_setg_errno(errp, -ret, "invalid conf option %s", key); + QDECREF(name); ret = -EINVAL; break; } + QDECREF(name); } QDECREF(keypairs); From patchwork Tue Jun 19 01:41:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 931277 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="Hwdaj1e8"; 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 418sC472Q9z9s37 for ; Tue, 19 Jun 2018 12:21:04 +1000 (AEST) Received: from localhost ([::1]:38576 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6GU-00038B-JM for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:21:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45213) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5hQ-00010T-T2 for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5hN-00083Y-QT for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:48 -0400 Received: from mail-oi0-x236.google.com ([2607:f8b0:4003:c06::236]:41482) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5hN-00083I-LL; Mon, 18 Jun 2018 21:44:45 -0400 Received: by mail-oi0-x236.google.com with SMTP id a141-v6so16692611oii.8; Mon, 18 Jun 2018 18:44: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 :mime-version:content-transfer-encoding; bh=CHM5MiieMPSGRZw1pWLqUbNK3KsCZvWYKRaYx7xVE0o=; b=Hwdaj1e8BnrMapNNhZSKJ4XgdBS0+Lmivx3Y3DMHf1YgxqIoY8h5k58R60KQw/+3n2 p6tDta0Jzzq/feK7CsOIw258gycS+H40ZUn3jJegP0CPyCZv0Jq7OakU3QVICcjAPIo6 sNH+MWQlgnZup+A/mggl+lWphpseTEPT8bwXFLZoFFeZ7BB/B9j+MUPyaob9US4HSOh1 rutfLHM5XgSuhGO4AR9+qZnBQA9QYY0F5OURE4OgJc8VE6H2t4ZbqJrZzP8bRUEDdMwP SvtRqH6DbReX4iz576n6i03yQ8IoSHBwy+5pYQ5KRXpYIdovy+tytbjUzVA7Aj/yPQ/r YR0g== 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=CHM5MiieMPSGRZw1pWLqUbNK3KsCZvWYKRaYx7xVE0o=; b=QWTJ+fXgUUWlEU2osBwpCVh/cgdmySE82Vh1hK0dN74bgeaBPiaZKD/ob8WrAh73P2 hfLLTbRh9JeI4wWboIOeyhDVq4lgzQ49oSqTH5lC87v2WgwNW8R/EpwHGA1RLVUKdnDs lTGWyFKcGmCSeUjYo+/bTfeTXB72VwbMwEXTLSbeHcEl5/7uLC9NQ9lGnFh2FfLcB54g aF78z1QvBPghB5cHJ62hRWvOt+Hgte5LD2o8MFqQenKQ9LJaz3D/VoX5t0d7kFumI5eg 4S6KVIkvQsgKxMfjVXUCUNnJnuQVRDc+1dUcwfMgnaTQrPrc9Nqd/EoSfr1Z1e8faOQ3 o5QQ== X-Gm-Message-State: APt69E3XgdXVS4SNFybLyl5QHiUiHoGRbvAFixLNLMAk0+pFbgtGQLo+ bXOGPmoKRH+Q7w13D7jlx9xwFnwC X-Google-Smtp-Source: ADUXVKJyEALk+r7w6C7gztowl5vLYdOArA7EciTAGqPo1JxrXWZsnHxVRNtGoAS/co8LZA/XK/CK7A== X-Received: by 2002:aca:3409:: with SMTP id b9-v6mr7629562oia.10.1529372684536; Mon, 18 Jun 2018 18:44: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 k141-v6sm12951793oih.42.2018.06.18.18.44.43 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:44:43 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:41:46 -0500 Message-Id: <20180619014319.28272-21-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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::236 Subject: [Qemu-devel] [PATCH 020/113] tpm: Set the flags of the CMD_INIT command to 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: qemu-stable@nongnu.org, Stefan Berger Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Stefan Berger The flags of the CMD_INIT control channel command were not initialized properly. Fix this and set to 0. Signed-off-by: Stefan Berger Reviewed-by: Marc-André Lureau (cherry picked from commit 302705876492a39f568035ce346e2c9176f5665e) Signed-off-by: Michael Roth --- hw/tpm/tpm_emulator.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/tpm/tpm_emulator.c b/hw/tpm/tpm_emulator.c index e1a68104d6..ad1f744132 100644 --- a/hw/tpm/tpm_emulator.c +++ b/hw/tpm/tpm_emulator.c @@ -260,7 +260,9 @@ static int tpm_emulator_check_caps(TPMEmulator *tpm_emu) static int tpm_emulator_startup_tpm(TPMBackend *tb) { TPMEmulator *tpm_emu = TPM_EMULATOR(tb); - ptm_init init; + ptm_init init = { + .u.req.init_flags = 0, + }; ptm_res res; DPRINTF("%s", __func__); From patchwork Tue Jun 19 01:41: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: 931274 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="mFc38u/p"; 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 418s7y5Q7qz9s37 for ; Tue, 19 Jun 2018 12:18:22 +1000 (AEST) Received: from localhost ([::1]:38563 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6Ds-0000xT-8o for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:18:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45255) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5hT-00012X-2f for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5hR-00084i-US for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:51 -0400 Received: from mail-ot0-x244.google.com ([2607:f8b0:4003:c0f::244]:32773) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5hR-00084Z-OO; Mon, 18 Jun 2018 21:44:49 -0400 Received: by mail-ot0-x244.google.com with SMTP id h6-v6so20789624otj.0; Mon, 18 Jun 2018 18:44: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=qM7TMfZHVkWFdrMEC1+1ffvTVguQ/3VrwQVoT10JH14=; b=mFc38u/p8aK3a1Ov+0ElQ5MG4rB37efgAJiUAuQZQ4i208Kp5V85cSaDw3e4gNSzkU K0OR39EfR1CT22trjt/QWpoH3YiPLzyZeIwEtmcmt+ZOAXKqWl+xLJWVQLt1SLBsVnOJ NnBgReAxH06ZJB9QAekWAfKpfKCuXehMZOJzfnOUO+51SQoT4j4NUTAu06ONjgutOn6d bsNFNClI+bgqjh8sFf0us8Di0Xlqt8V8BYqKazsK6WiPZS+n/62r59vAW6vw6YwHToQ4 +J0qx5aSXxAnyj2CIWyPT4w0DtE/qsgsctpuqJdBAhzp2iSUSxL+AUxuxUhea5MT2zDD 8QJA== 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=qM7TMfZHVkWFdrMEC1+1ffvTVguQ/3VrwQVoT10JH14=; b=p+Xyxxw/QPqeAl5qaX/++DPtwSpuHk0k0QPowyglxLNO93EiCqhmrtE1hhDoE0QJH/ IZI1ISyKEcznpUBUuv5RxgAM7qxDqmHDu2/ew51gIMy5iiTfozkN1A+mtei3BlLZA5fX /DqzLLcCwh1Nh31FmoeQmftTQ71aDrmxkjYsIKGyvbUYyFCX6V69913MlBEDWbqMLDf/ PRWxBkY0UF1Ys++G/TDjU5DTQ7PhM2Pcasr7ldB9yuPrQRneTXkyLMXtv8Y/p++Vn+hL XVnkNekR9cSjnUIljPW4aJcKSsIGZepsxW9671HGPUrejoYd9fre2BBTrXFGb5pNjV3n PSbQ== X-Gm-Message-State: APt69E04JVk1J6pmS+379wdnJQm8d2GNN9zLlK1maMT+F9EFB4dBXlzV yZgVu8dBXEtqb4ILfRZ1TTEHxBdQ X-Google-Smtp-Source: ADUXVKK2KSrjao0PfCYm4vec0E7zaQ8R7NXvfF0M4glVmz34MqIb47zRac9wOssVT64LdxVvwQGZRQ== X-Received: by 2002:a9d:2713:: with SMTP id r19-v6mr9899208ota.93.1529372688583; Mon, 18 Jun 2018 18:44:48 -0700 (PDT) Received: from localhost ([2600:1700:70:e488:b0ee:9bda:ee6f:91be]) by smtp.gmail.com with ESMTPSA id t77-v6sm7293535oie.3.2018.06.18.18.44.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:44:47 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:41:47 -0500 Message-Id: <20180619014319.28272-22-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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:c0f::244 Subject: [Qemu-devel] [PATCH 021/113] loader: don't perform overlapping address check for memory region ROM images 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: Mark Cave-Ayland , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Mark Cave-Ayland All memory region ROM images have a base address of 0 which causes the overlapping address check to fail if more than one memory region ROM image is present, or an existing ROM image is loaded at address 0. Make sure that we ignore the overlapping address check in rom_check_and_register_reset() if this is a memory region ROM image. In particular this fixes the "rom: requested regions overlap" error on startup when trying to run qemu-system-sparc with a -kernel image since commit 7497638642: "tcx: switch to load_image_mr() and remove prom_addr hack". Suggested-by: Peter Maydell Reviewed-by: Peter Maydell Signed-off-by: Mark Cave-Ayland (cherry picked from commit ca316c11526a1bc221fb542bdce6bac7238dde69) Signed-off-by: Michael Roth --- hw/core/loader.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/hw/core/loader.c b/hw/core/loader.c index 91669d65aa..c08f130461 100644 --- a/hw/core/loader.c +++ b/hw/core/loader.c @@ -1104,20 +1104,22 @@ int rom_check_and_register_reset(void) if (rom->fw_file) { continue; } - if ((addr > rom->addr) && (as == rom->as)) { - fprintf(stderr, "rom: requested regions overlap " - "(rom %s. free=0x" TARGET_FMT_plx - ", addr=0x" TARGET_FMT_plx ")\n", - rom->name, addr, rom->addr); - return -1; + if (!rom->mr) { + if ((addr > rom->addr) && (as == rom->as)) { + fprintf(stderr, "rom: requested regions overlap " + "(rom %s. free=0x" TARGET_FMT_plx + ", addr=0x" TARGET_FMT_plx ")\n", + rom->name, addr, rom->addr); + return -1; + } + addr = rom->addr; + addr += rom->romsize; + as = rom->as; } - addr = rom->addr; - addr += rom->romsize; section = memory_region_find(rom->mr ? rom->mr : get_system_memory(), rom->addr, 1); rom->isrom = int128_nz(section.size) && memory_region_is_rom(section.mr); memory_region_unref(section.mr); - as = rom->as; } qemu_register_reset(rom_reset, NULL); roms_loaded = 1; From patchwork Tue Jun 19 01:41: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: 931259 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="lt6V+BPJ"; 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 418rrf0p5hz9s2t for ; Tue, 19 Jun 2018 12:05:06 +1000 (AEST) Received: from localhost ([::1]:38483 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV611-0007Oy-M4 for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:05:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45282) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5hV-00013V-32 for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5hU-00085n-21 for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:53 -0400 Received: from mail-ot0-x242.google.com ([2607:f8b0:4003:c0f::242]:44060) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5hT-00085f-So; Mon, 18 Jun 2018 21:44:51 -0400 Received: by mail-ot0-x242.google.com with SMTP id w13-v6so20756323ote.11; Mon, 18 Jun 2018 18:44:51 -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=GkGE+KCrq+P0aYVBj7dDqXVu+irS20/NTs9htUFjkkQ=; b=lt6V+BPJGd8fhK+ry7aoD/5H4PxWkeUbdKwhcBmYpneNBtUC3mnIgQnttmsIQA72Lc tlZ/i42osHNQ3CYysuYBBmACVXTjjJrmjcV4lKaDs8nppMKrfEpZpNLABEddCsOA5iN6 q7FCUynkqLHXfKowlgjlROKunTo9bIq0DLZxZknQct8QeS3vDflrZgp+6hc2hKGb6WEh 2Eg7wOHs0BgUTH1TO3/CkThO7i74sQBxSSBfxCbMQOkgDGPmZqS4ZB1WsqkFMRXR6Ogd Uz5iqLQF2gQiYc2pMuNYUIVBygbOByKjMtdM/JXA4EQSYdz7UMDuH4cgoGT+wlEgj780 f2cA== 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=GkGE+KCrq+P0aYVBj7dDqXVu+irS20/NTs9htUFjkkQ=; b=ifMqQmuiv7ra08uxJlIWZZy1V70WZt/pMeWp0ueQa6m0MFImP1G2Eok5511od7/fGu +f9dIDtf88j98yolFX9bi60fUXnO7kPCTUgBqhZyHC4R7b3Gz0v9r8ASeBsyKB1c/Kw0 PFIQ7lEIbK1bZZh2Ys1xpKw9VFY8Dra7511ywbSIXh25oXOUhEy3TEyVuIzCBYxNyjVv Xu/z6m4oOD0h4hB6bJtDRpj/IaMd01bKo9IXhqzrPExG9sqbZ18nO8itaCcIluxECRST 0H7GiiGVU5IN+hvTDAoK9LXHpPvTT9hpjzyieQ49R5xdOfaHWeqHfrCuxgMh6WqqorFl miGw== X-Gm-Message-State: APt69E39UCz+LmRnqc0KF94iNKve3Xns/sejqJ9vma087VpIbwLgEAPw QE/j5vdoScJeJWqaKRhWnUlJXXZm X-Google-Smtp-Source: ADUXVKI+70G+B3P7VQa01IDl2JKttipZc2XE9h+Gy+cChEyAyNI70CQ5UqjW7jUk5F25zulhdo47gA== X-Received: by 2002:a9d:5c84:: with SMTP id a4-v6mr9619574oti.301.1529372690613; Mon, 18 Jun 2018 18:44:50 -0700 (PDT) Received: from localhost ([2600:1700:70:e488:b0ee:9bda:ee6f:91be]) by smtp.gmail.com with ESMTPSA id t4-v6sm16636816otd.40.2018.06.18.18.44.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:44:49 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:41:48 -0500 Message-Id: <20180619014319.28272-23-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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:c0f::242 Subject: [Qemu-devel] [PATCH 022/113] target/xtensa: dump correct physical registers 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: Max Filippov , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Max Filippov xtensa_cpu_dump_state outputs CPU physical registers as is, without synchronization from current window. That may result in different values printed for the current window and corresponding physical registers. Synchronize physical registers from window before dumping. Cc: qemu-stable@nongnu.org Signed-off-by: Max Filippov (cherry picked from commit b55b1afda942306e4e40420aced1524bd83ba16d) Conflicts: target/xtensa/translate.c * drop context dependencies Signed-off-by: Michael Roth --- target/xtensa/translate.c | 1 + 1 file changed, 1 insertion(+) diff --git a/target/xtensa/translate.c b/target/xtensa/translate.c index 20f7ddf042..60f2fe6e0b 100644 --- a/target/xtensa/translate.c +++ b/target/xtensa/translate.c @@ -3288,6 +3288,7 @@ void xtensa_cpu_dump_state(CPUState *cs, FILE *f, (i % 4) == 3 ? '\n' : ' '); } + xtensa_sync_phys_from_window(env); cpu_fprintf(f, "\n"); for (i = 0; i < env->config->nareg; ++i) { From patchwork Tue Jun 19 01:41: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: 931278 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="cfMNaMnT"; 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 418sCf6lrSz9s3C for ; Tue, 19 Jun 2018 12:21:34 +1000 (AEST) Received: from localhost ([::1]:38582 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6Gy-0003Yn-GT for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:21:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45324) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5hX-00016j-DD for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5hW-00086e-2i for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:55 -0400 Received: from mail-oi0-x243.google.com ([2607:f8b0:4003:c06::243]:44557) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5hV-00086N-Ru; Mon, 18 Jun 2018 21:44:54 -0400 Received: by mail-oi0-x243.google.com with SMTP id c128-v6so16677403oig.11; Mon, 18 Jun 2018 18:44:53 -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=m0+B9s+mSGfTWiYQNXrdMqfA94XVvo6m6l6FcDOZVNo=; b=cfMNaMnTkh76T9Kznac8wTt0O7AN+Ayn5pTyny8SXvnkayCBIsb5wiHOzNgsf0YXmh dLv/qmj3sDb1OUxpNAn9AZsEZ7oicywteZumH+Y2tIhfD/4IYnUv4dYwzV8wvTKN/vg+ ggk/vlCtzJk+JsHCacLUpyuq9kbtSbLvW9ZsZ4dA+fVKjYIk36/KQ+RzYK4vReaVA+V9 IkMqVSLjiowT2nemsPwzKd/A8oeX5lKRI/EzCDxga+Udxm7hzhG84rQ6bTl3stN1bn4F momKqFR2ektrazZkH7nJkJcGTonKFVTBIwovboqexBXIh6z3PiRAQWbjx+gzaeV9sf4F UrRg== 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=m0+B9s+mSGfTWiYQNXrdMqfA94XVvo6m6l6FcDOZVNo=; b=i8jOKGorTXb1kOpMrpPT36FJK6qSmOaJmPjJV84nIQ0J4s5P3wTlgEhG/S1Isi0FPs FWGPc3/clSeEnY/tbwz5uiaFdy61Z21joM9+v3llKC0D97nsKawRazR5og47ZUHaBVSu IKBOBbyLOcWiR2NdVdTczo/3feFetN3Fnbp2a0Eei+/99GivxMUQSl7QMbV1ko5bHVKZ xGVE0GVe1du0rJNsqnSIwwwlFbsBf9+BJMXX/osV17HbGGtcfnvB8xYmzDCqSodGN7Ar Q57o0v5ANuevKvfHmFGri6sapS9bjPWD+H/Kr+OHDZkZAZe21xbHBEBxryy76Wy5kjlp l1jg== X-Gm-Message-State: APt69E3+WxqAkNbllfAv+8DTQttNwU4IvGFq29UgHMFaG8tVm8VOfq/T zH219H0INPzgXtjR3vBMXCLzADUn X-Google-Smtp-Source: ADUXVKJCi+hPnx9SR4KlwchmA39y6P1W+O4uMecZnsCraa43F1CVUYgzFMHvcOeZlHnFHay1qq9suA== X-Received: by 2002:aca:5094:: with SMTP id e142-v6mr7897424oib.190.1529372692677; Mon, 18 Jun 2018 18:44:52 -0700 (PDT) Received: from localhost ([2600:1700:70:e488:b0ee:9bda:ee6f:91be]) by smtp.gmail.com with ESMTPSA id v50-v6sm9189917otd.7.2018.06.18.18.44.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:44:51 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:41:49 -0500 Message-Id: <20180619014319.28272-24-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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 023/113] linux-user: fix mmap/munmap/mprotect/mremap/shmat 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: Max Filippov , Riku Voipio , qemu-stable@nongnu.org, Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Max Filippov In linux-user QEMU that runs for a target with TARGET_ABI_BITS bigger than L1_MAP_ADDR_SPACE_BITS an assertion in page_set_flags fires when mmap, munmap, mprotect, mremap or shmat is called for an address outside the guest address space. mmap and mprotect should return ENOMEM in such case. Change definition of GUEST_ADDR_MAX to always be the last valid guest address. Account for this change in open_self_maps. Add macro guest_addr_valid that verifies if the guest address is valid. Add function guest_range_valid that verifies if address range is within guest address space and does not wrap around. Use that macro in mmap/munmap/mprotect/mremap/shmat for error checking. Cc: qemu-stable@nongnu.org Cc: Riku Voipio Cc: Laurent Vivier Signed-off-by: Max Filippov Reviewed-by: Laurent Vivier Message-Id: <20180307215010.30706-1-jcmvbkbc@gmail.com> Signed-off-by: Laurent Vivier (cherry picked from commit ebf9a3630c911d0cfc9c20f7cafe9ba4f88cf583) Signed-off-by: Michael Roth --- include/exec/cpu-all.h | 6 +++++- include/exec/cpu_ldst.h | 16 +++++++--------- linux-user/mmap.c | 20 +++++++++++++++----- linux-user/syscall.c | 5 ++++- 4 files changed, 31 insertions(+), 16 deletions(-) diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index 0b141683f0..f4fa94e966 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -159,8 +159,12 @@ extern unsigned long guest_base; extern int have_guest_base; extern unsigned long reserved_va; -#define GUEST_ADDR_MAX (reserved_va ? reserved_va : \ +#if HOST_LONG_BITS <= TARGET_VIRT_ADDR_SPACE_BITS +#define GUEST_ADDR_MAX (~0ul) +#else +#define GUEST_ADDR_MAX (reserved_va ? reserved_va - 1 : \ (1ul << TARGET_VIRT_ADDR_SPACE_BITS) - 1) +#endif #else #include "exec/hwaddr.h" diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h index 191f2e962a..5de8c8a5af 100644 --- a/include/exec/cpu_ldst.h +++ b/include/exec/cpu_ldst.h @@ -51,15 +51,13 @@ /* All direct uses of g2h and h2g need to go away for usermode softmmu. */ #define g2h(x) ((void *)((unsigned long)(target_ulong)(x) + guest_base)) -#if HOST_LONG_BITS <= TARGET_VIRT_ADDR_SPACE_BITS -#define h2g_valid(x) 1 -#else -#define h2g_valid(x) ({ \ - unsigned long __guest = (unsigned long)(x) - guest_base; \ - (__guest < (1ul << TARGET_VIRT_ADDR_SPACE_BITS)) && \ - (!reserved_va || (__guest < reserved_va)); \ -}) -#endif +#define guest_addr_valid(x) ((x) <= GUEST_ADDR_MAX) +#define h2g_valid(x) guest_addr_valid((unsigned long)(x) - guest_base) + +static inline int guest_range_valid(unsigned long start, unsigned long len) +{ + return len - 1 <= GUEST_ADDR_MAX && start <= GUEST_ADDR_MAX - len + 1; +} #define h2g_nocheck(x) ({ \ unsigned long __ret = (unsigned long)(x) - guest_base; \ diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 4888f53139..33a73cd29c 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -80,8 +80,9 @@ int target_mprotect(abi_ulong start, abi_ulong len, int prot) return -EINVAL; len = TARGET_PAGE_ALIGN(len); end = start + len; - if (end < start) - return -EINVAL; + if (!guest_range_valid(start, len)) { + return -ENOMEM; + } prot &= PROT_READ | PROT_WRITE | PROT_EXEC; if (len == 0) return 0; @@ -481,8 +482,8 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot, * It can fail only on 64-bit host with 32-bit target. * On any other target/host host mmap() handles this error correctly. */ - if ((unsigned long)start + len - 1 > (abi_ulong) -1) { - errno = EINVAL; + if (!guest_range_valid(start, len)) { + errno = ENOMEM; goto fail; } @@ -622,8 +623,10 @@ int target_munmap(abi_ulong start, abi_ulong len) if (start & ~TARGET_PAGE_MASK) return -EINVAL; len = TARGET_PAGE_ALIGN(len); - if (len == 0) + if (len == 0 || !guest_range_valid(start, len)) { return -EINVAL; + } + mmap_lock(); end = start + len; real_start = start & qemu_host_page_mask; @@ -678,6 +681,13 @@ abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size, int prot; void *host_addr; + if (!guest_range_valid(old_addr, old_size) || + ((flags & MREMAP_FIXED) && + !guest_range_valid(new_addr, new_size))) { + errno = ENOMEM; + return -1; + } + mmap_lock(); if (flags & MREMAP_FIXED) { diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 11c9116c4a..9872de7221 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -4871,6 +4871,9 @@ static inline abi_ulong do_shmat(CPUArchState *cpu_env, return -TARGET_EINVAL; } } + if (!guest_range_valid(shmaddr, shm_info.shm_segsz)) { + return -TARGET_EINVAL; + } mmap_lock(); @@ -7430,7 +7433,7 @@ static int open_self_maps(void *cpu_env, int fd) } if (h2g_valid(min)) { int flags = page_get_flags(h2g(min)); - max = h2g_valid(max - 1) ? max : (uintptr_t)g2h(GUEST_ADDR_MAX); + max = h2g_valid(max - 1) ? max : (uintptr_t)g2h(GUEST_ADDR_MAX) + 1; if (page_check_range(h2g(min), max - min, flags) == -1) { continue; } From patchwork Tue Jun 19 01:41: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: 931280 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="pS3EJ3R+"; 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 418sH60Mj8z9s37 for ; Tue, 19 Jun 2018 12:24:34 +1000 (AEST) Received: from localhost ([::1]:38599 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6Jr-0005pO-MD for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:24:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45345) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5hY-00018O-UT for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5hY-00087W-1f for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:57 -0400 Received: from mail-oi0-x242.google.com ([2607:f8b0:4003:c06::242]:33342) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5hX-00087P-ST; Mon, 18 Jun 2018 21:44:55 -0400 Received: by mail-oi0-x242.google.com with SMTP id c6-v6so16698615oiy.0; Mon, 18 Jun 2018 18:44:55 -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=kqyIMwNa5Ip7nhkfm8ERV6p+wMvHFWzhC2yEGIitDg8=; b=pS3EJ3R+DIheOGNOMM+TcXM4zL4db1hmJ1qJlPYB08aQNG1CGMwypFwjY9PBZz7NXZ KDDR+/8tolW5g1GJJ6IaVhyWuntNYBUrnNpxbQzVWAILyVLIjTWw682W07SphZhRurFx o+5cNeC0676xyfPV0j8docqRaeANyLhDgpzgmR+6s5IKU1/VZ7XqFodm/w8aMTgyTKba ukIrLKGyM4zwInwT2mlTOrWqtaY8pIDmTyQKOe9ZKjK0vLGW0D1L1YB0Z5amYlN+4Tgl 71DhO34YzL+SV1GqaYrU2TSI2qmuhNIHVIOBlJ58cQ76m13jEH1CovElixbag65xY5Nb ggbw== 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=kqyIMwNa5Ip7nhkfm8ERV6p+wMvHFWzhC2yEGIitDg8=; b=eliq44oQKh0XJNzfAjUDWrSX/OyPTb7XuCYR0lQIw5Ka7f7VItyBF8U8fryNQWp6F+ KR5UljJYR9UvsUr58R19R6GSAPvf+iL/AMPJO/IXBa7gFi/FAlMKBGO9K2kUSvVsSaN7 httkVFtLFz87cIsnfsxwHNC9tpMFW9z8W5Evd0t1AZFxI9Blp/qmLu1m9RRZLKYcTony 2CW1nZ9GXPb3h6fgaBtxYIbibSj2WnIBk2xIDJLaNsbQlauk7AW0D+rvx5pUvDq51mZq jeSVzdelT8yKNMhA5Wt5N7TWidYXfaLfm28ZK7ioOlyiZdySFvgbP64mqam2VePp3MNP 4NZQ== X-Gm-Message-State: APt69E34wavDLOqbp/gc+f8zDz7Z2OXyfMVgg6ua1gfMSqLvWEa5KPRK 1/Yqb1s0gKV2xZ0Qz2b4/UrNyo6s X-Google-Smtp-Source: ADUXVKLomTbnjsArUf3CFBuWhUqcS0ozCpKsylaHXmGGpytQBz0TAarNAwDSyMw8rAd15ZmFTOP3mQ== X-Received: by 2002:aca:cc4a:: with SMTP id c71-v6mr8805836oig.152.1529372694709; Mon, 18 Jun 2018 18:44:54 -0700 (PDT) Received: from localhost ([2600:1700:70:e488:b0ee:9bda:ee6f:91be]) by smtp.gmail.com with ESMTPSA id c17-v6sm7363271otl.17.2018.06.18.18.44.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:44:53 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:41:50 -0500 Message-Id: <20180619014319.28272-25-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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 024/113] linux-user: fix assertion in shmdt 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: Max Filippov , Riku Voipio , qemu-stable@nongnu.org, Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Max Filippov shmdt fails to call mmap_lock/mmap_unlock around page_set_flags, resulting in the following assertion: page_set_flags: Assertion `have_mmap_lock()' failed. Wrap shmdt internals into mmap_lock/mmap_unlock. Cc: qemu-stable@nongnu.org Cc: Riku Voipio Cc: Laurent Vivier Signed-off-by: Max Filippov Reviewed-by: Laurent Vivier Message-Id: <20180228221609.11265-7-jcmvbkbc@gmail.com> Signed-off-by: Laurent Vivier (cherry picked from commit 3c5f6a5f888729f9fbc64211298f7c3e2fb42b64) Signed-off-by: Michael Roth --- linux-user/syscall.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 9872de7221..74d56e2ee6 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -4918,6 +4918,9 @@ static inline abi_ulong do_shmat(CPUArchState *cpu_env, static inline abi_long do_shmdt(abi_ulong shmaddr) { int i; + abi_long rv; + + mmap_lock(); for (i = 0; i < N_SHM_REGIONS; ++i) { if (shm_regions[i].in_use && shm_regions[i].start == shmaddr) { @@ -4926,8 +4929,11 @@ static inline abi_long do_shmdt(abi_ulong shmaddr) break; } } + rv = get_errno(shmdt(g2h(shmaddr))); + + mmap_unlock(); - return get_errno(shmdt(g2h(shmaddr))); + return rv; } #ifdef TARGET_NR_ipc From patchwork Tue Jun 19 01:41:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 931265 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="Bj5Plx6h"; 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 418rxh45VTz9s19 for ; Tue, 19 Jun 2018 12:09:28 +1000 (AEST) Received: from localhost ([::1]:38509 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV65G-0002EQ-26 for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:09:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45408) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5he-0001EY-I4 for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5ha-00088Z-9c for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:02 -0400 Received: from mail-ot0-x22b.google.com ([2607:f8b0:4003:c0f::22b]:35248) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5ha-00088E-4P; Mon, 18 Jun 2018 21:44:58 -0400 Received: by mail-ot0-x22b.google.com with SMTP id q17-v6so20776826otg.2; Mon, 18 Jun 2018 18:44:57 -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=+tWXsKkgd9dwTNsOa+deYgnfMNYxKlK9ZP2XKR/YLy8=; b=Bj5Plx6htVFPVZWiE19crwLloEyngWXBNFDisnl36rO+45ooL8RrUyFAC9xHnAG/e4 muQjRt/upmWnvIYeh/09RTXO/psUgrtQRNPbVPJCRryP6m2QET3GykgSBp+N66xAJ4TB STSsmQnadBJNBeM9u6tVuHrEHZ5eJlgR21gV6SVgTw+JHJEHfDRVbMR643/5+e7ZaLWq ZuMDFZXwqkeZUPlJ7UivIwEO05L8XSZBn0QfwXrykVKYPMHkFebvgMbcnNyyAcIAfaFs Zl7ltvOcr46rh01AJ+xU6rHpCMw+UlW5AiKbtyL6zE+OLvSPKvy7weIWXupDJ3EOxRX8 /kjw== 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=+tWXsKkgd9dwTNsOa+deYgnfMNYxKlK9ZP2XKR/YLy8=; b=hq5+9dLppf2Tu4zS0aF94QaCQjH5QCmT13n8z9ITHsyq/T9a3gFUMY3OuFZjDlRJEm o/CGyP9nfiwi9R6AQ9ToolPJiRvkHtXxh/vGZf5FOZi7ZWg8sAOTRmzcgAihv7CS9I12 M5uRFKu5V8x97tl/krFB4pi0M7XeLZmhDZQg5fxdy3oLwqYGIEQ2fu9Z+0L71nsFXSRf qPHLNzz4Fuihkn6Sv4IGlBGXoRU3oSqFll+ovD96S2vmzaJOoX5mB0R/5eJu3SEU6juP 299eBLHdoLguQM64sF+Wxdud5wUCawNy072PGeC7dHMnDU090YH8cf+cihhbTM1FZcBP U4aQ== X-Gm-Message-State: APt69E0Ph+pqT0n+qBphhM0csWXSIvORvkblyXN6/YnNBalDPlB2yK0Q CLacsLGX7RQb8ZUj8aJ96JXUszG1 X-Google-Smtp-Source: ADUXVKJZ7D8QKMjvHQvCgADZAbCupArEuKmsP0HlfB1ABS7DTebD65cy0CLqwWYJE2LRhWSyLTCbWA== X-Received: by 2002:a9d:6385:: with SMTP id w5-v6mr9760231otk.233.1529372696834; Mon, 18 Jun 2018 18:44:56 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id z21-v6sm7388294otk.20.2018.06.18.18.44.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:44:55 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:41:51 -0500 Message-Id: <20180619014319.28272-26-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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:c0f::22b Subject: [Qemu-devel] [PATCH 025/113] linux-user: fix target_mprotect/target_munmap error return 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: Max Filippov , Riku Voipio , qemu-stable@nongnu.org, Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Max Filippov target_mprotect/target_munmap return value goes through get_errno at the call site, thus the functions must either set errno to host error code and return -1 or return negative guest error code. Do the latter. Cc: qemu-stable@nongnu.org Cc: Riku Voipio Cc: Laurent Vivier Signed-off-by: Max Filippov Reviewed-by: Laurent Vivier Message-Id: <20180228221609.11265-8-jcmvbkbc@gmail.com> Signed-off-by: Laurent Vivier (cherry picked from commit 78cf339039c325b336442f1d7f3ccc531b22c4a0) Signed-off-by: Michael Roth --- linux-user/mmap.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 33a73cd29c..e0c946eae6 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -77,11 +77,11 @@ int target_mprotect(abi_ulong start, abi_ulong len, int prot) #endif if ((start & ~TARGET_PAGE_MASK) != 0) - return -EINVAL; + return -TARGET_EINVAL; len = TARGET_PAGE_ALIGN(len); end = start + len; if (!guest_range_valid(start, len)) { - return -ENOMEM; + return -TARGET_ENOMEM; } prot &= PROT_READ | PROT_WRITE | PROT_EXEC; if (len == 0) @@ -621,10 +621,10 @@ int target_munmap(abi_ulong start, abi_ulong len) start, len); #endif if (start & ~TARGET_PAGE_MASK) - return -EINVAL; + return -TARGET_EINVAL; len = TARGET_PAGE_ALIGN(len); if (len == 0 || !guest_range_valid(start, len)) { - return -EINVAL; + return -TARGET_EINVAL; } mmap_lock(); From patchwork Tue Jun 19 01:41:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 931281 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="Q7qi54qp"; 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 418sHk12PWz9s3C for ; Tue, 19 Jun 2018 12:25:06 +1000 (AEST) Received: from localhost ([::1]:38604 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6KN-0006FC-M5 for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:25:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45421) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5hf-0001FD-6U for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5hc-00089K-31 for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:03 -0400 Received: from mail-ot0-x22b.google.com ([2607:f8b0:4003:c0f::22b]:44552) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5hb-000893-UL; Mon, 18 Jun 2018 21:45:00 -0400 Received: by mail-ot0-x22b.google.com with SMTP id w13-v6so20756564ote.11; Mon, 18 Jun 2018 18:44: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; bh=kcYTiHjA24qLCfUI0I3QpxcQz31ZqaR+GbBQohSv2tE=; b=Q7qi54qp9P7NqNQqZ81mac4AaDLaBeVfAkdje373CPn2MczK/JcdyuuNKH55U4xOoo BsWxExIH36yPi22jmSDU0dJvUikZ1qNZVjA+vzOQmtnLOcbhxGH4oU4Fc8RHfbnjnJGa fjF2HTOiQKBkjD82eopB+UZCws0zi8hyZ8V6MyvZJyBh6wj6itQucLZTbYYiwrmlIMS5 xE827wy7nlRcYGeMvd8AmF1GvKln1C0pQfLvLNE/u6HBGNlZg/PQ0FrBYoxrJI4BoQN8 3eHI+tJyvDhWgfkyx4zPvSljGPgyr1Gh/Rl7lVroU6SsTcUoKiD+Tj+AF4aZq9GtHSYa gjDw== 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=kcYTiHjA24qLCfUI0I3QpxcQz31ZqaR+GbBQohSv2tE=; b=LwLsV6gRIFmo4wcIVqqKZlanPRvLO6Hi32Uh0czSz5JuOzkS9w1dkLhDUsxE1AMihJ 9B4eDqP12/3MQ7jri/OpKtlPhcG1Y+PiAelDNzhvjZ1ORYRzAxqxWLvHAcByU5uWqN4S nmH3YN8NR3qBmqbzXKqQ3WtnliXGchH+D+wo7pdKhQlNdJiZxD4QpTXaRS55N2C7cPsB lCxf/PFuUtVDOh4bUYsEw9R+0D39l92jnKLCZmr8Ouy+hVA9GRX9AypSjU67yFpUD9+a 4QG+9VWwIqTbleMURaG7tXDDRtNrS2dzlGFhN9aUcd++XGGUwrKwz+WK5HlTiMkmF8R9 xvWg== X-Gm-Message-State: APt69E0qZOhg+eUy7cW9itiSmT2Nq6sh+ZcVK591JTP6al1fF7suCrMF 5iwgtoaH5z8Qn2e1+Pp1AozcBpS1 X-Google-Smtp-Source: ADUXVKLvDi4J1MZemkj/5oByJFZVO8Gctpuff5X7EnKLWefXOIg1/EvAHYG455pd1+85HKZYXp36hg== X-Received: by 2002:a9d:3c2d:: with SMTP id q42-v6mr8614673otc.202.1529372698806; Mon, 18 Jun 2018 18:44: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 k141-v6sm12952504oih.42.2018.06.18.18.44.57 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:44:57 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:41:52 -0500 Message-Id: <20180619014319.28272-27-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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:c0f::22b Subject: [Qemu-devel] [PATCH 026/113] sparc: fix leon3 casa instruction when MMU is disabled 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 , Mark Cave-Ayland , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: KONRAD Frederic Since the commit af7a06bac7d3abb2da48ef3277d2a415772d2ae8: `casa [..](10), .., ..` (and probably others alternate space instructions) triggers a data access exception when the MMU is disabled. When we enter get_asi(...) dc->mem_idx is set to MMU_PHYS_IDX when the MMU is disabled. Just keep mem_idx unchanged in this case so we passthrough the MMU when it is disabled. Signed-off-by: KONRAD Frederic Signed-off-by: Mark Cave-Ayland (cherry picked from commit 6e10f37c86068e35151f982c976a85f1bec07ef2) Signed-off-by: Michael Roth --- target/sparc/translate.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/target/sparc/translate.c b/target/sparc/translate.c index 849a02aebd..63693f72e3 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -2093,6 +2093,11 @@ static DisasASI get_asi(DisasContext *dc, int insn, TCGMemOp memop) type = GET_ASI_BFILL; break; } + + /* MMU_PHYS_IDX is used when the MMU is disabled to passthrough the + * permissions check in get_physical_address(..). + */ + mem_idx = (dc->mem_idx == MMU_PHYS_IDX) ? MMU_PHYS_IDX : mem_idx; } else { gen_exception(dc, TT_PRIV_INSN); type = GET_ASI_EXCP; From patchwork Tue Jun 19 01:41:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 931272 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="KwHiMDex"; 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 418s5j2kvLz9s37 for ; Tue, 19 Jun 2018 12:16:25 +1000 (AEST) Received: from localhost ([::1]:38554 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6By-00083T-Sz for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:16:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45417) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5hf-0001Ey-1d for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5he-0008AC-7n for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:03 -0400 Received: from mail-ot0-x244.google.com ([2607:f8b0:4003:c0f::244]:39250) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5he-00089q-2J; Mon, 18 Jun 2018 21:45:02 -0400 Received: by mail-ot0-x244.google.com with SMTP id l15-v6so20760935oth.6; Mon, 18 Jun 2018 18:45: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=XRVeJm8/PQHEvmfZNgTlf2ILrxYRXKQzS0Noee4oDww=; b=KwHiMDex/2r+dsnHVIOjoaQumhvVPrt5rEUFdoSdiRJFD1Z3g/sa2O110YLQ1TnGEs 5A4BDBs4NEIplzPrw6H0mV4TmxPqdC5hVH2IaEntbGohlIKrTqYK5n27mAF9fPvy96N/ LXXU522Ppwm89iTPqHi9Dw2yu3ei5/nWdoWf1fDL+Ou4IXJHcqa3iltWJ/b71xabogpt ktP+8lzT2FMhzuOcxrDSYYkbQ1gaedpMpkTFxpWuETZLo6sNrjvQqZFhnP6SexroXMjs h4/2gsi0jAPqaKGa6zVa194hKKEE2xMonZeZ/xi956LlHzuoa4eRo7zGWWgfFGsQaH2x 1xVQ== 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=XRVeJm8/PQHEvmfZNgTlf2ILrxYRXKQzS0Noee4oDww=; b=ThFJ28rSkmIg6eQWPaAepeYmGjAA5/Q4wPu4FvOAzNORlGnNqN5A5Hm9ezIBsZS+d7 fjABZmM41eqeXVYhRBDVQYVSyHFgw86HKUXox55tB5GoHG6H7O1oxkjSU/Vg8fEjOxni jNCEfKub6Sxyr/XrbGZiIm0ZbXrPe1SYJq5xtQNdKfLIwV1WolgfFOEfij2Awmf/k+iw ZM0eM4ijcc0qEjuNfr0aAFgBwolf8YihBv5NH9yWdmHlnz52ltvkoE6pYPP1k7i5gnoh Lga9aCbSq6qhIDigpkw7isGg8ErafzfkYYj54j3F5A54OOx99PwnPoWdRPj7DjhnOE8Y nwjQ== X-Gm-Message-State: APt69E2Yn9BwrlnlkX7ilVxcLF2NvAlWnGHO6wMwN4v28rByBduUyV7e 2eyCLkTpeHFrDxOpx3GYXGxjTRyg X-Google-Smtp-Source: ADUXVKLW8P7bfqxQmKheaXUIJZzeKUtl2rbXBZChUTOwzDIbTJ2eSj+7kQHPi96cj4i8Gk8Qiz1n2Q== X-Received: by 2002:a9d:e7c:: with SMTP id n57-v6mr9637366otd.10.1529372700768; Mon, 18 Jun 2018 18:45:00 -0700 (PDT) Received: from localhost ([2600:1700:70:e488:b0ee:9bda:ee6f:91be]) by smtp.gmail.com with ESMTPSA id t10-v6sm8489627ota.23.2018.06.18.18.44.59 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:44:59 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:41:53 -0500 Message-Id: <20180619014319.28272-28-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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:c0f::244 Subject: [Qemu-devel] [PATCH 027/113] openpic_kvm: drop address_space_to_flatview call 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 Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Paolo Bonzini The MemoryListener is registered on address_space_memory, there is not much to assert. This currently works because the callback is invoked only once when the listener is registered, but section->fv is the _new_ FlatView, not the old one on later calls and that would break. This confines address_space_to_flatview to exec.c and memory.c. Acked-by: David Gibson Reviewed-by: Alexey Kardashevskiy Signed-off-by: Paolo Bonzini (cherry picked from commit 80d2b933f9fe3e53d4f76a45a1bc1a0175669468) Signed-off-by: Michael Roth --- hw/intc/openpic_kvm.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/hw/intc/openpic_kvm.c b/hw/intc/openpic_kvm.c index fa83420254..39a6f369c5 100644 --- a/hw/intc/openpic_kvm.c +++ b/hw/intc/openpic_kvm.c @@ -124,10 +124,6 @@ static void kvm_openpic_region_add(MemoryListener *listener, uint64_t reg_base; int ret; - if (section->fv != address_space_to_flatview(&address_space_memory)) { - abort(); - } - /* Ignore events on regions that are not us */ if (section->mr != &opp->mem) { return; From patchwork Tue Jun 19 01:41: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: 931268 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="PLbE4vVp"; 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 418s2B4WBGz9s2t for ; Tue, 19 Jun 2018 12:13:22 +1000 (AEST) Received: from localhost ([::1]:38531 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV692-0005X4-91 for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:13:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45472) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5hh-0001Fu-OD for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5hg-0008BW-Q0 for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:05 -0400 Received: from mail-oi0-x22f.google.com ([2607:f8b0:4003:c06::22f]:44445) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5hg-0008B0-KO; Mon, 18 Jun 2018 21:45:04 -0400 Received: by mail-oi0-x22f.google.com with SMTP id c128-v6so16677688oig.11; Mon, 18 Jun 2018 18:45:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=l4veLp1exqJh+BmHTGrlEpoYremYvuCgClF71MFZWnw=; b=PLbE4vVpnKvWqy/fyl9vGBD8n5i3RqVjpiZsm4cZ3PPZdQ9wlRZ7DvsnwtKeHb+Vu9 zFuiB/LTNIaNtc4DU01WKjN0vXfmq0aPAt+Yi9bWeZog75Ead94T2impx8mkoJTOhX8T jZxwRruREpYsuZZHIXnVUKmqBtAyTzI3FtIKApIVcGeOdUvQKk+2/3HxXkb6RAELwApM sTQdcgZ87qQ6a5su1TbTUh7IYBrWnlg/SVry6YLbRgtFRlsSCF5jsdM/gjt6gSb9AzFX LcmZg7W+eCHM429XD6L1vJRebfE9RzcEaQ5k8QB/2xX93OzOD7/7QEmJ1IJFOMmEjFzU chEA== 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=l4veLp1exqJh+BmHTGrlEpoYremYvuCgClF71MFZWnw=; b=CNtGeFAxQLxJ2RvFlbyhXpPPQ7kJUsp4Jhzku7Y7ZXgW4kudrIsVYmFPC4JtytKlbD egLsagmMWSZPyNNAqiG7Spk2rPCy7F/evjtRzpxDa54BQwS8QvASyBd/toueZjoeSUTv JpcTbcuFHeekVWskaHgZLYI5XiL0rurXBz9E/zOxOPkXwZcgDsodiGBumVy26evEkbei QCeiVIhJDwoOkKsqa8mi08LZhOmUahUo3CsrrQwcqIygId4V5qzorntXdoyEyRz2n4SB 9QFkAhzaevpfZGETapC4SMXpBSY2DRXvz4+kIjuT5WPCg823sUkRXhrR9j89Jpc/nqRP kXEQ== X-Gm-Message-State: APt69E1M6NDXz0LFmXMYXsHjTzoH7zC0PL5vmB0ztPcHitdufEXvnEKX 2TnCqqzdQwS+a/mbVPolqjc12SZw X-Google-Smtp-Source: ADUXVKJszeCQhN2OeSiPkmY3rVaF/vVdEFSjXjYPXVhk6HhQteqk75xfQGROHKoHiFvAFQUaM5oKkQ== X-Received: by 2002:aca:a887:: with SMTP id r129-v6mr8469762oie.253.1529372703175; Mon, 18 Jun 2018 18:45: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 b63-v6sm7203885oia.4.2018.06.18.18.45.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:45:02 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:41:54 -0500 Message-Id: <20180619014319.28272-29-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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 028/113] memory: inline some performance-sensitive accessors 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 Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Paolo Bonzini These accessors are called from inlined functions, and the call sequence is much more expensive than just inlining the access. Move the struct declaration to memory-internal.h so that exec.c and memory.c can both use an inline function. Reviewed-by: Alexey Kardashevskiy Signed-off-by: Paolo Bonzini (cherry picked from commit 785a507ec78bbda1c346f3d3593e5a58b62e73ef) Signed-off-by: Michael Roth --- include/exec/memory-internal.h | 13 +++++++++---- include/exec/memory.h | 22 +++++++++++++++++++++- memory.c | 30 ------------------------------ 3 files changed, 30 insertions(+), 35 deletions(-) diff --git a/include/exec/memory-internal.h b/include/exec/memory-internal.h index 98d82964cc..987ff115b8 100644 --- a/include/exec/memory-internal.h +++ b/include/exec/memory-internal.h @@ -20,7 +20,15 @@ #define MEMORY_INTERNAL_H #ifndef CONFIG_USER_ONLY -typedef struct AddressSpaceDispatch AddressSpaceDispatch; +static inline AddressSpaceDispatch *flatview_to_dispatch(FlatView *fv) +{ + return fv->dispatch; +} + +static inline AddressSpaceDispatch *address_space_to_dispatch(AddressSpace *as) +{ + return flatview_to_dispatch(address_space_to_flatview(as)); +} extern const MemoryRegionOps unassigned_mem_ops; @@ -30,9 +38,6 @@ bool memory_region_access_valid(MemoryRegion *mr, hwaddr addr, void flatview_add_to_dispatch(FlatView *fv, MemoryRegionSection *section); AddressSpaceDispatch *address_space_dispatch_new(FlatView *fv); void address_space_dispatch_compact(AddressSpaceDispatch *d); - -AddressSpaceDispatch *address_space_to_dispatch(AddressSpace *as); -AddressSpaceDispatch *flatview_to_dispatch(FlatView *fv); void address_space_dispatch_free(AddressSpaceDispatch *d); void mtree_print_dispatch(fprintf_function mon, void *f, diff --git a/include/exec/memory.h b/include/exec/memory.h index 5ed4042f87..ca544027fb 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -318,7 +318,27 @@ struct AddressSpace { QTAILQ_ENTRY(AddressSpace) address_spaces_link; }; -FlatView *address_space_to_flatview(AddressSpace *as); +typedef struct AddressSpaceDispatch AddressSpaceDispatch; +typedef struct FlatRange FlatRange; + +/* Flattened global view of current active memory hierarchy. Kept in sorted + * order. + */ +struct FlatView { + struct rcu_head rcu; + unsigned ref; + FlatRange *ranges; + unsigned nr; + unsigned nr_allocated; + struct AddressSpaceDispatch *dispatch; + MemoryRegion *root; +}; + +static inline FlatView *address_space_to_flatview(AddressSpace *as) +{ + return atomic_rcu_read(&as->current_map); +} + /** * MemoryRegionSection: describes a fragment of a #MemoryRegion diff --git a/memory.c b/memory.c index 226a7e8a2c..b2e23c31f4 100644 --- a/memory.c +++ b/memory.c @@ -210,8 +210,6 @@ static bool memory_region_ioeventfd_equal(MemoryRegionIoeventfd a, && !memory_region_ioeventfd_before(b, a); } -typedef struct FlatRange FlatRange; - /* Range of memory in the global map. Addresses are absolute. */ struct FlatRange { MemoryRegion *mr; @@ -222,19 +220,6 @@ struct FlatRange { bool readonly; }; -/* Flattened global view of current active memory hierarchy. Kept in sorted - * order. - */ -struct FlatView { - struct rcu_head rcu; - unsigned ref; - FlatRange *ranges; - unsigned nr; - unsigned nr_allocated; - struct AddressSpaceDispatch *dispatch; - MemoryRegion *root; -}; - typedef struct AddressSpaceOps AddressSpaceOps; #define FOR_EACH_FLAT_RANGE(var, view) \ @@ -322,21 +307,6 @@ static void flatview_unref(FlatView *view) } } -FlatView *address_space_to_flatview(AddressSpace *as) -{ - return atomic_rcu_read(&as->current_map); -} - -AddressSpaceDispatch *flatview_to_dispatch(FlatView *fv) -{ - return fv->dispatch; -} - -AddressSpaceDispatch *address_space_to_dispatch(AddressSpace *as) -{ - return flatview_to_dispatch(address_space_to_flatview(as)); -} - static bool can_merge(FlatRange *r1, FlatRange *r2) { return int128_eq(addrrange_end(r1->addr), r2->addr.start) From patchwork Tue Jun 19 01:41: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: 931275 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="qltF/cNq"; 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 418s9T4gW5z9s37 for ; Tue, 19 Jun 2018 12:19:41 +1000 (AEST) Received: from localhost ([::1]:38570 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6F9-0001vU-3O for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:19:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45498) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5hj-0001H7-Qp for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5hi-0008C5-PN for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:07 -0400 Received: from mail-ot0-x22b.google.com ([2607:f8b0:4003:c0f::22b]:32863) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5hi-0008Bs-JH; Mon, 18 Jun 2018 21:45:06 -0400 Received: by mail-ot0-x22b.google.com with SMTP id h6-v6so20790079otj.0; Mon, 18 Jun 2018 18:45: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=gRPaLti8UMgv2taMBny9kQjA3jXyjN9CTCd+BOLaWPY=; b=qltF/cNqnx7UHad11qwuxSxurdzdeMoMxWnB5J+/HDPF++6hD8Y7EyRx5Ud0U4ZoKU 53O9bwpS/VxZ+2Q6/YALsqUxsSoJZzaQQm/4y0mtqMltge9Yf0aF+kcVoSOPOHwBcztB dE/D6CTm7EBKTgQSiTKdi7kBD1K7KZx7cxCADYyijtVSG7enf5yb8pWQXwnWAMJD4Jb5 F2YpuizOibj9JWCjmX6yEP8SOwhpoG7USEMmE/LQpXjru1ky1OCVbZlCyNApJtHFIsxm Ecee5Wc/vrLvU1xwKdCzEExPbBUIcKv7k+j/WYy8d95n7ijkXvrEtxmuRHsjXAHM9mLF xAqg== 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=gRPaLti8UMgv2taMBny9kQjA3jXyjN9CTCd+BOLaWPY=; b=ZD4snvdVSVaMbeiMN/hikj5Y7Rkp2waEq0O9JhUL8dS8fyVloL39pOORil5zz/5lME yMn8E2OJdoaQ8nWANUby0ptgYx1H1vfszo+3Ev8qKofdbloKYilSqINZenR/Djl9pc6t M3xe3NfhahyJYz51jc2Fai0IQYbvweEMJtd6zU4qaK3AjZtV7jFDc8i8e0unFKXeIwr9 TM5CWluL3cCy54sbtLjOY4hTRy0UaYiBMzvjNSyweERkR1BNFA9ILokVZL10GnPr3I+B RR9dNKq9ZRLnygYWzGh9xrBRIUptrslITbVMvSgbNeunZehVpZJPPRA0kcqjb7J3OHUx KTzw== X-Gm-Message-State: APt69E3k4atrv6EonJjKmr/C0qHJqqIo3GxNqfCVv1ghxk8PfBplieEO aPQ/dNNc/Ioa3iY+ccswWBdNFyRc X-Google-Smtp-Source: ADUXVKKzJuBOpsYRv3YkniMGX5Gh9AufCdGGZL3FT1mm9MmzW41WxOAs2dGKQA9Oc7B2AQcjeZD0dA== X-Received: by 2002:a9d:368a:: with SMTP id h10-v6mr8603590otc.19.1529372705427; Mon, 18 Jun 2018 18:45: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 x13-v6sm6635938oie.13.2018.06.18.18.45.03 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:45:04 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:41:55 -0500 Message-Id: <20180619014319.28272-30-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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:c0f::22b Subject: [Qemu-devel] [PATCH 029/113] address_space_write: address_space_to_flatview needs RCU 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: Paolo Bonzini , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Paolo Bonzini address_space_write is calling address_space_to_flatview but it can be called outside the RCU lock. To fix it, push the rcu_read_lock/unlock pair up from flatview_write to address_space_write. Reviewed-by: Alexey Kardashevskiy Signed-off-by: Paolo Bonzini (cherry picked from commit 4c6ebbb364aa6f42c5d8e83e932e967eb83f0e44) Signed-off-by: Michael Roth --- exec.c | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/exec.c b/exec.c index 03238a3449..884e243a84 100644 --- a/exec.c +++ b/exec.c @@ -3005,6 +3005,7 @@ static MemTxResult flatview_write_continue(FlatView *fv, hwaddr addr, return result; } +/* Called from RCU critical section. */ static MemTxResult flatview_write(FlatView *fv, hwaddr addr, MemTxAttrs attrs, const uint8_t *buf, int len) { @@ -3013,25 +3014,14 @@ static MemTxResult flatview_write(FlatView *fv, hwaddr addr, MemTxAttrs attrs, MemoryRegion *mr; MemTxResult result = MEMTX_OK; - if (len > 0) { - rcu_read_lock(); - l = len; - mr = flatview_translate(fv, addr, &addr1, &l, true); - result = flatview_write_continue(fv, addr, attrs, buf, len, - addr1, l, mr); - rcu_read_unlock(); - } + l = len; + mr = flatview_translate(fv, addr, &addr1, &l, true); + result = flatview_write_continue(fv, addr, attrs, buf, len, + addr1, l, mr); return result; } -MemTxResult address_space_write(AddressSpace *as, hwaddr addr, - MemTxAttrs attrs, - const uint8_t *buf, int len) -{ - return flatview_write(address_space_to_flatview(as), addr, attrs, buf, len); -} - /* Called within RCU critical section. */ MemTxResult flatview_read_continue(FlatView *fv, hwaddr addr, MemTxAttrs attrs, uint8_t *buf, @@ -3140,6 +3130,23 @@ MemTxResult address_space_rw(AddressSpace *as, hwaddr addr, addr, attrs, buf, len, is_write); } +MemTxResult address_space_write(AddressSpace *as, hwaddr addr, + MemTxAttrs attrs, + const uint8_t *buf, int len) +{ + MemTxResult result = MEMTX_OK; + FlatView *fv; + + if (len > 0) { + rcu_read_lock(); + fv = address_space_to_flatview(as); + result = flatview_write(fv, addr, attrs, buf, len); + rcu_read_unlock(); + } + + return result; +} + void cpu_physical_memory_rw(hwaddr addr, uint8_t *buf, int len, int is_write) { From patchwork Tue Jun 19 01:41: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: 931282 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="GnPx50Ab"; 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 418sJf5Dwcz9s37 for ; Tue, 19 Jun 2018 12:25:53 +1000 (AEST) Received: from localhost ([::1]:38610 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6L8-0006yf-2s for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:25:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45544) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5hl-0001JL-O5 for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5hk-0008DC-J4 for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:09 -0400 Received: from mail-ot0-x22b.google.com ([2607:f8b0:4003:c0f::22b]:41124) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5hk-0008Cu-DD; Mon, 18 Jun 2018 21:45:08 -0400 Received: by mail-ot0-x22b.google.com with SMTP id d19-v6so20756217oti.8; Mon, 18 Jun 2018 18:45: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=GMgzRmin9XaAWYtAvbRrog4EI+qJbdFg8paxzDsOWjY=; b=GnPx50AbIHnT+UBMo6npQjxSYZ9cIx0gkpLnoBsg504igPDYuS90bXCMFpnB+Q7rjl +BpfWViYZ7tzncHVjjg3EqlmLnb0rPOZ9186YZ91vipRN7PPKijuwNHg0zT+5plXhA9o HxqWZKYsmCMRGVRT2QQ6XmwSojF9Jqd4UUhJuAEjUSLQTejrVHA64tJsiQnjF9RAEqmS MXhHYd8fkuZ8qISAGExumnT9udv05Apwckrpxdxw6ChPNj4jcOhFSR4RX+FWSk3SJd77 nlDO5XPa8b7cir9bnearj+d0XWq8PQNaXcQzj80k4P/H/FoGkV+QmoSL1BU1HAoMckA3 mXGQ== 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=GMgzRmin9XaAWYtAvbRrog4EI+qJbdFg8paxzDsOWjY=; b=Nze+P3mfi+znVVWW8gIiSjfZEolr72zXtrCfcOtYgA0jNfoYKO4qObmzr/WI/0p4Jl kcMnVeY+YTgDWXlsTfF9RSFpHfziAs6iUqbNRElihEj/MEsE1sUf0dMky61+40X7mhVo mmS+vBRtwNf7sLkagw9Pi15j64G1dHi82utJ/JhUewqktigouuWDACZtAp4fFI8K8CZl 0mmw/YAy4eoiH/vY0n/JoJKnss9HoeTpZcEUpGdU8Nmestty/R6iE0XqxSYQMpf6oIJf nVEHaZniO0IAv2XM/Wfh/Oj4bPiizEsK6K9fsCwBrQ9ZO1SkReYe7GkXLG6bw5I8Z9MR g+4A== X-Gm-Message-State: APt69E2TjxCWDTwU4JWWOaqv4ICgX9d0tlQz27aYRKZrbhgoTbqjvlWQ BJp4rkbem5Gd49ITcefoGICSu88z X-Google-Smtp-Source: ADUXVKJUzDchx8ZK2whzMXimjVVcJGdEssmQT1uGXEPhbJGjC3xz8pthSpMjFpL01cD1TTUKPXRBCQ== X-Received: by 2002:a9d:542e:: with SMTP id j46-v6mr10297010oth.41.1529372707236; Mon, 18 Jun 2018 18:45: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 97-v6sm7800093oth.15.2018.06.18.18.45.05 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:45:06 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:41:56 -0500 Message-Id: <20180619014319.28272-31-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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:c0f::22b Subject: [Qemu-devel] [PATCH 030/113] address_space_read: address_space_to_flatview needs RCU 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: Paolo Bonzini , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Paolo Bonzini address_space_read is calling address_space_to_flatview but it can be called outside the RCU lock. To fix it, push the rcu_read_lock/unlock pair up from flatview_read_full to address_space_read's constant size fast path and address_space_read_full. Reviewed-by: Alexey Kardashevskiy Signed-off-by: Paolo Bonzini (cherry picked from commit b2a44fcad74f1cc7a6786d38eba7db12ab2352ba) Signed-off-by: Michael Roth --- exec.c | 38 +++++++++++++++++++++++++------------- include/exec/memory.h | 23 +++++++++-------------- 2 files changed, 34 insertions(+), 27 deletions(-) diff --git a/exec.c b/exec.c index 884e243a84..7e3c5c67f0 100644 --- a/exec.c +++ b/exec.c @@ -2575,6 +2575,8 @@ static const MemoryRegionOps watch_mem_ops = { }, }; +static MemTxResult flatview_read(FlatView *fv, hwaddr addr, + MemTxAttrs attrs, uint8_t *buf, int len); static MemTxResult flatview_write(FlatView *fv, hwaddr addr, MemTxAttrs attrs, const uint8_t *buf, int len); static bool flatview_access_valid(FlatView *fv, hwaddr addr, int len, @@ -3092,24 +3094,18 @@ MemTxResult flatview_read_continue(FlatView *fv, hwaddr addr, return result; } -MemTxResult flatview_read_full(FlatView *fv, hwaddr addr, - MemTxAttrs attrs, uint8_t *buf, int len) +/* Called from RCU critical section. */ +static MemTxResult flatview_read(FlatView *fv, hwaddr addr, + MemTxAttrs attrs, uint8_t *buf, int len) { hwaddr l; hwaddr addr1; MemoryRegion *mr; - MemTxResult result = MEMTX_OK; - - if (len > 0) { - rcu_read_lock(); - l = len; - mr = flatview_translate(fv, addr, &addr1, &l, false); - result = flatview_read_continue(fv, addr, attrs, buf, len, - addr1, l, mr); - rcu_read_unlock(); - } - return result; + l = len; + mr = flatview_translate(fv, addr, &addr1, &l, false); + return flatview_read_continue(fv, addr, attrs, buf, len, + addr1, l, mr); } static MemTxResult flatview_rw(FlatView *fv, hwaddr addr, MemTxAttrs attrs, @@ -3130,6 +3126,22 @@ MemTxResult address_space_rw(AddressSpace *as, hwaddr addr, addr, attrs, buf, len, is_write); } +MemTxResult address_space_read_full(AddressSpace *as, hwaddr addr, + MemTxAttrs attrs, uint8_t *buf, int len) +{ + MemTxResult result = MEMTX_OK; + FlatView *fv; + + if (len > 0) { + rcu_read_lock(); + fv = address_space_to_flatview(as); + result = flatview_read(fv, addr, attrs, buf, len); + rcu_read_unlock(); + } + + return result; +} + MemTxResult address_space_write(AddressSpace *as, hwaddr addr, MemTxAttrs attrs, const uint8_t *buf, int len) diff --git a/include/exec/memory.h b/include/exec/memory.h index ca544027fb..e7fdb1b79a 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -1907,13 +1907,12 @@ void address_space_unmap(AddressSpace *as, void *buffer, hwaddr len, /* Internal functions, part of the implementation of address_space_read. */ +MemTxResult address_space_read_full(AddressSpace *as, hwaddr addr, + MemTxAttrs attrs, uint8_t *buf, int len); MemTxResult flatview_read_continue(FlatView *fv, hwaddr addr, MemTxAttrs attrs, uint8_t *buf, int len, hwaddr addr1, hwaddr l, MemoryRegion *mr); - -MemTxResult flatview_read_full(FlatView *fv, hwaddr addr, - MemTxAttrs attrs, uint8_t *buf, int len); void *qemu_map_ram_ptr(RAMBlock *ram_block, ram_addr_t addr); static inline bool memory_access_is_direct(MemoryRegion *mr, bool is_write) @@ -1932,7 +1931,7 @@ static inline bool memory_access_is_direct(MemoryRegion *mr, bool is_write) * * Return a MemTxResult indicating whether the operation succeeded * or failed (eg unassigned memory, device rejected the transaction, - * IOMMU fault). + * IOMMU fault). Called within RCU critical section. * * @as: #AddressSpace to be accessed * @addr: address within that address space @@ -1940,17 +1939,20 @@ static inline bool memory_access_is_direct(MemoryRegion *mr, bool is_write) * @buf: buffer with the data transferred */ static inline __attribute__((__always_inline__)) -MemTxResult flatview_read(FlatView *fv, hwaddr addr, MemTxAttrs attrs, - uint8_t *buf, int len) +MemTxResult address_space_read(AddressSpace *as, hwaddr addr, + MemTxAttrs attrs, uint8_t *buf, + int len) { MemTxResult result = MEMTX_OK; hwaddr l, addr1; void *ptr; MemoryRegion *mr; + FlatView *fv; if (__builtin_constant_p(len)) { if (len) { rcu_read_lock(); + fv = address_space_to_flatview(as); l = len; mr = flatview_translate(fv, addr, &addr1, &l, false); if (len == l && memory_access_is_direct(mr, false)) { @@ -1963,18 +1965,11 @@ MemTxResult flatview_read(FlatView *fv, hwaddr addr, MemTxAttrs attrs, rcu_read_unlock(); } } else { - result = flatview_read_full(fv, addr, attrs, buf, len); + result = address_space_read_full(as, addr, attrs, buf, len); } return result; } -static inline MemTxResult address_space_read(AddressSpace *as, hwaddr addr, - MemTxAttrs attrs, uint8_t *buf, - int len) -{ - return flatview_read(address_space_to_flatview(as), addr, attrs, buf, len); -} - /** * address_space_read_cached: read from a cached RAM region * From patchwork Tue Jun 19 01:41: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: 931284 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="go1ErG8/"; 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 418sM73120z9s37 for ; Tue, 19 Jun 2018 12:28:03 +1000 (AEST) Received: from localhost ([::1]:38624 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6NF-0000HZ-2Y for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:28:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45638) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5hp-0001Px-Ji for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5ho-0008Jd-Mt for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:13 -0400 Received: from mail-oi0-x22d.google.com ([2607:f8b0:4003:c06::22d]:38222) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5ho-0008Iw-Hj; Mon, 18 Jun 2018 21:45:12 -0400 Received: by mail-oi0-x22d.google.com with SMTP id d5-v6so16697294oib.5; Mon, 18 Jun 2018 18:45: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=5JH3eIoeGEoP+GHKl6BWNAD6bBnrrVa66Kqg/80H1BA=; b=go1ErG8//FZJtwk/5ZFUhyqC322nghV4IIh2K6Q1oitAp8tCQ6QKMMHeZjW0Rvk++7 nZBSB0geDrQ0nNUsAe9hHrFKJ6GmKPaRdXg5LbP108gp2P/ayZJ6BWNg+MQ3nlAhi5ah qoI5CSgvkY3aWoN034ZDbEhlIXS0U8hxs76qxz6scokMwcIsddLIJKh8rRvzKnP4Leq8 C99vUXyowx5X0v4AHSjqGJKOMwshTqk6E3bxF3Dmb1AFWVAj1FNuN8sTIR7wUw9AuJK8 EK6tVtgqJud13NbBSjIiQpO/8WGSG0/2IH6/OtUvZJkdNlLFHHNGmCphwvi5wZVsptgv qHSQ== 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=5JH3eIoeGEoP+GHKl6BWNAD6bBnrrVa66Kqg/80H1BA=; b=Mpxr1j4vmaQTbPQhrR8lQhYAIo99S4ALTr3GQX8V6IMCGteD01MQ4mPctF7RLKznYh ruUsOzmXuvJRUyDn8v5/kd6RDCaHoIOBcGQHqpwejpBmk7HHbphYOYs4qSV2fSUSGyzk QALMl+sI3wq1Woj1EjXks7yMugBaeADQltG6xCH6tyUNfYCUr6A4jlEEiUs3yPhaXNIL Lu/HtYi0B7RNp9VALOGJY/rLfVo3cUZ68WiJXGBqj/7TzPXrZEEaLUiWtpgRTa81YITr jabfUfJPF/WMmh7825ztAUkKCjAk4HFOuxf5OzyU8bQ2qvVfGtEZMFy9YUdcfyuqaKKa jqtA== X-Gm-Message-State: APt69E1n84R845x6Z2PJTpDw8k9bKdDoI+owH2GO516+GjHojo7Jyd8H fsmuWnGbObG3tIe8bCvGMYFni2iq X-Google-Smtp-Source: ADUXVKI3w9xZwqJtHZ5OBSDJOWe6/SbLmBsBCFWGRxozTGgOKFSpwcpbjb4bX8LOJgY/PQRJWFVesQ== X-Received: by 2002:aca:5c46:: with SMTP id q67-v6mr7875382oib.17.1529372711308; Mon, 18 Jun 2018 18:45:11 -0700 (PDT) Received: from localhost ([2600:1700:70:e488:b0ee:9bda:ee6f:91be]) by smtp.gmail.com with ESMTPSA id c71-v6sm10092670oig.44.2018.06.18.18.45.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:45:10 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:41:57 -0500 Message-Id: <20180619014319.28272-32-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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 031/113] address_space_access_valid: address_space_to_flatview needs RCU 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: Paolo Bonzini , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Paolo Bonzini address_space_access_valid is calling address_space_to_flatview but it can be called outside the RCU lock. To fix it, push the rcu_read_lock/unlock pair up from flatview_access_valid to address_space_access_valid. Reviewed-by: Alexey Kardashevskiy Signed-off-by: Paolo Bonzini (cherry picked from commit 11e732a5ed46903f997985bed4c3767ca28a7eb6) Signed-off-by: Michael Roth --- exec.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/exec.c b/exec.c index 7e3c5c67f0..7c4fb68368 100644 --- a/exec.c +++ b/exec.c @@ -3322,7 +3322,6 @@ static bool flatview_access_valid(FlatView *fv, hwaddr addr, int len, MemoryRegion *mr; hwaddr l, xlat; - rcu_read_lock(); while (len > 0) { l = len; mr = flatview_translate(fv, addr, &xlat, &l, is_write); @@ -3337,15 +3336,20 @@ static bool flatview_access_valid(FlatView *fv, hwaddr addr, int len, len -= l; addr += l; } - rcu_read_unlock(); return true; } bool address_space_access_valid(AddressSpace *as, hwaddr addr, int len, bool is_write) { - return flatview_access_valid(address_space_to_flatview(as), - addr, len, is_write); + FlatView *fv; + bool result; + + rcu_read_lock(); + fv = address_space_to_flatview(as); + result = flatview_access_valid(fv, addr, len, is_write); + rcu_read_unlock(); + return result; } static hwaddr From patchwork Tue Jun 19 01:41: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: 931285 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="quLfbyN/"; 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 418sMY3cYhz9s37 for ; Tue, 19 Jun 2018 12:28:25 +1000 (AEST) Received: from localhost ([::1]:38625 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6Na-0000aR-Tf for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:28:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45698) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5hr-0001SH-Tl for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5hr-0008Lq-2e for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:15 -0400 Received: from mail-oi0-x235.google.com ([2607:f8b0:4003:c06::235]:43938) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5hq-0008LR-UZ; Mon, 18 Jun 2018 21:45:15 -0400 Received: by mail-oi0-x235.google.com with SMTP id t133-v6so16695364oif.10; Mon, 18 Jun 2018 18:45: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=RFRfs+e+5HIlKSdEH+KaNnrDTCCndMdD1Qd832KxdSs=; b=quLfbyN/Y1MTlmRNYyFAYZGSSnXF6HJY0uodD2tWUEr51tf3cM2zXC1mQfM1TatBEL 0WHYEOzlvaIT9bvhK2urygea1/sOcWJlvm+CpJouiKSN/TdsETY5T/lL8rrDDNDZr/w2 YZMYSbEKhI7kYnaUtecxcJhJgzksOaHbC3WoexpGHbu/NCCc3BR9JIY89GYbNatkqqPo rGrsyZtmQ0gXhLjWcT9WyUzhfMz1szBouzVGc/VfMbfreBVY9+jjPttj/veXXM1BH3oN wQJpIsDTUgNe9Nr4/4Ogsff5J3Uo25WbiSnzz0NpnvDU37GTL0827uz7CxoHkSPsBdVT 9lbg== 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=RFRfs+e+5HIlKSdEH+KaNnrDTCCndMdD1Qd832KxdSs=; b=l4Dp2JcQ343GRI3+fOAwHrYZqun/jyrhuf/5dEirbpqroOPTeQsIwsKL7elEjqVxGU NkoMhq6o/kif0tfDPJpmNPQh3qcpCAwGpBTjoxcZgA8wBKIEGlMVEPRUi9t0rTA05npv SiJm5cgJjOFT85vKLCK0D3OEQcVh/nWRD0KbgRaC7jPn4YbWgfw58OYC4EX+oa/M8Kio CScU3ky2BZC2TQAK52t85U24UeWHMEGQ6XI/YAfv0kh5jnJpxWA3+h3645IHSffv+nB5 BnDTxJnzBB8OxKh8szlJ6fdV2/vw2YWo+KSPNOsK2KEr50vqndcsumwsD9DFfGCoGo+a zyFw== X-Gm-Message-State: APt69E0Mx4MOEWT6rIxwLjdnRb7TJ5jXwbKa3RBWrp/VmAoBFu4AisLt cI2HPESKcpQX4r0e5T4tWSbgrlHG X-Google-Smtp-Source: ADUXVKKO7rfBvrxU/5wLerylo9GsLAOiPqDT0iYIUY6RO0MMp25JJrRhXb6qHbD/qFyETE9ZUtXuuw== X-Received: by 2002:aca:52cb:: with SMTP id g194-v6mr6297797oib.241.1529372713733; Mon, 18 Jun 2018 18:45: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 b4-v6sm7199667otf.79.2018.06.18.18.45.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:45:12 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:41:58 -0500 Message-Id: <20180619014319.28272-33-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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 032/113] address_space_map: address_space_to_flatview needs RCU 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: Paolo Bonzini , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Paolo Bonzini address_space_map is calling address_space_to_flatview but it can be called outside the RCU lock. The function itself is calling rcu_read_lock/rcu_read_unlock, just in the wrong place, so the fix is easy. Reviewed-by: Alexey Kardashevskiy Signed-off-by: Paolo Bonzini (cherry picked from commit ad0c60fa572d4050255b698ecdb67294dd4c0125) Signed-off-by: Michael Roth --- exec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/exec.c b/exec.c index 7c4fb68368..e30155c113 100644 --- a/exec.c +++ b/exec.c @@ -3395,7 +3395,7 @@ void *address_space_map(AddressSpace *as, hwaddr l, xlat; MemoryRegion *mr; void *ptr; - FlatView *fv = address_space_to_flatview(as); + FlatView *fv; if (len == 0) { return NULL; @@ -3403,6 +3403,7 @@ void *address_space_map(AddressSpace *as, l = len; rcu_read_lock(); + fv = address_space_to_flatview(as); mr = flatview_translate(fv, addr, &xlat, &l, is_write); if (!memory_access_is_direct(mr, is_write)) { From patchwork Tue Jun 19 01:41:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 931291 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="h3U/ganJ"; 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 418sS85hYSz9s37 for ; Tue, 19 Jun 2018 12:32:24 +1000 (AEST) Received: from localhost ([::1]:38656 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6RS-0003li-Bt for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:32:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45744) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5hu-0001VD-0O for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5ht-0008N1-01 for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:18 -0400 Received: from mail-oi0-x22e.google.com ([2607:f8b0:4003:c06::22e]:42963) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5hs-0008Mc-RN; Mon, 18 Jun 2018 21:45:16 -0400 Received: by mail-oi0-x22e.google.com with SMTP id k190-v6so16694198oib.9; Mon, 18 Jun 2018 18:45:16 -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=ctdwtVYPNXOTefE+rDLS0xnoZMYx2WO+KiGPzDBrN24=; b=h3U/ganJ7w9fbKiao4+awo0pJzuQAhU+iOooz5Q9mYVizrbroUQzQJRoBaFsz1XH4i Yl1zFDNW+nUJ/e//7ZSfUQj3/WAFB2crskg/2rdmeSCHhopkaTuX5T10T3sc9W5e7ruO TfPUsitViSO9C7aHqZwK17342akWBu3h6LKzvUaOWr+uzi0VPFb5GzWEWxu7/7+DyJ2e 9TsU6s7YBXb8l4XccPclNrcxkeIPzCxuKK3ZmoJwmqTwdekB/kYFuNUYkNHGOJprLN4c IPfPYBbxJ2uDS6dvCgQByvi9Y07aZoK9+FSTYklscMVcXN674Uh8DWtdPVn5v1qLpxT+ rr3w== 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=ctdwtVYPNXOTefE+rDLS0xnoZMYx2WO+KiGPzDBrN24=; b=NNwyndV8Z/oSp3gmkvnzWmR/2xRajPdS4aJbP6ca4m4sxudwNMWKpYJNSOz4NPTobI F3rI+ZxLPzGvs5nMf9XFgd8gHrNYJjmPT5eazGVFtFP7bG80qMtq+th4QF5wiYBjEerV hPGPSRN4CNAIvZ+fIm06IxShh/d/W+qoogl9qLW9yJiavP4Y7L4v0nEAUZKbvxXlNTZ9 a8a0RfJqE45LmBYLIRRhzdTBzObdLG2YlOglozxBIPMqDkC4//N2UVjtTrfuJRUAhTOr kjzrTq0Sbcfai01GOEOro55rPZ2cnyGg+YamsG+bBI0BeLkFawsbQLuJWgwS/f/9Nx/d S19w== X-Gm-Message-State: APt69E3DbBCwCipjd04HM7EutboNbh/8mEiyDkaH+LrxcL7URRyfzgW/ bSlIosYrxJYIyJXFl6iNDiqFRaaU X-Google-Smtp-Source: ADUXVKJ51yflGlgu4CtVJhOEp9b2SJMRj94UPbTI/A1DNnhVNd1zyWJh2VQ8eCMHLkvnlTkAe3qfHw== X-Received: by 2002:aca:e895:: with SMTP id f143-v6mr7893378oih.59.1529372715603; Mon, 18 Jun 2018 18:45: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 o55-v6sm10498467otb.51.2018.06.18.18.45.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:45:14 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:41:59 -0500 Message-Id: <20180619014319.28272-34-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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 033/113] address_space_rw: address_space_to_flatview needs RCU 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: Paolo Bonzini , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Paolo Bonzini address_space_rw is calling address_space_to_flatview but it can be called outside the RCU lock. To fix it, transform flatview_rw into address_space_rw, since flatview_rw is otherwise unused. Reviewed-by: Alexey Kardashevskiy Signed-off-by: Paolo Bonzini (cherry picked from commit db84fd973eba3f1e121416dcab73a4e8a60f2526) Signed-off-by: Michael Roth --- exec.c | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/exec.c b/exec.c index e30155c113..d589283bdd 100644 --- a/exec.c +++ b/exec.c @@ -3108,24 +3108,6 @@ static MemTxResult flatview_read(FlatView *fv, hwaddr addr, addr1, l, mr); } -static MemTxResult flatview_rw(FlatView *fv, hwaddr addr, MemTxAttrs attrs, - uint8_t *buf, int len, bool is_write) -{ - if (is_write) { - return flatview_write(fv, addr, attrs, (uint8_t *)buf, len); - } else { - return flatview_read(fv, addr, attrs, (uint8_t *)buf, len); - } -} - -MemTxResult address_space_rw(AddressSpace *as, hwaddr addr, - MemTxAttrs attrs, uint8_t *buf, - int len, bool is_write) -{ - return flatview_rw(address_space_to_flatview(as), - addr, attrs, buf, len, is_write); -} - MemTxResult address_space_read_full(AddressSpace *as, hwaddr addr, MemTxAttrs attrs, uint8_t *buf, int len) { @@ -3159,6 +3141,16 @@ MemTxResult address_space_write(AddressSpace *as, hwaddr addr, return result; } +MemTxResult address_space_rw(AddressSpace *as, hwaddr addr, MemTxAttrs attrs, + uint8_t *buf, int len, bool is_write) +{ + if (is_write) { + return address_space_write(as, addr, attrs, buf, len); + } else { + return address_space_read_full(as, addr, attrs, buf, len); + } +} + void cpu_physical_memory_rw(hwaddr addr, uint8_t *buf, int len, int is_write) { From patchwork Tue Jun 19 01:42:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 931289 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="TelHXugh"; 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 418sRc1pLYz9s37 for ; Tue, 19 Jun 2018 12:31:56 +1000 (AEST) Received: from localhost ([::1]:38652 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6Qz-0003SA-Qf for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:31:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45783) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5hv-0001Xl-VK for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5hv-0008Nv-64 for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:20 -0400 Received: from mail-ot0-x234.google.com ([2607:f8b0:4003:c0f::234]:40174) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5hv-0008Ni-0q; Mon, 18 Jun 2018 21:45:19 -0400 Received: by mail-ot0-x234.google.com with SMTP id w9-v6so20745241otj.7; Mon, 18 Jun 2018 18:45: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; bh=m9CkoYxnJd1eWUMuB6qHUuNN/6NlP1kLtPCsZwLZ4oI=; b=TelHXugh3BQy+8H5T4ZxBs1zn44Gw2A2uBPVV1hEmAdsS+9L9Looh4Ovz2s/jbNv30 ZdJd4w6/K5jhN8DBqJOke5DbtgYTjg5cxU0KAw39SDPITKduUFeGZY9idB0HS/TYo+Mq ypkQIE8/eUVslQa/fzPOraMGzTOFbef/3mxKtztvfkbXhT0IKiVpdcb+PFoRyl+wekFL 2ySbw9cg9sSJERMXhlwwtx6rybr3Y/I7SmKC2IIDxhWLASvT54JfZDVXDDqqnc31GpZR UU/YqrdurM+Rdy+VdhteXEWDd2QAV3zdqIcQNEbKBC1/YR4SgCLfvCc59XETSTd9gNVj xXVQ== 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=m9CkoYxnJd1eWUMuB6qHUuNN/6NlP1kLtPCsZwLZ4oI=; b=XUr7CFV/UwciRo0RbuOmZkVtCA4dA5w2SlCf4Rv3U/9z1Ii+A4+Ub1R+UZEZ8ZGZLQ lhaLgTtuRZlgnZE7JjrybqBCvHEutWDEWmrPX5UKHK7UUHtvmHJ+FKO7MVz4ha44fpBN LJzWV29jKEaOWC6Yc8Hp97dDWpcUsnvgjtWM/MvX6QRrykdS4w1Vv4LY8nddPDTw6Ikz md2Qf5UOAEfuKY2nyzZcrvzf2/bCNj1XyscmXw/fx+hZRHqIA2GG3xn1Y68t12UF/NXZ RLO7bcUbQTbEYn5XDzrXMSfR6tF1G5fTgs1iLrp0jWmsT/FphYDWc+3C2UN4qdeiRCpF /keQ== X-Gm-Message-State: APt69E0Gu27Nkpunam28h7JRQJJqMFj67JHmM/B7GtuXFmG6td4Aa3c1 6nUdcki9NUQ9qzUXwTf8yKuMkqS0 X-Google-Smtp-Source: ADUXVKKDD2R6kOb9EG1btwIC/eOS04Jlv0M8yecjiTTSlZ++VbIRftCfESzFAh7lRKoKsh/cCiOD1A== X-Received: by 2002:a9d:43aa:: with SMTP id t42-v6mr9717510ote.327.1529372717855; Mon, 18 Jun 2018 18:45:17 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id b63-v6sm7204106oia.4.2018.06.18.18.45.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:45:16 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:00 -0500 Message-Id: <20180619014319.28272-35-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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:c0f::234 Subject: [Qemu-devel] [PATCH 034/113] memory: fix flatview_access_valid RCU read lock/unlock imbalance 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, Peter Maydell Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Paolo Bonzini Fixes: 11e732a5ed46903f997985bed4c3767ca28a7eb6 Reported-by: Cornelia Huck Reported-by: luigi burdo Signed-off-by: Paolo Bonzini Tested-by: Cornelia Huck Tested-by: Thomas Huth Message-id: 20180307130238.19358-1-pbonzini@redhat.com Signed-off-by: Peter Maydell (cherry picked from commit b39b61e410022f96ceb53d4381d25cba5126ac44) Signed-off-by: Michael Roth --- exec.c | 1 - 1 file changed, 1 deletion(-) diff --git a/exec.c b/exec.c index d589283bdd..5f8017a5d7 100644 --- a/exec.c +++ b/exec.c @@ -3320,7 +3320,6 @@ static bool flatview_access_valid(FlatView *fv, hwaddr addr, int len, if (!memory_access_is_direct(mr, is_write)) { l = memory_access_size(mr, l, addr); if (!memory_region_access_valid(mr, xlat, l, is_write)) { - rcu_read_unlock(); return false; } } From patchwork Tue Jun 19 01:42:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 931286 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="V54XbHLW"; 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 418sMy3XNVz9s37 for ; Tue, 19 Jun 2018 12:28:46 +1000 (AEST) Received: from localhost ([::1]:38628 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6Nw-0000tU-4S for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:28:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45806) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5hy-0001a9-Bv for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5hx-0008Og-D5 for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:22 -0400 Received: from mail-oi0-x22e.google.com ([2607:f8b0:4003:c06::22e]:41477) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5hx-0008Oa-83; Mon, 18 Jun 2018 21:45:21 -0400 Received: by mail-oi0-x22e.google.com with SMTP id a141-v6so16693569oii.8; Mon, 18 Jun 2018 18:45: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=N74TcslkdOeXZjJ035p8Cr7MeldxPXEGVyCegfyI7JE=; b=V54XbHLWPVYahT0z0RfpkLY5+ZN3EOKyG6VxGOPweD8LTkoTH7m47yvHWSCtq4Vrsf IyJVzbVNtf3LiWBNyf6RnjV/mvoUh5cM7BHt+viaN1Rzv5Fmy+BN+BxkyjWxCtgjLwu8 NPg7Aoh/UtlC9ahn4NgE8lXLHnQnskvDYqIQmR80MuglK2m1oD45pxX/Unen2jdo3Exd h0fsQVh/SlJ+9fOHXBFjcEqOzqKp+Tw7OwenmeBT1z2D38tgCYqmmBE8Mfmgg0m6sQAa Qj4DekX5WlCFpns5C9wQSmUkeqGI7Q9pZOHUU4ZKmrJlSD97EAxAcrdNsy5CrOWtRurl 4Xag== 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=N74TcslkdOeXZjJ035p8Cr7MeldxPXEGVyCegfyI7JE=; b=oqr/Ihhroy35OxYwP/371I9CJWnSULETpjQyJDV04Q/zv5HpunKirDgOi7lS0VXl7z BCIqSZ4Zj4BIz36ctFpscY1msvq5O1qUi9CRFuhhJvt58BxAM7S6V17FkQz/A3ZQYoaB kelGB4PMZDR6wh3ttZi+hNTZuTLiC8Z86ZId2MlffnUnWExGULGSTXzUhkDMQiFgSMdH 0oFkPYIJcsVmCQvnUYnOy5ThX0KYO70Nft0HAXq2/PoZNfzryPiBPgoh0ZdVbUefU2Wi 3MrarFnKXBvhHHWqWUhxJzjY0a10DvKgkGOrj0d6FXO7kkxxzhzS21dmKMUiiUue8rlK M/Jg== X-Gm-Message-State: APt69E2/lBWREmf8hy4J3oNpA06bgAOSx8dkYBtqPNDcpsczXDCsGpZY oReAIJl+fwRLTEZk/tsCkac4eSA5 X-Google-Smtp-Source: ADUXVKLNJyvU+wspdqOi3iTWn3iM39k1aor3RDC2eRvhACZSAss/yTXRMYtPZkP4PLfZSIsHxv3Rag== X-Received: by 2002:aca:4286:: with SMTP id p128-v6mr7719502oia.242.1529372720111; Mon, 18 Jun 2018 18:45:20 -0700 (PDT) Received: from localhost ([2600:1700:70:e488:b0ee:9bda:ee6f:91be]) by smtp.gmail.com with ESMTPSA id q23-v6sm10133953otd.25.2018.06.18.18.45.18 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:45:19 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:01 -0500 Message-Id: <20180619014319.28272-36-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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 035/113] migration/block: reset dirty bitmap before read in bulk phase 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 Lieven , qemu-stable@nongnu.org, "Dr . David Alan Gilbert" Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Peter Lieven Reset the dirty bitmap before reading to make sure we don't miss any new data. Cc: qemu-stable@nongnu.org Signed-off-by: Peter Lieven Message-Id: <1520507908-16743-3-git-send-email-pl@kamp.de> Reviewed-by: Juan Quintela Signed-off-by: Dr. David Alan Gilbert (cherry picked from commit 86b124bc76bd7137d0fb20696c4e349571b8533d) Signed-off-by: Michael Roth --- migration/block.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/migration/block.c b/migration/block.c index 7147171bb7..7dc13352d8 100644 --- a/migration/block.c +++ b/migration/block.c @@ -331,11 +331,10 @@ static int mig_save_device_bulk(QEMUFile *f, BlkMigDevState *bmds) */ qemu_mutex_lock_iothread(); aio_context_acquire(blk_get_aio_context(bmds->blk)); - blk->aiocb = blk_aio_preadv(bb, cur_sector * BDRV_SECTOR_SIZE, &blk->qiov, - 0, blk_mig_read_cb, blk); - bdrv_reset_dirty_bitmap(bmds->dirty_bitmap, cur_sector * BDRV_SECTOR_SIZE, nr_sectors * BDRV_SECTOR_SIZE); + blk->aiocb = blk_aio_preadv(bb, cur_sector * BDRV_SECTOR_SIZE, &blk->qiov, + 0, blk_mig_read_cb, blk); aio_context_release(blk_get_aio_context(bmds->blk)); qemu_mutex_unlock_iothread(); From patchwork Tue Jun 19 01:42: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: 931292 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="KdFds+yL"; 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 418sWV0y4Zz9s37 for ; Tue, 19 Jun 2018 12:35:18 +1000 (AEST) Received: from localhost ([::1]:38666 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6UF-0005kH-P2 for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:35:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45827) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5i0-0001cQ-Vp for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5hz-0008P3-F3 for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:25 -0400 Received: from mail-oi0-x236.google.com ([2607:f8b0:4003:c06::236]:46063) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5hz-0008Ou-9o; Mon, 18 Jun 2018 21:45:23 -0400 Received: by mail-oi0-x236.google.com with SMTP id 188-v6so16659507oid.12; Mon, 18 Jun 2018 18:45: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=xexEk92pBLmhUh/GHAqJdoJ1+xWn3k2Z1CHYN5qYw5s=; b=KdFds+yLiCJXUnai5smEgwmmHmKED7a8p5/x1yO4/pL689JDSmYBJQHV0QcNqcpo0G 70yuqawQHnp9Zn/iOZV+L1Sp3bdV1cFrx+Kve8j81ySoL7e8hIirzY3L3ZxEQZnchQvL wLWpZyNCtZpWm0qcIKl6WS7yKdahcuHyyUWClMdcOSvSysm4hzgpuOFwC9aIDyEpMKZ1 r6Mxo+eSXmEQxvxHAiiZArMGT3U/HZ1M0o0veD18FhrGaLkVNLMtI3TfWW0F1LofAHBh s8gh+jL0h47eSCWO70UIKIqgZYRESRS0zTQImwouVyxLwHx5EWXygyXuBMJWIdyX4lE1 jx9w== 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=xexEk92pBLmhUh/GHAqJdoJ1+xWn3k2Z1CHYN5qYw5s=; b=Is0iQlkLDgdrwFty2AIN+H8pXcYp+RLA7JKyxwhgk7p+USwZ1GITRCLa4rveLCRAbv 48d7ZYbXoT5tZ2TWkktWaysO40mU5hXO4uyENI2vP6g1QYbPRVV3I8EVarqATW+3+k3H AJ/xuiXHnvcCUJqwJkiANbYOJI0SUm41HV7aEMjbE7lcM/CTJSN7NYAIhe/9x+NfP53E Cj9xFrZp93uJfWnNAP7RWQIZA0Pk3ndOUmqThqUwBpfB6cfLETCAsJUu+QFFyKhdA4B+ AGxwfvYh8RXaePHXOLrpxGfSpqe+HGj2OSs1T0M+tk3xuysRER/vZFz2snySM12Fg/wE 8I1A== X-Gm-Message-State: APt69E2nLnk8d49lx/9Qz70tloZLss7U3C0DfNB6yjgoWGq/TMft/ztJ GF+bP/++YuJfROCP1kO4DaTAybdv X-Google-Smtp-Source: ADUXVKKhC2q1fVLDL4/ymb0YzHvfTa4o0mbrRW5VnsIl/hTVAwR/oPv0siRK36TiTm7Jm/TdJ0Zfvg== X-Received: by 2002:aca:5317:: with SMTP id h23-v6mr7883967oib.90.1529372722161; Mon, 18 Jun 2018 18:45: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 t4-v6sm16637815otd.40.2018.06.18.18.45.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:45:21 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:02 -0500 Message-Id: <20180619014319.28272-37-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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 036/113] multiboot: bss_end_addr can be zero 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, Jack Schwartz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Jack Schwartz The multiboot spec (https://www.gnu.org/software/grub/manual/multiboot/), section 3.1.3, allows for bss_end_addr to be zero. A zero bss_end_addr signifies there is no .bss section. Suggested-by: Daniel Kiper Signed-off-by: Jack Schwartz Reviewed-by: Daniel Kiper Reviewed-by: Prasad J Pandit Signed-off-by: Kevin Wolf (cherry picked from commit 2a8fcd119eb7c6bb3837fc3669eb1b2dfb31daf8) Signed-off-by: Michael Roth --- hw/i386/multiboot.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/hw/i386/multiboot.c b/hw/i386/multiboot.c index c7b70c91d5..ff2733d12e 100644 --- a/hw/i386/multiboot.c +++ b/hw/i386/multiboot.c @@ -233,12 +233,6 @@ int load_multiboot(FWCfgState *fw_cfg, mh_entry_addr = ldl_p(header+i+28); if (mh_load_end_addr) { - if (mh_bss_end_addr < mh_load_addr) { - fprintf(stderr, "invalid mh_bss_end_addr address\n"); - exit(1); - } - mb_kernel_size = mh_bss_end_addr - mh_load_addr; - if (mh_load_end_addr < mh_load_addr) { fprintf(stderr, "invalid mh_load_end_addr address\n"); exit(1); @@ -249,8 +243,16 @@ int load_multiboot(FWCfgState *fw_cfg, fprintf(stderr, "invalid kernel_file_size\n"); exit(1); } - mb_kernel_size = kernel_file_size - mb_kernel_text_offset; - mb_load_size = mb_kernel_size; + mb_load_size = kernel_file_size - mb_kernel_text_offset; + } + if (mh_bss_end_addr) { + if (mh_bss_end_addr < (mh_load_addr + mb_load_size)) { + fprintf(stderr, "invalid mh_bss_end_addr address\n"); + exit(1); + } + mb_kernel_size = mh_bss_end_addr - mh_load_addr; + } else { + mb_kernel_size = mb_load_size; } /* Valid if mh_flags sets MULTIBOOT_HEADER_HAS_VBE. From patchwork Tue Jun 19 01:42:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 931295 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="SZWVwE1g"; 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 418sX175Htz9s37 for ; Tue, 19 Jun 2018 12:35:45 +1000 (AEST) Received: from localhost ([::1]:38671 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6Uh-0006Cu-Kd for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:35:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45862) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5i2-0001eW-SV for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5i2-0008Py-0J for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:26 -0400 Received: from mail-oi0-x22c.google.com ([2607:f8b0:4003:c06::22c]:39400) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5i1-0008Pi-M4; Mon, 18 Jun 2018 21:45:25 -0400 Received: by mail-oi0-x22c.google.com with SMTP id t22-v6so16701129oih.6; Mon, 18 Jun 2018 18:45: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=6gtdG4OxtIdGw9fSnj5OnmzBLmBRifd7LYNW9cLiQWs=; b=SZWVwE1gkpKLhB3bHsw5+66Feb2sNEhxtt2lAC0yEPKlDnaGaMxJAuYzdCck85/88O pfwvDppvxS8QFXyPIfM5yolVbAWer7bHM90MEzrR7HJt2aqTXPy3cL3bcIszv4f0prIY 5lZ6nbY+KgKa4+M1nrAblOEqrJjvDwaM39N1wc9yK78VcjnBQjwukI84c3zWl3bKXUrl dhphZg82yXsp7NDR8jIkdw457Hl9TVn8dJh5RiQ7BFFMpN6e+6xHytYuOuPquLeibjrm 0W6Jr5bwqAfvdcdjHXclnOqjk3rcRIj26IYsb8MAbusEv40I6E06RN/+CjGwXsSazP6F hKdA== 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=6gtdG4OxtIdGw9fSnj5OnmzBLmBRifd7LYNW9cLiQWs=; b=VmMcCUZ9WKa3zRuVT60bmgj/Fyd+sC89UxVGI44jX5C6xnF+P9y08vnz6awcXf28A0 tNXZRfSTjunvNOgwTg6nenEJJXYYm3T9fQsbNfzSmn8GPPRARBlh89RDH+XV/SAqxgvl ON85YWyhVS/JY4kW8YMds2CHRhjcjvZUVATWNS3QL/9QLTh4/bGDNenSJNjbV4yu++Ae FQlJsBEUiGZQ3AS7ryW6x7guH15h8a0v+hZyJktNW1O4Zd0s2h2OS1BfZ1zGFJI6I9WD RMkZ5rPoVmPnSzKr1FV4ayc7JHeWpT7ZGwUH/l18DexHR878zKG4ar0Ps/+4DVNGCWcF VP5w== X-Gm-Message-State: APt69E3cCYEIJVsVXxXeUemCE9we01PT5I9YXNbL5OoGXLypfbpW2x03 X6QvdGKxG4zYkiHnstbCNqzxhvjF X-Google-Smtp-Source: ADUXVKK1iJnIYjXBdzjJb4Ea0TRqFPS8MPG54oB6vQmsvJeKm09r3GFFoK8tdkY3JDroC/6cMQg7GA== X-Received: by 2002:aca:3a45:: with SMTP id h66-v6mr8708283oia.336.1529372724511; Mon, 18 Jun 2018 18:45: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 f53-v6sm11179114otd.80.2018.06.18.18.45.22 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:45:23 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:03 -0500 Message-Id: <20180619014319.28272-38-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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 037/113] multiboot: Remove unused variables from multiboot.c 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, Jack Schwartz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Jack Schwartz Remove unused variables: mh_mode_type, mh_width, mh_height, mh_depth Signed-off-by: Jack Schwartz Reviewed-by: Daniel Kiper Reviewed-by: Prasad J Pandit Signed-off-by: Kevin Wolf (cherry picked from commit 7a2e43cc96fd017883973caf9ee076ae23a3bebd) Signed-off-by: Michael Roth --- hw/i386/multiboot.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/hw/i386/multiboot.c b/hw/i386/multiboot.c index ff2733d12e..964feaf26e 100644 --- a/hw/i386/multiboot.c +++ b/hw/i386/multiboot.c @@ -255,12 +255,6 @@ int load_multiboot(FWCfgState *fw_cfg, mb_kernel_size = mb_load_size; } - /* Valid if mh_flags sets MULTIBOOT_HEADER_HAS_VBE. - uint32_t mh_mode_type = ldl_p(header+i+32); - uint32_t mh_width = ldl_p(header+i+36); - uint32_t mh_height = ldl_p(header+i+40); - uint32_t mh_depth = ldl_p(header+i+44); */ - mb_debug("multiboot: mh_header_addr = %#x\n", mh_header_addr); mb_debug("multiboot: mh_load_addr = %#x\n", mh_load_addr); mb_debug("multiboot: mh_load_end_addr = %#x\n", mh_load_end_addr); From patchwork Tue Jun 19 01:42: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: 931260 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="mWcMA6Kx"; 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 418rs51l1Gz9s2t for ; Tue, 19 Jun 2018 12:05:27 +1000 (AEST) Received: from localhost ([::1]:38485 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV61M-0007mB-CZ for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:05:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45895) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5i5-0001hA-7d for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5i4-0008Qy-8X for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:29 -0400 Received: from mail-ot0-x241.google.com ([2607:f8b0:4003:c0f::241]:36222) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5i3-0008Qk-Ul; Mon, 18 Jun 2018 21:45:28 -0400 Received: by mail-ot0-x241.google.com with SMTP id c15-v6so20777632otl.3; Mon, 18 Jun 2018 18:45:27 -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=/1JMGEGG5vdvuhQ0+7oWLrZYseFp3/5PfumkMqS4NXQ=; b=mWcMA6KxBCtqjTUXaEgMD5mEj9MV+vxSdczQx5RuHK9sicPUP5y5a16UEQrvOF3jj4 EyN0m8XY7fbdQxwnCSKFoeILSJdTcepjtzo4CNCN3TlrLpkXO4n2zn0l3RZV0dOEBV5a +cZHaKKY3Rc+1xwEyaAFbyG5vowrAz58pXlnc790GqE2vbBJXQfN13/3ZTf0TSkZ7SFw MioyR9GsC5W+J97GmJ0KIqqvGYh3JqGXyjaImhIg7K7ylS78wLAtcwy/S9eau7JCL8zv 58nzUNroRo+1ksKGoLPuHSMaelrv+pbTJUj8XBgPDx7qoW6FyadYFl+ao7/2kktlzBaN 955w== 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=/1JMGEGG5vdvuhQ0+7oWLrZYseFp3/5PfumkMqS4NXQ=; b=P2jrdb/MExljQsFjYnPZiSb91vjbh4EhsEUTK23Hsz4H3fsRjpLR5Os9/Xk1f7R5cZ +nh7e+ftWO+bcKmj3xpScLLrlNuHnKFwJwWa+rDCsHNIZ2KWQAHy0T/Nix2ixqcBqGHg xz5IiFaF2NOtVpcgC+//1OSQa7rzYcvg3Iuw7oWs4Ldk145o9Ctnj7Pe/C/EcZER6+A9 vdDkghelr1KYohSUnxR2AHTr+UQHR3JEXiXBQlXwzIIpFks9Cih6UKp27ugtlQnj8ZV0 XcdrTg6KEFNPZppABXDOOkkzLxngxypzoPl/qEEdnxXbkMbViZSPEVdxe5mL3TU1BVlU 2FsA== X-Gm-Message-State: APt69E1m+4YQ5LAlQP4f6s42VSIMEEdBaC/kQWpaJ2O2FcAQitK3deRF 3nZ2vBZjn41Sg8Ie12u/JtllX8tX X-Google-Smtp-Source: ADUXVKLdHjYoE2WtZrk6GZmytldaqoEyW/fNP7GF33Q12diIZ87AyFveMuU9Y8tuq1iOyPY2pcxZXQ== X-Received: by 2002:a9d:300d:: with SMTP id d13-v6mr9892577otc.103.1529372726750; Mon, 18 Jun 2018 18:45: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 m62-v6sm7708135otc.71.2018.06.18.18.45.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:45:25 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:04 -0500 Message-Id: <20180619014319.28272-39-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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:c0f::241 Subject: [Qemu-devel] [PATCH 038/113] multiboot: Use header names when displaying fields 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, Jack Schwartz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Jack Schwartz Refer to field names when displaying fields in printf and debug statements. Signed-off-by: Jack Schwartz Reviewed-by: Daniel Kiper Signed-off-by: Kevin Wolf (cherry picked from commit ce5eb6dc4dc5652f7e360a1db817f1d5dafab90f) Signed-off-by: Michael Roth --- hw/i386/multiboot.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/hw/i386/multiboot.c b/hw/i386/multiboot.c index 964feaf26e..818728bdf8 100644 --- a/hw/i386/multiboot.c +++ b/hw/i386/multiboot.c @@ -224,7 +224,7 @@ int load_multiboot(FWCfgState *fw_cfg, mh_load_addr = ldl_p(header+i+16); if (mh_header_addr < mh_load_addr) { - fprintf(stderr, "invalid mh_load_addr address\n"); + fprintf(stderr, "invalid load_addr address\n"); exit(1); } @@ -234,7 +234,7 @@ int load_multiboot(FWCfgState *fw_cfg, if (mh_load_end_addr) { if (mh_load_end_addr < mh_load_addr) { - fprintf(stderr, "invalid mh_load_end_addr address\n"); + fprintf(stderr, "invalid load_end_addr address\n"); exit(1); } mb_load_size = mh_load_end_addr - mh_load_addr; @@ -247,7 +247,7 @@ int load_multiboot(FWCfgState *fw_cfg, } if (mh_bss_end_addr) { if (mh_bss_end_addr < (mh_load_addr + mb_load_size)) { - fprintf(stderr, "invalid mh_bss_end_addr address\n"); + fprintf(stderr, "invalid bss_end_addr address\n"); exit(1); } mb_kernel_size = mh_bss_end_addr - mh_load_addr; @@ -255,10 +255,10 @@ int load_multiboot(FWCfgState *fw_cfg, mb_kernel_size = mb_load_size; } - mb_debug("multiboot: mh_header_addr = %#x\n", mh_header_addr); - mb_debug("multiboot: mh_load_addr = %#x\n", mh_load_addr); - mb_debug("multiboot: mh_load_end_addr = %#x\n", mh_load_end_addr); - mb_debug("multiboot: mh_bss_end_addr = %#x\n", mh_bss_end_addr); + mb_debug("multiboot: header_addr = %#x\n", mh_header_addr); + mb_debug("multiboot: load_addr = %#x\n", mh_load_addr); + mb_debug("multiboot: load_end_addr = %#x\n", mh_load_end_addr); + mb_debug("multiboot: bss_end_addr = %#x\n", mh_bss_end_addr); mb_debug("qemu: loading multiboot kernel (%#x bytes) at %#x\n", mb_load_size, mh_load_addr); @@ -361,7 +361,7 @@ int load_multiboot(FWCfgState *fw_cfg, stl_p(bootinfo + MBI_BOOT_DEVICE, 0x8000ffff); /* XXX: use the -boot switch? */ stl_p(bootinfo + MBI_MMAP_ADDR, ADDR_E820_MAP); - mb_debug("multiboot: mh_entry_addr = %#x\n", mh_entry_addr); + mb_debug("multiboot: entry_addr = %#x\n", mh_entry_addr); mb_debug(" mb_buf_phys = "TARGET_FMT_plx"\n", mbs.mb_buf_phys); mb_debug(" mod_start = "TARGET_FMT_plx"\n", mbs.mb_buf_phys + mbs.offset_mods); mb_debug(" mb_mods_count = %d\n", mbs.mb_mods_count); From patchwork Tue Jun 19 01:42: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: 931263 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="mI0xt7gT"; 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 418rx22wR4z9s19 for ; Tue, 19 Jun 2018 12:08:54 +1000 (AEST) Received: from localhost ([::1]:38503 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV64i-0001lP-0Q for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:08:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45932) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5i7-0001j4-TZ for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5i6-0008Rb-AC for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:31 -0400 Received: from mail-oi0-x231.google.com ([2607:f8b0:4003:c06::231]:41480) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5i6-0008RN-2n; Mon, 18 Jun 2018 21:45:30 -0400 Received: by mail-oi0-x231.google.com with SMTP id a141-v6so16693765oii.8; Mon, 18 Jun 2018 18:45:29 -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=yQujSyrP+o5vviIFx8FFFNYs2QJFyViQZ28Byt3zhGE=; b=mI0xt7gTHGWUl1XuhTLdrvfVN75mNm7V8NOwgTBN61FYScdoYhwKs7uGo0vXyJW1LM ZxA8ywByHGCF8xFbaXkt51EN95jpOCZwLhFXzRs5ZoZGOlJrS0eC/vfpsor47ua90qUu desVtXKHNSvZ5ujtvPaMr9DGxbLExFZi80DhBQ+AE1KeTSTthDDhqeY0xJWq4lGSPBP0 x/aPcyDiAMH5fEUJGswkoGGevaAEc+eCSvl4aOinlRo2PZ4zr5o8RX02CFjuA3lTvlWi P9XzZx3m6+bKGOc3tsRq2gsITIQpdnEqxziq6Kg3UEh1AaB6KbySUejqP4WuCsFxurhE bR6Q== 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=yQujSyrP+o5vviIFx8FFFNYs2QJFyViQZ28Byt3zhGE=; b=F4byyJCWasr9mcwGkb68ITu/4YK/w/6Q+AgJki9SFsl66bwjV6duQGsJ4kb6fmWKQw dgQjRK6O4E+32RKLMBPiBNrYavNNeo/N02CeGNStOVHcH8/GUuDk7O5+wKPZBdpSh/aZ 4kubFuCwTtv0A2Hdp0IGwjjVs5tfITFDIP+6++gIgb3dL/Ox75pGtUyUyHzon7cqOOeI nV8hqi7XHrGPIpbE8L35gaMicELGF1ThvHTQN9SNPY79YjV+JPIB3sr7g5e8OLqb8Mu8 R7Ew7dmde+yHbG1kBFyyJy0l2bgOYtms+dWS6lpqDx3RCvhLrcmX8DOKmjlUN2IwY62v GhEA== X-Gm-Message-State: APt69E3uZm4k7dyvHqloNZILWleI51s4/c49fx+Ha3Bq/HZxkrMUp5tg DO+FmdGcpXhX3/N5OJVhlTl4y3QX X-Google-Smtp-Source: ADUXVKJOVZAFX0S+whvcgygIWcsRjG4XOiRyRM2DkYyPLw+CjYktdVHgChEd0Q1BnuOojrKsAFH8AQ== X-Received: by 2002:aca:3c07:: with SMTP id j7-v6mr8617177oia.13.1529372728691; Mon, 18 Jun 2018 18:45:28 -0700 (PDT) Received: from localhost ([2600:1700:70:e488:b0ee:9bda:ee6f:91be]) by smtp.gmail.com with ESMTPSA id a202-v6sm8674877oib.28.2018.06.18.18.45.27 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:45:27 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:05 -0500 Message-Id: <20180619014319.28272-40-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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 039/113] multiboot: fprintf(stderr...) -> error_report() 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, Jack Schwartz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Jack Schwartz Change all fprintf(stderr...) calls in hw/i386/multiboot.c to call error_report() instead, including the mb_debug macro. Remove the "\n" from strings passed to all modified calls, since error_report() appends one. Signed-off-by: Jack Schwartz Reviewed-by: Daniel Kiper Signed-off-by: Kevin Wolf (cherry picked from commit 4b9006a41ea8818f2385ae5228e07f211bb4a33d) Signed-off-by: Michael Roth --- hw/i386/multiboot.c | 55 ++++++++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/hw/i386/multiboot.c b/hw/i386/multiboot.c index 818728bdf8..d9a0a95a2f 100644 --- a/hw/i386/multiboot.c +++ b/hw/i386/multiboot.c @@ -31,12 +31,13 @@ #include "hw/loader.h" #include "elf.h" #include "sysemu/sysemu.h" +#include "qemu/error-report.h" /* Show multiboot debug output */ //#define DEBUG_MULTIBOOT #ifdef DEBUG_MULTIBOOT -#define mb_debug(a...) fprintf(stderr, ## a) +#define mb_debug(a...) error_report(a) #else #define mb_debug(a...) #endif @@ -137,7 +138,7 @@ static void mb_add_mod(MultibootState *s, stl_p(p + MB_MOD_END, end); stl_p(p + MB_MOD_CMDLINE, cmdline_phys); - mb_debug("mod%02d: "TARGET_FMT_plx" - "TARGET_FMT_plx"\n", + mb_debug("mod%02d: "TARGET_FMT_plx" - "TARGET_FMT_plx, s->mb_mods_count, start, end); s->mb_mods_count++; @@ -179,12 +180,12 @@ int load_multiboot(FWCfgState *fw_cfg, if (!is_multiboot) return 0; /* no multiboot */ - mb_debug("qemu: I believe we found a multiboot image!\n"); + mb_debug("qemu: I believe we found a multiboot image!"); memset(bootinfo, 0, sizeof(bootinfo)); memset(&mbs, 0, sizeof(mbs)); if (flags & 0x00000004) { /* MULTIBOOT_HEADER_HAS_VBE */ - fprintf(stderr, "qemu: multiboot knows VBE. we don't.\n"); + error_report("qemu: multiboot knows VBE. we don't."); } if (!(flags & 0x00010000)) { /* MULTIBOOT_HEADER_HAS_ADDR */ uint64_t elf_entry; @@ -193,7 +194,7 @@ int load_multiboot(FWCfgState *fw_cfg, fclose(f); if (((struct elf64_hdr*)header)->e_machine == EM_X86_64) { - fprintf(stderr, "Cannot load x86-64 image, give a 32bit one.\n"); + error_report("Cannot load x86-64 image, give a 32bit one."); exit(1); } @@ -201,7 +202,7 @@ int load_multiboot(FWCfgState *fw_cfg, &elf_low, &elf_high, 0, I386_ELF_MACHINE, 0, 0); if (kernel_size < 0) { - fprintf(stderr, "Error while loading elf kernel\n"); + error_report("Error while loading elf kernel"); exit(1); } mh_load_addr = elf_low; @@ -210,12 +211,13 @@ int load_multiboot(FWCfgState *fw_cfg, mbs.mb_buf = g_malloc(mb_kernel_size); if (rom_copy(mbs.mb_buf, mh_load_addr, mb_kernel_size) != mb_kernel_size) { - fprintf(stderr, "Error while fetching elf kernel from rom\n"); + error_report("Error while fetching elf kernel from rom"); exit(1); } - mb_debug("qemu: loading multiboot-elf kernel (%#x bytes) with entry %#zx\n", - mb_kernel_size, (size_t)mh_entry_addr); + mb_debug("qemu: loading multiboot-elf kernel " + "(%#x bytes) with entry %#zx", + mb_kernel_size, (size_t)mh_entry_addr); } else { /* Valid if mh_flags sets MULTIBOOT_HEADER_HAS_ADDR. */ uint32_t mh_header_addr = ldl_p(header+i+12); @@ -224,7 +226,7 @@ int load_multiboot(FWCfgState *fw_cfg, mh_load_addr = ldl_p(header+i+16); if (mh_header_addr < mh_load_addr) { - fprintf(stderr, "invalid load_addr address\n"); + error_report("invalid load_addr address"); exit(1); } @@ -234,20 +236,20 @@ int load_multiboot(FWCfgState *fw_cfg, if (mh_load_end_addr) { if (mh_load_end_addr < mh_load_addr) { - fprintf(stderr, "invalid load_end_addr address\n"); + error_report("invalid load_end_addr address"); exit(1); } mb_load_size = mh_load_end_addr - mh_load_addr; } else { if (kernel_file_size < mb_kernel_text_offset) { - fprintf(stderr, "invalid kernel_file_size\n"); + error_report("invalid kernel_file_size"); exit(1); } mb_load_size = kernel_file_size - mb_kernel_text_offset; } if (mh_bss_end_addr) { if (mh_bss_end_addr < (mh_load_addr + mb_load_size)) { - fprintf(stderr, "invalid bss_end_addr address\n"); + error_report("invalid bss_end_addr address"); exit(1); } mb_kernel_size = mh_bss_end_addr - mh_load_addr; @@ -255,17 +257,17 @@ int load_multiboot(FWCfgState *fw_cfg, mb_kernel_size = mb_load_size; } - mb_debug("multiboot: header_addr = %#x\n", mh_header_addr); - mb_debug("multiboot: load_addr = %#x\n", mh_load_addr); - mb_debug("multiboot: load_end_addr = %#x\n", mh_load_end_addr); - mb_debug("multiboot: bss_end_addr = %#x\n", mh_bss_end_addr); - mb_debug("qemu: loading multiboot kernel (%#x bytes) at %#x\n", + mb_debug("multiboot: header_addr = %#x", mh_header_addr); + mb_debug("multiboot: load_addr = %#x", mh_load_addr); + mb_debug("multiboot: load_end_addr = %#x", mh_load_end_addr); + mb_debug("multiboot: bss_end_addr = %#x", mh_bss_end_addr); + mb_debug("qemu: loading multiboot kernel (%#x bytes) at %#x", mb_load_size, mh_load_addr); mbs.mb_buf = g_malloc(mb_kernel_size); fseek(f, mb_kernel_text_offset, SEEK_SET); if (fread(mbs.mb_buf, 1, mb_load_size, f) != mb_load_size) { - fprintf(stderr, "fread() failed\n"); + error_report("fread() failed"); exit(1); } memset(mbs.mb_buf + mb_load_size, 0, mb_kernel_size - mb_load_size); @@ -319,10 +321,10 @@ int load_multiboot(FWCfgState *fw_cfg, hwaddr c = mb_add_cmdline(&mbs, tmpbuf); if ((next_space = strchr(tmpbuf, ' '))) *next_space = '\0'; - mb_debug("multiboot loading module: %s\n", tmpbuf); + mb_debug("multiboot loading module: %s", tmpbuf); mb_mod_length = get_image_size(tmpbuf); if (mb_mod_length < 0) { - fprintf(stderr, "Failed to open file '%s'\n", tmpbuf); + error_report("Failed to open file '%s'", tmpbuf); exit(1); } @@ -333,7 +335,7 @@ int load_multiboot(FWCfgState *fw_cfg, mb_add_mod(&mbs, mbs.mb_buf_phys + offs, mbs.mb_buf_phys + offs + mb_mod_length, c); - mb_debug("mod_start: %p\nmod_end: %p\n cmdline: "TARGET_FMT_plx"\n", + mb_debug("mod_start: %p\nmod_end: %p\n cmdline: "TARGET_FMT_plx, (char *)mbs.mb_buf + offs, (char *)mbs.mb_buf + offs + mb_mod_length, c); initrd_filename = next_initrd+1; @@ -361,10 +363,11 @@ int load_multiboot(FWCfgState *fw_cfg, stl_p(bootinfo + MBI_BOOT_DEVICE, 0x8000ffff); /* XXX: use the -boot switch? */ stl_p(bootinfo + MBI_MMAP_ADDR, ADDR_E820_MAP); - mb_debug("multiboot: entry_addr = %#x\n", mh_entry_addr); - mb_debug(" mb_buf_phys = "TARGET_FMT_plx"\n", mbs.mb_buf_phys); - mb_debug(" mod_start = "TARGET_FMT_plx"\n", mbs.mb_buf_phys + mbs.offset_mods); - mb_debug(" mb_mods_count = %d\n", mbs.mb_mods_count); + mb_debug("multiboot: entry_addr = %#x", mh_entry_addr); + mb_debug(" mb_buf_phys = "TARGET_FMT_plx, mbs.mb_buf_phys); + mb_debug(" mod_start = "TARGET_FMT_plx, + mbs.mb_buf_phys + mbs.offset_mods); + mb_debug(" mb_mods_count = %d", mbs.mb_mods_count); /* save bootinfo off the stack */ mb_bootinfo_data = g_memdup(bootinfo, sizeof(bootinfo)); From patchwork Tue Jun 19 01:42: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: 931293 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="drUsXowK"; 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 418sWX4qdQz9s37 for ; Tue, 19 Jun 2018 12:35:20 +1000 (AEST) Received: from localhost ([::1]:38667 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6UI-0005mr-Ah for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:35:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45998) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5iB-0001mp-Hc for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5i8-0008SU-Fb for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:35 -0400 Received: from mail-oi0-x232.google.com ([2607:f8b0:4003:c06::232]:32789) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5i8-0008S9-74; Mon, 18 Jun 2018 21:45:32 -0400 Received: by mail-oi0-x232.google.com with SMTP id c6-v6so16699574oiy.0; Mon, 18 Jun 2018 18:45: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=wblhaoia/wIA4S+Lvax8kQx5mbt+4ozrhGYexmgT32I=; b=drUsXowKil3WtXiDyPN0XYfQUwiqrcTDolae2VN47342iGq2BXA56r3+uMQBIwvZw0 JctMUwKDJIFmtHDWPkk+Th+gNWpsXUZWCbIGfWmrCtKJ/2ytnbNxCQ4aNaBpMoFHc4Gh 0BDF55hhpOwjAOrIkQ5fYfIg5T0FX1xzeUdDfJK1MTPqEoOHfvcrbZti2KsHa1MpiSCf X0fVhda4VwM5fElbmw1RWxc2BLAGSRgwmB8dOd/SWw7GGd5Q1LoJaaDHmixOGlt8u5uP iHyBn8wfcP0mMYJozgNwDk/KzwfpGFc7VOVlfqMNsK37W8bVzTqdijIUrGPN0gvyLxiU 3vEQ== 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=wblhaoia/wIA4S+Lvax8kQx5mbt+4ozrhGYexmgT32I=; b=jP4DamT/yFxIgBEdPsm6iT+AAIhU/AsZdDXzfFt8mBFTN1INfG7uJuIgbCAwQU1i6/ 9aFD/m7fy4wJV0nLaTQqzIiZtkeSt3em+IvuuieHq78ZuVLNI5qlPYNGbybvIiYk7Iwb iQc/LjgFD/9MI46o/VXEdl8Mc04l2hoyPjJ6kiZWBOmK8ihS+u9StEDekgo4+l/eGqNg JF05nhT+5LEV2/8SwbinfJ+o2AJs8dmFPmgI/kc7p9x3CBNeYNxMT+yF7lS9S9WvYIPQ kbdcxZ0bMVrp/Gz7r14gzxhDDgyQ/d4aH9Sq9x68bm7w9RZy6fGnAAXrWBvOKxKlLZTn APtg== X-Gm-Message-State: APt69E1cxDjo5pPIe9SkxZAVakhj2vX/WJmVjfL79EYEXmsKC99yYWuk ONV2fgSOjrNcxAogiObQ3rQZwCpo X-Google-Smtp-Source: ADUXVKIdBpf7lUFP3K0J2vvQVO78btVEbkESQLbblO7A4I5ruZjaaPCgkfTwVTEnmshaKgFD9r2qeg== X-Received: by 2002:aca:f505:: with SMTP id t5-v6mr8658039oih.62.1529372731044; Mon, 18 Jun 2018 18:45: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 m17-v6sm7400634otk.1.2018.06.18.18.45.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:45:29 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:06 -0500 Message-Id: <20180619014319.28272-41-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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 040/113] multiboot: Reject kernels exceeding the address space 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: Kevin Wolf The code path where mh_load_end_addr is non-zero in the Multiboot header checks that mh_load_end_addr >= mh_load_addr and so mb_load_size is checked. However, mb_load_size is not checked when calculated from the file size, when mh_load_end_addr is 0. If the kernel binary size is larger than can fit in the address space after load_addr, we ended up with a kernel_size that is smaller than load_size, which means that we read the file into a too small buffer. Add a check to reject kernel files with such Multiboot headers. Signed-off-by: Kevin Wolf Reviewed-by: Jack Schwartz (cherry picked from commit b17a9054a0652a1481be48a6729e972abf02412f) Signed-off-by: Michael Roth --- hw/i386/multiboot.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/i386/multiboot.c b/hw/i386/multiboot.c index d9a0a95a2f..775aa5bfd0 100644 --- a/hw/i386/multiboot.c +++ b/hw/i386/multiboot.c @@ -247,6 +247,10 @@ int load_multiboot(FWCfgState *fw_cfg, } mb_load_size = kernel_file_size - mb_kernel_text_offset; } + if (mb_load_size > UINT32_MAX - mh_load_addr) { + error_report("kernel does not fit in address space"); + exit(1); + } if (mh_bss_end_addr) { if (mh_bss_end_addr < (mh_load_addr + mb_load_size)) { error_report("invalid bss_end_addr address"); From patchwork Tue Jun 19 01:42: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: 931299 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="RWjOyI47"; 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 418scP2Wrdz9s47 for ; Tue, 19 Jun 2018 12:39:33 +1000 (AEST) Received: from localhost ([::1]:38694 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6YM-0000vY-UH for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:39:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46040) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5iD-0001op-Ln for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5iC-0008Uk-Ph for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:37 -0400 Received: from mail-oi0-x242.google.com ([2607:f8b0:4003:c06::242]:37844) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5iC-0008UM-HN; Mon, 18 Jun 2018 21:45:36 -0400 Received: by mail-oi0-x242.google.com with SMTP id l22-v6so16716725oib.4; Mon, 18 Jun 2018 18:45:36 -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=0oMUUDZxgzt3qvP1ddMk+6f5+GmCX/2z7+IJItyg+ws=; b=RWjOyI47Cznnh9PWM+IYd4YNM5RLonvFxhjOYRXvhIprl0MfI7RIWaBuOLO/qLJo6p JQCQrnQXyiZJyCTh2WOD5ZeKzmdiMg4p0+Als8Hfqrf8ACW/fNVldMf4Tg37SbEKzbak hscFU63uY1H+YJrL/6ovT69kqEuygddz4hSuEDiX/InJVsxhRnDiySrixKBCZyFLVGPv n1mfDMIrpdsGjTQ3BbdajdRgG2shvzjArFiNhOnkJQO6SI3yxS+F5XYPceCQFULD6IE9 fq7/d00MFo7O8FI3/vjO4W/pVVAnzDM9GXThhwIy7emGW3u/EvX/2InWkWgpJzrmUJq7 ER0A== 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=0oMUUDZxgzt3qvP1ddMk+6f5+GmCX/2z7+IJItyg+ws=; b=VhFXFlW/K8cHwRCidN3xeXAlsRDmLg0+2XYr++UBSyGHbSts1cQpgmrTMR3AJD7IEk MG/4kl9taCzHC+zN56cLBvhOdR+l1k4rScOYG/vSSj0+pgEZ4vNZC0Rfy8C9kGorCHVJ oPJhzcaOKrrSAgL0TdFfGJl/CzuGRy5rg4J8w1thn9EdjDiiYblWP5Nk3YOM8FR3/ap4 VMWmMVNLMPxh8kOote2nUZLcuU7OrZdwtTh0XB+hhk9+zGkJ0HCcf2LJEcQ0eQfjzaIL FixmuCIwCf8GHo5qbkBe2opQ3WZWOcR6F6odJCPw+/XsZ/RYlixNtirZU1+lQqJ77ybF GcJQ== X-Gm-Message-State: APt69E1Irn/12m24RPo0IgoMzauS9h0lAzDovSkyvsIn04BEExTwstFU id2YgqkjsPQmAHaXtbY50tqGg1b1 X-Google-Smtp-Source: ADUXVKLC5dNFbt6vvSYBvc5pXvNW1n+RQY9mpUZM11lCgkN6xFrVY9RcmS5hJoS3tlFgB1hZ8CQJQw== X-Received: by 2002:aca:38c3:: with SMTP id f186-v6mr7631623oia.310.1529372735284; Mon, 18 Jun 2018 18:45:35 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id v8-v6sm16545365oti.35.2018.06.18.18.45.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:45:34 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:07 -0500 Message-Id: <20180619014319.28272-42-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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 041/113] multiboot: Check validity of mh_header_addr 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: Kevin Wolf I couldn't find a case where this prevents something bad from happening that isn't already caught by other checks, but let's err on the safe side and check that mh_header_addr is as expected. Signed-off-by: Kevin Wolf Reviewed-by: Jack Schwartz (cherry picked from commit dbf2dce7aabb7723542bd182175904846d70b0f9) Signed-off-by: Michael Roth --- hw/i386/multiboot.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/i386/multiboot.c b/hw/i386/multiboot.c index 775aa5bfd0..36b22832cd 100644 --- a/hw/i386/multiboot.c +++ b/hw/i386/multiboot.c @@ -229,6 +229,10 @@ int load_multiboot(FWCfgState *fw_cfg, error_report("invalid load_addr address"); exit(1); } + if (mh_header_addr - mh_load_addr > i) { + error_report("invalid header_addr address"); + exit(1); + } uint32_t mb_kernel_text_offset = i - (mh_header_addr - mh_load_addr); uint32_t mb_load_size = 0; From patchwork Tue Jun 19 01:42: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: 931267 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="hmaF9A8M"; 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 418s103YYnz9s2t for ; Tue, 19 Jun 2018 12:12:20 +1000 (AEST) Received: from localhost ([::1]:38528 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV682-0004jd-3E for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:12:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46071) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5iF-0001r6-Qf for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5iE-0008Vf-S0 for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:39 -0400 Received: from mail-ot0-x244.google.com ([2607:f8b0:4003:c0f::244]:45057) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5iE-0008VR-MN; Mon, 18 Jun 2018 21:45:38 -0400 Received: by mail-ot0-x244.google.com with SMTP id a5-v6so20750620otf.12; Mon, 18 Jun 2018 18:45:38 -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=GDyfM38TQW5Xy2ju0B4VuATfn5l8mJ1uu4AqsAueG/Y=; b=hmaF9A8MedBRI1HI3O92IRa28qPhiTiFfEb6NRYqs6eRCBWCgu++wX4nK+nfOSj4DP kPw6brz4TOqdNLN9GsTctUnTBtJcz1Dd1yj6idkPxhqnlnpNNxeOv/7Oa2ak8ZZFPiUJ 3e9MXdZ2OcqRxnc60K9nJEOkS7ubn+mTsswHPiin8YP/ssqbjgOA7dRSu4XBd+plbkHQ PQghmhXePM6jY08tr+8lrqBoR6pnokQuSD7MHAfJD8hyhFcUMj3AUViyM4eV96cG5pN2 JxvI4f4PuBoIulPrIY7VYNRnNJlX+98IAfhgwt+YrFw2sA7XKuow2Nlu/I+HSA1KPVzw JRAw== 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=GDyfM38TQW5Xy2ju0B4VuATfn5l8mJ1uu4AqsAueG/Y=; b=uHfXZ5Z5mjCSo+SUm/3i4q1hgIm+kjWVeBFt50qUpymwbc6rpjFjs6aw4YD/gwfXXO L1ImpRAgLOa+KHvSA4GV/DGMKpFfGSlSdqICyVg0iJhXt9mbYsmIkQ3t45gImNwTNmNt Q8YvwRbihQrs5m3AeAJE21Zn0zmoMyMC9joYkVJdjZ1bsI+Db1V8jbq/UeLjpQtskaR8 Ms/R66PqG6yTXLmwtnAjwMIfSLMUi6+yU1ASMURIAP53SXqx9JKKeou21M9udOOpUS5z ryStC2xi+k0nJ6ZdrBRi18mfo49HcHd1zrSsBTwK9wzzpWJ0umUlqCf2luI6HuORUKaC JMYA== X-Gm-Message-State: APt69E1TFnVOajf/QZR9Gn+7H6CX8JV4zUlP31UVV4iEvc53O3Y6Nstf aAVPMTr1MENig93he8xeJJ1gKV89 X-Google-Smtp-Source: ADUXVKI8CNPuqw8zy3yomej+OFgxzugYAQmoLzktaq0hD7jAAAGBidBvCIiEqKSf6098EY5Mdbo/EQ== X-Received: by 2002:a9d:3866:: with SMTP id r35-v6mr9960117otd.329.1529372737522; Mon, 18 Jun 2018 18:45:37 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id f53-v6sm11179828otd.80.2018.06.18.18.45.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:45:36 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:08 -0500 Message-Id: <20180619014319.28272-43-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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:c0f::244 Subject: [Qemu-devel] [PATCH 042/113] tests/multiboot: Test exit code for every qemu run 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: Kevin Wolf Testing the exit code only once after a whole group of tests has completed is not enough, it catches errors only in the very last qemu invocation. We need to have the check after each qemu run. The logging and diff with the reference output is still done once per group to keep things more managable. This is not a problem because the log file accumulates the output of all runs. Signed-off-by: Kevin Wolf Reviewed-by: Jack Schwartz (cherry picked from commit 49713c413a65ab4b02124aabe83f8539cc6ece5e) Signed-off-by: Michael Roth --- tests/multiboot/run_test.sh | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/multiboot/run_test.sh b/tests/multiboot/run_test.sh index 0278148b43..bc9c3670af 100755 --- a/tests/multiboot/run_test.sh +++ b/tests/multiboot/run_test.sh @@ -38,6 +38,17 @@ run_qemu() { ret=$? cat test.out >> test.log + + debugexit=$((ret & 0x1)) + ret=$((ret >> 1)) + + if [ $debugexit != 1 ]; then + printf %b "\e[31m ?? \e[0m $kernel $* (no debugexit used, exit code $ret)\n" + pass=0 + elif [ $ret != 0 ]; then + printf %b "\e[31mFAIL\e[0m $kernel $* (exit code $ret)\n" + pass=0 + fi } mmap() { @@ -61,19 +72,8 @@ make all for t in mmap modules; do echo > test.log - $t - - debugexit=$((ret & 0x1)) - ret=$((ret >> 1)) pass=1 - - if [ $debugexit != 1 ]; then - printf %b "\e[31m ?? \e[0m $t (no debugexit used, exit code $ret)\n" - pass=0 - elif [ $ret != 0 ]; then - printf %b "\e[31mFAIL\e[0m $t (exit code $ret)\n" - pass=0 - fi + $t if ! diff $t.out test.log > /dev/null 2>&1; then printf %b "\e[31mFAIL\e[0m $t (output difference)\n" From patchwork Tue Jun 19 01:42: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: 931271 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="QVQAilxb"; 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 418s4y4FGsz9s2t for ; Tue, 19 Jun 2018 12:15:45 +1000 (AEST) Received: from localhost ([::1]:38546 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6BJ-0007TK-NE for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:15:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46112) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5iI-0001tW-AB for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5iH-00005G-3S for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:42 -0400 Received: from mail-ot0-x244.google.com ([2607:f8b0:4003:c0f::244]:44065) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5iG-00004v-UN; Mon, 18 Jun 2018 21:45:41 -0400 Received: by mail-ot0-x244.google.com with SMTP id w13-v6so20757889ote.11; Mon, 18 Jun 2018 18:45:40 -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=/aEBa1F3B/gxCGRPk8/0OZmrmV0s7fLsXJeKNXQzQ8s=; b=QVQAilxbquumQ4bcYmkTk0Vml1YTqcmxHPA1J19apPo/GdoUjuba8IJ91aH2JTLvNH /YdWr06qtAAk7dQ3e1iPNFQGvv+UFf48PmiJZ4m4P5x1APYkTLpkePDjDbQlpJlcsbee tKhg9qblpKHiy5Lg4DLKFv9Iqu6kWX/zOkh9l3GnEOeHzDDvDW/7nF+3lM6NankxFpQM Xpiau83r9wqcUahytKOSxBLLIOoA4XeR0CwDeiefba8/t5/4vKb9eN/IrcFM1YHtUsVG ArPKcdZfYZcjvUxrdiuIamTS4NratzszxPWyMjRly4yHmUaXLoJ/lt7ubSsVSuUkQ35R 4zLQ== 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=/aEBa1F3B/gxCGRPk8/0OZmrmV0s7fLsXJeKNXQzQ8s=; b=GsAIfwoN4SMUg7bo5NPBnjKFdl6DZXzaFqbt75LIF3l50TOBseBwIihMjpf8Amhu7J bq8bfxnNOXZSPGGhs//6WOEo5WVZvU0grTTfwA28v1fsMvouOZOQi2v76uzhwqJXO5wv eLYxLZoslQ/1BqEAUqBeNDUujzXAFfVhCX6ADzC/jCcKF17Io6OtEzG4+E8nYyXLLAyq VhyGw673fS2B0wwnNarqEJrY396fE69rAvFdzIoq1iISngR3WpQeFdmGBnO6UwsjMnF+ sKMloYDnikacwqpmouWRixHMg+eZmOcfRoof2WC+ifEStLuVnhdNHlik3VeYmNErf0+n X/Jg== X-Gm-Message-State: APt69E3xRE/+CMHpHvj67L+QUvmGvPxEjdO935ryEkPJse0D0/5aGv6n tvoYxdJToALsRFZyfBYMm44UGkJg X-Google-Smtp-Source: ADUXVKIDlM2HOMhpnrNyYtKxxk0vQ8NXJ3P00IQGfo7BcSNrU4H6307LhmxKGBkZRQtJ5nRnNhL+LQ== X-Received: by 2002:a9d:26bc:: with SMTP id l57-v6mr8823414otb.97.1529372739600; Mon, 18 Jun 2018 18:45:39 -0700 (PDT) Received: from localhost ([2600:1700:70:e488:b0ee:9bda:ee6f:91be]) by smtp.gmail.com with ESMTPSA id c2-v6sm7231786oia.53.2018.06.18.18.45.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:45:38 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:09 -0500 Message-Id: <20180619014319.28272-44-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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:c0f::244 Subject: [Qemu-devel] [PATCH 043/113] tests/multiboot: Add tests for the a.out kludge 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: Kevin Wolf Signed-off-by: Kevin Wolf Reviewed-by: Jack Schwartz (cherry picked from commit 1c8c426fb44bf5b3ffbcad1b00c7def4b89b03ec) Signed-off-by: Michael Roth --- tests/multiboot/Makefile | 22 +++++-- tests/multiboot/aout_kludge.S | 138 ++++++++++++++++++++++++++++++++++++++++ tests/multiboot/aout_kludge.out | 42 ++++++++++++ tests/multiboot/run_test.sh | 10 ++- 4 files changed, 204 insertions(+), 8 deletions(-) create mode 100644 tests/multiboot/aout_kludge.S create mode 100644 tests/multiboot/aout_kludge.out diff --git a/tests/multiboot/Makefile b/tests/multiboot/Makefile index 36f01dc647..ed4225e7d1 100644 --- a/tests/multiboot/Makefile +++ b/tests/multiboot/Makefile @@ -3,16 +3,26 @@ CCFLAGS=-m32 -Wall -Wextra -Werror -fno-stack-protector -nostdinc -fno-builtin ASFLAGS=-m32 LD=ld -LDFLAGS=-melf_i386 -T link.ld +LDFLAGS_ELF=-melf_i386 -T link.ld +LDFLAGS_BIN=-melf_i386 -T link.ld --oformat=binary LIBS=$(shell $(CC) $(CCFLAGS) -print-libgcc-file-name) -all: mmap.elf modules.elf +AOUT_KLUDGE_BIN=$(foreach x,$(shell seq 1 9),aout_kludge_$x.bin) -mmap.elf: start.o mmap.o libc.o - $(LD) $(LDFLAGS) -o $@ $^ $(LIBS) +all: mmap.elf modules.elf $(AOUT_KLUDGE_BIN) -modules.elf: start.o modules.o libc.o - $(LD) $(LDFLAGS) -o $@ $^ $(LIBS) +mmap.elf: start.o mmap.o libc.o link.ld + $(LD) $(LDFLAGS_ELF) -o $@ $^ $(LIBS) + +modules.elf: start.o modules.o libc.o link.ld + $(LD) $(LDFLAGS_ELF) -o $@ $^ $(LIBS) + +aout_kludge_%.bin: aout_kludge_%.o link.ld + $(LD) $(LDFLAGS_BIN) -o $@ $^ $(LIBS) + +.PRECIOUS: aout_kludge_%.o +aout_kludge_%.o: aout_kludge.S + $(CC) $(ASFLAGS) -DSCENARIO=$* -c -o $@ $^ %.o: %.c $(CC) $(CCFLAGS) -c -o $@ $^ diff --git a/tests/multiboot/aout_kludge.S b/tests/multiboot/aout_kludge.S new file mode 100644 index 0000000000..52e8ebd766 --- /dev/null +++ b/tests/multiboot/aout_kludge.S @@ -0,0 +1,138 @@ +/* + * Copyright (c) 2018 Kevin Wolf + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +.section multiboot + +#define MB_MAGIC 0x1badb002 +#define MB_FLAGS 0x10000 +#define MB_CHECKSUM -(MB_MAGIC + MB_FLAGS) + +.align 4 +.int MB_MAGIC +.int MB_FLAGS +.int MB_CHECKSUM + +#define LAST_BYTE_VALUE 0xa5 + +/* + * Order of fields in the a.out kludge header fields: + * + * header_addr + * load_addr + * load_end_addr + * bss_end_addr + * entry_addr + */ +#if SCENARIO == 1 +/* Well-behaved kernel file with explicit bss_end */ +.int 0x100000 +.int 0x100000 +.int data_end +.int data_end +.int _start +#elif SCENARIO == 2 +/* Well-behaved kernel file with default bss_end */ +.int 0x100000 +.int 0x100000 +.int data_end +.int 0 +.int _start +#elif SCENARIO == 3 +/* Well-behaved kernel file with default load_end */ +.int 0x100000 +.int 0x100000 +.int 0 +.int 0 +.int _start +#elif SCENARIO == 4 +/* Well-behaved kernel file with load_end < data_end and bss > data_end */ +#undef LAST_BYTE_VALUE +#define LAST_BYTE_VALUE 0 +.int 0x100000 +.int 0x100000 +.int code_end +.int 0x140000 +.int _start +#elif SCENARIO == 5 +/* header < load */ +.int 0x10000 +.int 0x100000 +.int data_end +.int data_end +.int _start +#elif SCENARIO == 6 +/* load_end < load */ +.int 0x100000 +.int 0x100000 +.int 0x10000 +.int data_end +.int _start +#elif SCENARIO == 7 +/* header much larger than in reality with default load_end */ +.int 0x80000000 +.int 0x100000 +.int 0 +.int data_end +.int _start +#elif SCENARIO == 8 +/* bss_end < load_end - load (regression test for CVE-2018-7550) */ +.int 0x100000 +.int 0x100000 +.int data_end +.int code_end +.int _start +#elif SCENARIO == 9 +/* Default load_end_addr, load_addr + kernel_file_size > UINT32_MAX */ +.int 0xfffff000 +.int 0xfffff000 +.int 0 +.int 0xfffff001 +.int _start +#else +#error Invalid SCENARIO +#endif + +.section .text +.global _start +_start: + xor %eax, %eax + + cmpb $LAST_BYTE_VALUE, last_byte + je passed + or $0x1, %eax +passed: + + /* Test device exit */ + outl %eax, $0xf4 + + cli + hlt + jmp . +code_end: + +#if SCENARIO != 8 +.space 8192 +#endif + +last_byte: +.byte 0xa5 +data_end: diff --git a/tests/multiboot/aout_kludge.out b/tests/multiboot/aout_kludge.out new file mode 100644 index 0000000000..031459275b --- /dev/null +++ b/tests/multiboot/aout_kludge.out @@ -0,0 +1,42 @@ + + + +=== Running test case: aout_kludge_1.bin === + + + +=== Running test case: aout_kludge_2.bin === + + + +=== Running test case: aout_kludge_3.bin === + + + +=== Running test case: aout_kludge_4.bin === + + + +=== Running test case: aout_kludge_5.bin === + +qemu-system-x86_64: invalid load_addr address + + +=== Running test case: aout_kludge_6.bin === + +qemu-system-x86_64: invalid load_end_addr address + + +=== Running test case: aout_kludge_7.bin === + +qemu-system-x86_64: invalid header_addr address + + +=== Running test case: aout_kludge_8.bin === + +qemu-system-x86_64: invalid bss_end_addr address + + +=== Running test case: aout_kludge_9.bin === + +qemu-system-x86_64: kernel does not fit in address space diff --git a/tests/multiboot/run_test.sh b/tests/multiboot/run_test.sh index bc9c3670af..6c33003e71 100755 --- a/tests/multiboot/run_test.sh +++ b/tests/multiboot/run_test.sh @@ -34,7 +34,7 @@ run_qemu() { -device isa-debugcon,chardev=stdio \ -chardev file,path=test.out,id=stdio \ -device isa-debug-exit,iobase=0xf4,iosize=0x4 \ - "$@" + "$@" >> test.log 2>&1 ret=$? cat test.out >> test.log @@ -67,9 +67,15 @@ modules() { run_qemu modules.elf -initrd "module.txt,module.txt argument,module.txt" } +aout_kludge() { + for i in $(seq 1 9); do + run_qemu aout_kludge_$i.bin + done +} + make all -for t in mmap modules; do +for t in mmap modules aout_kludge; do echo > test.log pass=1 From patchwork Tue Jun 19 01:42: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: 931302 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="AOmMWHoH"; 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 418shm15csz9s1R for ; Tue, 19 Jun 2018 12:43:20 +1000 (AEST) Received: from localhost ([::1]:38720 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6c1-0004EV-KG for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:43:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46134) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5iL-0001x4-TT for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5iJ-000076-6b for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:45 -0400 Received: from mail-oi0-x22a.google.com ([2607:f8b0:4003:c06::22a]:41474) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5iJ-00006y-0x; Mon, 18 Jun 2018 21:45:43 -0400 Received: by mail-oi0-x22a.google.com with SMTP id a141-v6so16694099oii.8; Mon, 18 Jun 2018 18:45:42 -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=V02fr+KhvNhpXudq/3m6AkqnpSgTpjAO5bmUDCE2Oak=; b=AOmMWHoHFP+emftmKMu1/Cl914eNjzFb/vPc2OJI+53LC1Xh4CbleME2KYS+lGBdEs dFmKVraGWZOI8jcwIZ/pZiUKFbggsI8UdXcKzYqi76rzG9SgvgaU0gB8FVOm9oxxpDSa f2nRQydEIIQ9j+IX9eFdBZ17yqxc8kyUuulhcvH7fAhvn38tVovOUplu8iemQVDsN6UT Y0BYTDpHVCZcqQeQBhNS5ncyHkNt4aP6jdeYlzCzZwkQR9mpBTDnkSh2H3IldrWUe8hB NP2J29q9tGX6/cmtsJE/SGd1eJH5xmmvLAzCpturzV9LLTc4iP6sOORdYO4I4O0RUtuu L4ow== 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=V02fr+KhvNhpXudq/3m6AkqnpSgTpjAO5bmUDCE2Oak=; b=kqZG+q8P1J3cEdtjG7LVPZVuaU1LU6QzJoxs2fG7BXdojC6HLszqjz3cZIWijq7Arx V6t21G0aWIPwS1EAnrNPiRy7/qaQSdrGAnAnCSCt8o6LlX1az86xh0jvFyYJCwmJeTk1 PYrPsD6YUi/yGqvS2nenLpjp0FYdO0Eehjsr4fnO9p0cUTwoYpw9b966uoeSmWdaF1Tj smTTMUXPdJpdIBGHYTEgoYCxXRiX2G9d6OfQKcL73MerZL89vnosNwOWweCpagd0gcYH xjooChogOQXk3FAMDxdEaDhv09bQJQTavyrXwsQalt1MaIPryYhDB/Xg8+jfMnnOqBeJ 4WqQ== X-Gm-Message-State: APt69E147wxYeQyHK6yFJoFUuPS3NGptqallvBdGgcdUIHU8oA/UYP7D 9BQoRUd8fbQjyuNzqqWFcXn8pQ5a X-Google-Smtp-Source: ADUXVKIFkCwWdNoL1orSnc975m2qfOxxmvpjdBIfbNh17xl3klo1lXDOeFmTuhby/LOiXMIODc7WbQ== X-Received: by 2002:aca:3a42:: with SMTP id h63-v6mr7561943oia.185.1529372741807; Mon, 18 Jun 2018 18:45:41 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id k133-v6sm7206008oia.36.2018.06.18.18.45.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:45:40 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:10 -0500 Message-Id: <20180619014319.28272-45-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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 044/113] tests/multiboot: Add .gitignore 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: Kevin Wolf Signed-off-by: Kevin Wolf Reviewed-by: Jack Schwartz Reviewed-by: Eric Blake (cherry picked from commit e2679395d598bd40770c22a793c0152576ac211f) Signed-off-by: Michael Roth --- tests/multiboot/.gitignore | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 tests/multiboot/.gitignore diff --git a/tests/multiboot/.gitignore b/tests/multiboot/.gitignore new file mode 100644 index 0000000000..93ef99800b --- /dev/null +++ b/tests/multiboot/.gitignore @@ -0,0 +1,3 @@ +*.bin +*.elf +test.out From patchwork Tue Jun 19 01:42: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: 931298 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="eSpEb79l"; 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 418sbw0hBRz9s1R for ; Tue, 19 Jun 2018 12:39:08 +1000 (AEST) Received: from localhost ([::1]:38692 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6Xx-0000Yc-Mb for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:39:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46152) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5iM-0001xr-Tc for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5iL-00007c-Kr for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:46 -0400 Received: from mail-ot0-x242.google.com ([2607:f8b0:4003:c0f::242]:32773) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5iL-00007Q-8V; Mon, 18 Jun 2018 21:45:45 -0400 Received: by mail-ot0-x242.google.com with SMTP id h6-v6so20791259otj.0; Mon, 18 Jun 2018 18:45: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 :mime-version:content-transfer-encoding; bh=4CmOVZbFQSobDDni/AZN+gRoBOw9C78qnUJRBGs0Jtc=; b=eSpEb79lo9uQvB3t1XhKsutWJ+PaJpRGv3qMN9rDCYAPO7vbmJsD5646Mg0ANwwh95 34w4MVZd3pGG5Nbj6iXZ2IgfVwbjazWhBc1wFZSgP3gncgGt08STzloxXkfJ5hlnbsy6 MORGTFBTTmLeNTdDUSjVntlXZvbfjoKvbWAByW93CKn0M7l6kXDSf5IipOp/GEWFpZQ3 pucZ+ZjI9odgd0XglcBbdcWmJQIJy3u0vgmNDPvqIsDs8QqcpjWj3/Hsu/modesbiBxu yqlZlYckWnk2kX/0g++v4gtO+0cFRsZdvsh5YkK49t+AubUn7ihxd8VqNmnMkI6oE7dN 23Ow== 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=4CmOVZbFQSobDDni/AZN+gRoBOw9C78qnUJRBGs0Jtc=; b=Y7lONRcuJDCpDzwhfnquTZnsY0RdPXtlyX6jw1kYR3agkqVpI/lJiq8rc7cgLcOPh8 LoM0sot2OOm+c3Wio+35FueNqCMP7Gnl4tceh1eL7O8vDNpoLHbLPJYPG8s4B6rHn9WF nTS5Sth9qJXzsx5jujLfEc/zvmzJUdXURz3biVKwSZhqO0EfxfImQ27dsFsaxLLsjxwg V2Gnf4QRF4Pu05OnMJRlpSadcmFM5laHDAI7KbhcK8dhQObU8y5EjdUWPzaZiATKxSqz nDTHzkLrVGDlIjDHVU372+/FYIVR0qJhFyiNfwkAV5sv2OHK3WnCFghxxMzRWF41OqjE lKnQ== X-Gm-Message-State: APt69E21Eq/Hp0qqLL9IOq1UeXyXlsoM7gXV66DPXAvw3t7pjvGM7I9f SWNWZlDy0rMsnVWETExmbS3Id6pM X-Google-Smtp-Source: ADUXVKIqLoYs/7jzoCgPiHENic+nnPuYHJJ1EFtZcncm7XhtZf87nreffao3n+xUSuwHDGXplNuLhw== X-Received: by 2002:a9d:1f66:: with SMTP id x35-v6mr8600372otx.219.1529372744092; Mon, 18 Jun 2018 18:45: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 t204-v6sm7857239oig.24.2018.06.18.18.45.42 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:45:43 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:11 -0500 Message-Id: <20180619014319.28272-46-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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:c0f::242 Subject: [Qemu-devel] [PATCH 045/113] arm/translate-a64: treat DISAS_UPDATE as variant of DISAS_EXIT 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 , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-stable@nongnu.org, Victor Kamensky Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Victor Kamensky In OE project 4.15 linux kernel boot hang was observed under single cpu aarch64 qemu. Kernel code was in a loop waiting for vtimer arrival, spinning in TC generated blocks, while interrupt was pending unprocessed. This happened because when qemu tried to handle vtimer interrupt target had interrupts disabled, as result flag indicating TCG exit, cpu->icount_decr.u16.high, was cleared but arm_cpu_exec_interrupt function did not call arm_cpu_do_interrupt to process interrupt. Later when target reenabled interrupts, it happened without exit into main loop, so following code that waited for result of interrupt execution run in infinite loop. To solve the problem instructions that operate on CPU sys state (i.e enable/disable interrupt), and marked as DISAS_UPDATE, should be considered as DISAS_EXIT variant, and should be forced to exit back to main loop so qemu will have a chance processing pending CPU state updates, including pending interrupts. This change brings consistency with how DISAS_UPDATE is treated in aarch32 case. CC: Peter Maydell CC: Alex Bennée CC: qemu-stable@nongnu.org Suggested-by: Peter Maydell Signed-off-by: Victor Kamensky Reviewed-by: Richard Henderson Message-id: 1521526368-1996-1-git-send-email-kamensky@cisco.com Signed-off-by: Peter Maydell (cherry picked from commit a75a52d62418dafe462be4fe30485501d1010bb9) Signed-off-by: Michael Roth --- target/arm/translate-a64.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 625ef2dfd2..c38109146f 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -11384,12 +11384,12 @@ static void aarch64_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) case DISAS_UPDATE: gen_a64_set_pc_im(dc->pc); /* fall through */ - case DISAS_JUMP: - tcg_gen_lookup_and_goto_ptr(); - break; case DISAS_EXIT: tcg_gen_exit_tb(0); break; + case DISAS_JUMP: + tcg_gen_lookup_and_goto_ptr(); + break; case DISAS_NORETURN: case DISAS_SWI: break; From patchwork Tue Jun 19 01:42: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: 931301 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="Ajp0VYGk"; 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 418sg9730Sz9s1R for ; Tue, 19 Jun 2018 12:41:57 +1000 (AEST) Received: from localhost ([::1]:38710 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6ah-000372-GQ for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:41:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46165) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5iO-0001zW-Ok for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5iN-00008M-Fk for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:48 -0400 Received: from mail-oi0-x244.google.com ([2607:f8b0:4003:c06::244]:40539) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5iN-000087-A9; Mon, 18 Jun 2018 21:45:47 -0400 Received: by mail-oi0-x244.google.com with SMTP id f79-v6so16686559oib.7; Mon, 18 Jun 2018 18:45: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=De4ncD0ZCVnAiLZIxM/nRUIBuH9mTKHnaKsSzi5UN1w=; b=Ajp0VYGke4DEg2BwesjAfAja8LGnPsuE3iOQlR1Y89ULqmIMefYCgv8N9UG+u+AHgu hsYXTe9OcenB9JqYJ6X8OYY6uEiLwPbtPQXVU1drMhLo8M29VAVHuIE4sWvHE1X5h3AB AM05MwE1dNyUXXngHHYKdgl+G4bn4VCFq/mxgb6Tk9MopRm4vPfG0DNG8AXCgHVSjIp3 q1Gm8EhcQaR/r6fVtSaXW3TjkIqiTgOqE1khGdIXAi7mEWo88pLQDF9qpV1x7Dy7bZpx EuhfQpS86bW71BgC5TVR4bY4efcU0mnWsnY04a7waev15YXgknVXg0em5C+3zqdg1WPP HS7g== 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=De4ncD0ZCVnAiLZIxM/nRUIBuH9mTKHnaKsSzi5UN1w=; b=rrQJ2mlSYHSOMZVxSoxA/mQ5dI3wYOSq6/R+R6tLwlfv2WTevMfZ4WeMDA3UMKdMzV F9m67CsOlZ3P2PfxZDkOpWSO5kTRERrKwHFiiz8xCcwuolcdelVE/OSRxBYZOwK7LqYp +7MKJbSEtPwjev5ef3MCMPVmMOAoObgwNzorB3lZikxF49DVA08pTXw8aV+XCEjHtpXu pRB5NAFIS7Y6RBkTBy7fIjt3ZgIKyjMaEA56BOo+DC+KMQKT6zMs596h3MZafWgMFSYY zti7ok3qn97frXXp1+E7Ba8xJBNvvm0HC0VURxrkBNQx3z/IccgA8QRTAq+OE7c9zpn5 JZRQ== X-Gm-Message-State: APt69E0/gJ0B3tgFQJl7Miwq049dJotu8j+Xxfe5lAuiTjC0JTQZzbhq iXsoXIeuJMo5DsuAe8UG6f0ZZdmH X-Google-Smtp-Source: ADUXVKKQzScGkxE4WRSB8bpL6S7HCvZlHHlmluqfqwSNv9p8+44wYUCM+kmJwfbYwGyI4XkzTZzy2A== X-Received: by 2002:aca:e7c8:: with SMTP id e191-v6mr8038428oih.202.1529372746138; Mon, 18 Jun 2018 18:45:46 -0700 (PDT) Received: from localhost ([2600:1700:70:e488:b0ee:9bda:ee6f:91be]) by smtp.gmail.com with ESMTPSA id p128-v6sm6851858oif.21.2018.06.18.18.45.44 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:45:45 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:12 -0500 Message-Id: <20180619014319.28272-47-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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 046/113] virtio_net: flush uncompleted TX on 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: Jason Wang , qemu-stable@nongnu.org, Greg Kurz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Greg Kurz If the backend could not transmit a packet right away for some reason, the packet is queued for asynchronous sending. The corresponding vq element is tracked in the async_tx.elem field of the VirtIONetQueue, for later freeing when the transmission is complete. If a reset happens before completion, virtio_net_tx_complete() will push async_tx.elem back to the guest anyway, and we end up with the inuse flag of the vq being equal to -1. The next call to virtqueue_pop() is then likely to fail with "Virtqueue size exceeded". This can be reproduced easily by starting a guest with an hubport backend that is not connected to a functional network, eg, -device virtio-net-pci,netdev=hub0 -netdev hubport,id=hub0,hubid=0 and no other -netdev hubport,hubid=0 on the command line. The appropriate fix is to ensure that such an asynchronous transmission cannot survive a device reset. So for all queues, we first try to send the packet again, and eventually we purge it if the backend still could not deliver it. CC: qemu-stable@nongnu.org Reported-by: R. Nageswara Sastry Buglink: https://github.com/open-power-host-os/qemu/issues/37 Signed-off-by: Greg Kurz Tested-by: R. Nageswara Sastry Signed-off-by: Jason Wang (cherry picked from commit 94b52958b77a2a040564cf7ed716d3a9545d94e5) Signed-off-by: Michael Roth --- hw/net/virtio-net.c | 11 +++++++++++ include/net/net.h | 1 + net/net.c | 1 - 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 38674b08aa..6bdef38ceb 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -422,6 +422,7 @@ static RxFilterInfo *virtio_net_query_rxfilter(NetClientState *nc) static void virtio_net_reset(VirtIODevice *vdev) { VirtIONet *n = VIRTIO_NET(vdev); + int i; /* Reset back to compatibility mode */ n->promisc = 1; @@ -445,6 +446,16 @@ static void virtio_net_reset(VirtIODevice *vdev) memcpy(&n->mac[0], &n->nic->conf->macaddr, sizeof(n->mac)); qemu_format_nic_info_str(qemu_get_queue(n->nic), n->mac); memset(n->vlans, 0, MAX_VLAN >> 3); + + /* Flush any async TX */ + for (i = 0; i < n->max_queues; i++) { + NetClientState *nc = qemu_get_subqueue(n->nic, i); + + if (nc->peer) { + qemu_flush_or_purge_queued_packets(nc->peer, true); + assert(!virtio_net_get_subqueue(nc)->async_tx.elem); + } + } } static void peer_test_vnet_hdr(VirtIONet *n) diff --git a/include/net/net.h b/include/net/net.h index 1c55a93588..ab87d426e1 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -156,6 +156,7 @@ ssize_t qemu_send_packet_async(NetClientState *nc, const uint8_t *buf, int size, NetPacketSent *sent_cb); void qemu_purge_queued_packets(NetClientState *nc); void qemu_flush_queued_packets(NetClientState *nc); +void qemu_flush_or_purge_queued_packets(NetClientState *nc, bool purge); void qemu_format_nic_info_str(NetClientState *nc, uint8_t macaddr[6]); bool qemu_has_ufo(NetClientState *nc); bool qemu_has_vnet_hdr(NetClientState *nc); diff --git a/net/net.c b/net/net.c index 39ef546708..0719358d03 100644 --- a/net/net.c +++ b/net/net.c @@ -612,7 +612,6 @@ void qemu_purge_queued_packets(NetClientState *nc) qemu_net_queue_purge(nc->peer->incoming_queue, nc); } -static void qemu_flush_or_purge_queued_packets(NetClientState *nc, bool purge) { nc->receive_disabled = 0; From patchwork Tue Jun 19 01:42: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: 931276 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="QXQGimic"; 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 418s9t6dkcz9s37 for ; Tue, 19 Jun 2018 12:20:02 +1000 (AEST) Received: from localhost ([::1]:38572 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6FU-0002Al-Ed for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:20:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46195) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5iQ-00022G-HP for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5iP-000091-If for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:50 -0400 Received: from mail-ot0-x22d.google.com ([2607:f8b0:4003:c0f::22d]:43000) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5iP-00008s-E3; Mon, 18 Jun 2018 21:45:49 -0400 Received: by mail-ot0-x22d.google.com with SMTP id 92-v6so20760342otw.9; Mon, 18 Jun 2018 18:45: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=A8twTIhqZmhEdHqqnjYH9nVhDzWUFyDBtAnvCAHtguE=; b=QXQGimicG7A/qC6bcAuvmAXirQ7ZleWKLinFHv/6MJi1MrO28/Ad5b4qnnoUdyBbDS KpHll4wkGN2DERjCQjRksj7MNlMKuYkG97uGfZZEnO20h38OKmHanvqlzv/HwJgPS7oe Z5DuxqsgPLCISud7AR8IdkXhjUEUr/H58PagDcqBxe0rIn0303bpXO4g6ilGIBIpyiGQ TWX7/MUohQZPFeP9JmsNv/ClY1crH82MRiV8k+eXJ15mu3XCm7wwYv1jpdFITuW4iRPj L7nFPDtN6+Vukv0JhM8VI1FPsNnHlrivxsUzlmRN4RakUUmj3ZSNuP8JJ1CsdrwRqy5u PQUA== 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=A8twTIhqZmhEdHqqnjYH9nVhDzWUFyDBtAnvCAHtguE=; b=WKHVq8mu++j3YNrPhb501d9He+Z4zvnQfs8W7TmmvnLewjOq9CZw53rN485zDbO0M9 EmiYaJojKZw6KD+0GaZ63cdpXzxH6TTD/KRP4nYQW3k6r7OsaKlu8drXSCrL2vfryDxr vEayTTMQSb7c3X+gqe6PyxQoimBbuB18oUNotYaK+fbohyWmhkgPEZXfXtSSeoG8AdJs ot5aFnsXgB8UQRVDXpzlfs7hAjBRNmjpZpD1/a1aYvtLiKGjqzug+mRilRpumL931n6r mScy2ihZSK542GuT/W5s3qkb3p1v1f1nomDBpRx26UFvWaVMVeJJMFYoOLLqxGaq8QGs BAnw== X-Gm-Message-State: APt69E08C0Zjc6CzFmf0siNnA87TNXk50t0SeRm3RqrPfUZv193Z5wSv 10/y6DdJBEEFoh0wKFthvhK9FZsK X-Google-Smtp-Source: ADUXVKIjsHhsLCPAgpItqa6H5XFyY4liY6EjFmcIpin5FPWpGAynFUTlXrk7lvsZtMqsC4wAz+LNsQ== X-Received: by 2002:a9d:338d:: with SMTP id u13-v6mr9579238otc.232.1529372748193; Mon, 18 Jun 2018 18:45:48 -0700 (PDT) Received: from localhost ([2600:1700:70:e488:b0ee:9bda:ee6f:91be]) by smtp.gmail.com with ESMTPSA id 4-v6sm6844956oil.2.2018.06.18.18.45.46 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:45:47 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:13 -0500 Message-Id: <20180619014319.28272-48-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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:c0f::22d Subject: [Qemu-devel] [PATCH 047/113] qemu-pr-helper: Actually allow users to specify pidfile 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, Paolo Bonzini Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Michal Privoznik Due to wrong specification of arguments to getopt_long() any attempt to set pidfile resulted in: 1) the default to be leaked 2) the @pidfile variable to be set to NULL (because optarg is NULL without this patch). Signed-off-by: Michal Privoznik Message-Id: <6f10cd53d361a395aa0e85a9311ec4e9a8fc11e5.1521868451.git.mprivozn@redhat.com> Cc: qemu-stable@nongnu.org Reviewed-by: Eric Blake Signed-off-by: Paolo Bonzini (cherry picked from commit f8e1a989644f22ba2f7afb0e13b6ce2309ea9503) Signed-off-by: Michael Roth --- scsi/qemu-pr-helper.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scsi/qemu-pr-helper.c b/scsi/qemu-pr-helper.c index 9fe615c73c..12474d162c 100644 --- a/scsi/qemu-pr-helper.c +++ b/scsi/qemu-pr-helper.c @@ -903,12 +903,12 @@ static int drop_privileges(void) int main(int argc, char **argv) { - const char *sopt = "hVk:fdT:u:g:vq"; + const char *sopt = "hVk:f:dT:u:g:vq"; struct option lopt[] = { { "help", no_argument, NULL, 'h' }, { "version", no_argument, NULL, 'V' }, { "socket", required_argument, NULL, 'k' }, - { "pidfile", no_argument, NULL, 'f' }, + { "pidfile", required_argument, NULL, 'f' }, { "daemon", no_argument, NULL, 'd' }, { "trace", required_argument, NULL, 'T' }, { "user", required_argument, NULL, 'u' }, @@ -952,7 +952,8 @@ int main(int argc, char **argv) } break; case 'f': - pidfile = optarg; + g_free(pidfile); + pidfile = g_strdup(optarg); break; #ifdef CONFIG_LIBCAP case 'u': { From patchwork Tue Jun 19 01:42: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: 931297 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="YCIm8DvW"; 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 418sbY4bzvz9s1R for ; Tue, 19 Jun 2018 12:38:49 +1000 (AEST) Received: from localhost ([::1]:38691 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6Xe-0000GS-SY for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:38:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46253) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5iW-00028u-Hi for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5iR-00009l-Ly for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:56 -0400 Received: from mail-oi0-x22b.google.com ([2607:f8b0:4003:c06::22b]:34774) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5iR-00009Y-Gk; Mon, 18 Jun 2018 21:45:51 -0400 Received: by mail-oi0-x22b.google.com with SMTP id i205-v6so16712249oib.1; Mon, 18 Jun 2018 18:45:51 -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=VprMFyDS392JXPSIMXsRatIG6g9hq/SSPzBns5VJi7o=; b=YCIm8DvWeCEn/3tjz67cKjKwZFD8RC4zlADn0z1RT8H1Ox5A436+e9Y9LEIPoYamyi K2BQJXwnAIvdAFV7ZzM67kl4E//tXO5wtJceu4CHywIKXugMlCdO69AkBLrSB3iBtgKo GEqHmb5c8/NZ0HiLeOKVNp2iza1T8rvclTNLwZz8RAjlyAOxADVCZenE1KJlDraBN59x U75ewtZ8s7foVLC3Q7YBmAvHDaeVZAhfaA6B8yIQzJHy7pLblN8f+deaFcPG41z8N4HJ rxzWX8BuWDbJ4koVK7EpcG0d7gFgiskpkpOxz/i2TkQIECe3qWNpB62DcmvAUJHObc/C 9SEQ== 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=VprMFyDS392JXPSIMXsRatIG6g9hq/SSPzBns5VJi7o=; b=icM/Iv6P78zP92HW0rRf0Fhcuc9HSOUxJnq17AjBwMleQETJcB5ut8MuJ3mG+FBR/4 OWd8guW04wxNxJj9UwkJ542ENVspJnoJhe25FejguoiNaTXj5hAEdH7cHE7uLvKcget7 2ktVvFzDVDjYUqbAvg57CzvPuP18cig1VP90r++zgB6xu8Bs33NWArKhOIKt/zVn3BpD XH5MvSA9mT58sqJN5N2xoHJBDd6bI+3GQTdBm6pNXNSYZh8SqpmkrY51ONmcGINLxXCW U+QeOZ6sPuHmvdgvVeQvNXQQYB+ovgNY/qy9MEJxvdlz88Sptpmnsvb0nqrRuWB44LJA 3MGg== X-Gm-Message-State: APt69E0pput6iM21YY9Z66edp4ehNCx6/WPYu4772NtvFSqmCeN1PgVg Mk2wCXnzgY5ssLS75aWxzc6bjPdE X-Google-Smtp-Source: ADUXVKLcC0cJ2he2z/pyMyfCvh9gv7g6zLeOHxqzB3JhQfBM5699SQl9VSjK79HwF67k5oUCzYoZXw== X-Received: by 2002:aca:da82:: with SMTP id r124-v6mr7598479oig.19.1529372750258; Mon, 18 Jun 2018 18:45:50 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id b4-v6sm7200134otf.79.2018.06.18.18.45.48 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:45:49 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:14 -0500 Message-Id: <20180619014319.28272-49-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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 048/113] block/file-posix: Fix fully preallocated truncate 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 Storing the lseek() result in an int results in it overflowing when the file is at least 2 GB big. Then, we have a 50 % chance of the result being "negative" and thus thinking an error occurred when actually everything went just fine. So we should use the correct type for storing the result: off_t. Reported-by: Daniel P. Berrange Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1549231 Cc: qemu-stable@nongnu.org Signed-off-by: Max Reitz Message-id: 20180228131315.30194-2-mreitz@redhat.com Reviewed-by: Eric Blake Signed-off-by: Max Reitz (cherry picked from commit 82b45e0a0b824787bd79ce3f6453eaa2afddd138) Signed-off-by: Michael Roth --- block/file-posix.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/block/file-posix.c b/block/file-posix.c index 36ee89e940..275953fdc6 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -1694,6 +1694,7 @@ static int raw_regular_truncate(int fd, int64_t offset, PreallocMode prealloc, case PREALLOC_MODE_FULL: { int64_t num = 0, left = offset - current_length; + off_t seek_result; /* * Knowing the final size from the beginning could allow the file @@ -1708,8 +1709,8 @@ static int raw_regular_truncate(int fd, int64_t offset, PreallocMode prealloc, buf = g_malloc0(65536); - result = lseek(fd, current_length, SEEK_SET); - if (result < 0) { + seek_result = lseek(fd, current_length, SEEK_SET); + if (seek_result < 0) { result = -errno; error_setg_errno(errp, -result, "Failed to seek to the old end of file"); From patchwork Tue Jun 19 01:42: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: 931305 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="ni6JL2hK"; 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 418skw4BK4z9s1R for ; Tue, 19 Jun 2018 12:45:12 +1000 (AEST) Received: from localhost ([::1]:38732 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6dq-0005xm-5B for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:45:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46234) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5iU-00026l-Ay for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5iT-0000AH-Br for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:54 -0400 Received: from mail-ot0-x241.google.com ([2607:f8b0:4003:c0f::241]:44064) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5iT-0000A8-6m; Mon, 18 Jun 2018 21:45:53 -0400 Received: by mail-ot0-x241.google.com with SMTP id w13-v6so20758279ote.11; Mon, 18 Jun 2018 18:45:53 -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=CuzL4gGZ/HcuguXkeauX1d8SD/HS4vDlr1t6UCInqYs=; b=ni6JL2hKUdOyF0PJhMZIfl66DietzQ/F7wZ5uNXkjmVLPR31FL6ZZziOqFpbAQoJCV DAerDoOoLvGbWeV/mkM+lQcj6AlsP3S9XzcRwIKM6NaCCA+iO50V2wXFPebFwFiQABZ7 l9c59n+Smlz+etoE/jMULP/amDsjWVRnUz9npLyV3IaKP3CbfvfHBg6BWeSvZDc54AEX QbH2qF+I/nI9D8HHhnk7mCELNZPt7NRj7oFstzGnRKXu0BeFTJp6sr3H3wZWi8DEb7TN JXfR83C+orT3CcoRaroT6WL2mKuTm+tZrCd3dvqqmJzm2j54DtZaJAy615BCb84Bm7dS 239Q== 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=CuzL4gGZ/HcuguXkeauX1d8SD/HS4vDlr1t6UCInqYs=; b=DrOSdrXQseklhxkz07K9xt8jPvaAC9FkZ15aiKR+n4J44muNxuB8YY016pVcJJsZq3 mqMcJHM+qMo6DzcLwiA5PZOhqn8qE7iU48g2pBxaUEB33xh5cb4NAxm8/LH58hLpMQgY pdp9x0Fdxs8WCtwW6IXBclyESDAPoeKzWJcNHMeW6rONzyFj8iFq2/dGEkOqnY8qoBbt gp5Lq3g4Mr2ocfSjZdDGCn5TRgPT1hFu7ROsljMPkK8LLYVVUAhWkekARDwinqAQpoyC KOgeySnqOijBEU/PkzJJlBmTYd/OBZVM+ARoZ4feoGToJ9zf5h48pmp2S/nZP6LB2zb7 Yh5Q== X-Gm-Message-State: APt69E3iNnK12ec4yl5Nu5XC48s3Vahvv37msDGafJd5uywZBmdCOD/l ctvkov6q2QT/GPWTK3n23VoUepuf X-Google-Smtp-Source: ADUXVKKrDR068ulyoVRaIUTbMiwbM1QQXOGqAgGUwuhuNkwMEhRdv0wOkIPhntJTC+kmwcfUJUusuA== X-Received: by 2002:a9d:b3b:: with SMTP id a56-v6mr9583983ota.272.1529372752048; Mon, 18 Jun 2018 18:45:52 -0700 (PDT) Received: from localhost ([2600:1700:70:e488:b0ee:9bda:ee6f:91be]) by smtp.gmail.com with ESMTPSA id d13-v6sm6999667oth.34.2018.06.18.18.45.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:45:51 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:15 -0500 Message-Id: <20180619014319.28272-50-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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:c0f::241 Subject: [Qemu-devel] [PATCH 049/113] iotests: Test preallocated truncate of 2G 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 Signed-off-by: Max Reitz Message-id: 20180228131315.30194-3-mreitz@redhat.com Reviewed-by: Daniel P. Berrangé Reviewed-by: Eric Blake Signed-off-by: Max Reitz (cherry picked from commit 733d1dce0f3c8ab7b79a173f6482781d3718f844) Signed-off-by: Michael Roth --- tests/qemu-iotests/106 | 24 ++++++++++++++++++++++++ tests/qemu-iotests/106.out | 10 ++++++++++ 2 files changed, 34 insertions(+) diff --git a/tests/qemu-iotests/106 b/tests/qemu-iotests/106 index bfe71f4e60..5e51f88a78 100755 --- a/tests/qemu-iotests/106 +++ b/tests/qemu-iotests/106 @@ -86,6 +86,30 @@ for growth_mode in falloc full off; do $QEMU_IMG resize -f "$IMGFMT" --shrink --preallocation=$growth_mode "$TEST_IMG" -${GROWTH_SIZE}K done +echo +echo '=== Testing image growth on 2G empty image ===' + +for growth_mode in falloc full; do + echo + echo "--- growth_mode=$growth_mode ---" + + # Maybe we want to do an lseek() to the end of the file before the + # preallocation; if the file has a length of 2 GB, that would + # return an integer that overflows to negative when put into a + # plain int. We should use the correct type for the result, and + # this tests we do. + + _make_test_img 2G + $QEMU_IMG resize -f "$IMGFMT" --preallocation=$growth_mode "$TEST_IMG" +${GROWTH_SIZE}K + + actual_size=$($QEMU_IMG info -f "$IMGFMT" "$TEST_IMG" | grep 'disk size') + actual_size=$(echo "$actual_size" | sed -e 's/^[^0-9]*\([0-9]\+\).*$/\1/') + + if [ $actual_size -lt $GROWTH_SIZE ]; then + echo "ERROR: Image should have at least ${GROWTH_SIZE}K, but has ${actual_size}K" + fi +done + # success, all done echo '*** done' rm -f $seq.full diff --git a/tests/qemu-iotests/106.out b/tests/qemu-iotests/106.out index 0a42312301..c459957660 100644 --- a/tests/qemu-iotests/106.out +++ b/tests/qemu-iotests/106.out @@ -47,4 +47,14 @@ qemu-img: Preallocation can only be used for growing images --- growth_mode=off --- Image resized. + +=== Testing image growth on 2G empty image === + +--- growth_mode=falloc --- +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2147483648 +Image resized. + +--- growth_mode=full --- +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2147483648 +Image resized. *** done From patchwork Tue Jun 19 01:42:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 931309 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="ITe7V0k9"; 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 418spZ11PZz9s1R for ; Tue, 19 Jun 2018 12:48:22 +1000 (AEST) Received: from localhost ([::1]:38751 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6gt-0008Kg-OI for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:48:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46255) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5iW-00028v-IW for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5iV-0000Bj-Dn for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:56 -0400 Received: from mail-ot0-x242.google.com ([2607:f8b0:4003:c0f::242]:35720) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5iV-0000Bb-8V; Mon, 18 Jun 2018 21:45:55 -0400 Received: by mail-ot0-x242.google.com with SMTP id q17-v6so20778590otg.2; Mon, 18 Jun 2018 18:45:55 -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=EiedPMKIMDOxSC/Z0Tp6rpZSOKyu6ubrgDOJ4qs5lq8=; b=ITe7V0k9P8aoHkSKDF70iFjVtEZzpccrFudQvdt++2faa131WgFD/ZFvTZpb8N28w1 Gpn9ocJUuiDI1FqPjK+h1yh7P2qgUnUR2kKntDCw55W0B//rZNVNefeTFTCShiIGSQb0 4WCywsn108CXD//AwJslLDCIBY3FudNzM+M2Cgn15KbnZljIiKW7bXLwe6RsAHEGkKJk m6OiOMd9qdVZ4ahb7GfDt71RFqGLM5IkIhP9BcLRPbtI7oNaG7kaxjV4smfxo1BX285Z BQCO86OrkUM0+GBHIem6TG4zzyXg/gjy6AB+xFyYHciCNYP/3Of/KOpJVm/Ru0cdtO63 pOwQ== 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=EiedPMKIMDOxSC/Z0Tp6rpZSOKyu6ubrgDOJ4qs5lq8=; b=BWlFkBfWgZahP6GR35LGyDKRC0hebG9VrA0mJCtwZipV9xzGC3ieG5R+4Ac125Gh1g rJfvM65vSNl1fteeV8u9fH8lsMHtQyqMtcLGoQLZmkSnZSA4yGetdYtNUCjZk/K/LA5z mBDEveFnmBWjZ95SnFeGUuWkmWOd91kEV2yHuc/PD5Sr9KcV/sYe0iWurgjbXrm5Bp92 h9iA5ezmK8vzMrDPIJaRkW3JRQ7IjN3BwaTm2MWzdXHlNobqFTF0s/JndmcyXUJay7Zt CjCIU+dPkwwRCl8xCnYi0svnAC77jv/Mqhn0uQsTpeZS5q2MiUAzVYFdFFAaSmw/GlD8 FgEw== X-Gm-Message-State: APt69E1l7C+Ag28uAVevq++3Vf+Z0Tst1jWrQ6Ew0W+PrfBHLSHgzz2I Gz/R1cr+VAsmosztzc9RqPSfjdSD X-Google-Smtp-Source: ADUXVKI61f+WJpguRNP1Zrz4DSRsERyEkKl/ZEsQcuF6+xeUrbpuLeroyXSlbFm+sRdXH7OEmLCm0A== X-Received: by 2002:a9d:4696:: with SMTP id z22-v6mr9704704ote.57.1529372754138; Mon, 18 Jun 2018 18:45:54 -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-v6sm6629915oia.35.2018.06.18.18.45.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:45:53 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:16 -0500 Message-Id: <20180619014319.28272-51-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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:c0f::242 Subject: [Qemu-devel] [PATCH 050/113] tcg: Mark muluh_i64 and mulsh_i64 as 64-bit ops 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 Failure to do so results in the tcg optimizer sign-extending any constant fold from 32-bits. This turns out to be visible in the RISC-V testsuite using a host that emits these opcodes (e.g. any non-x86_64). Reported-by: Michael Clark Reviewed-by: Emilio G. Cota Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson (cherry picked from commit f2f1dde75160cac6ede330f3db50dc817d01a2d6) Signed-off-by: Michael Roth --- tcg/tcg-opc.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tcg/tcg-opc.h b/tcg/tcg-opc.h index 956fb1e9f3..bb28b863ce 100644 --- a/tcg/tcg-opc.h +++ b/tcg/tcg-opc.h @@ -182,8 +182,8 @@ DEF(add2_i64, 2, 4, 0, IMPL64 | IMPL(TCG_TARGET_HAS_add2_i64)) DEF(sub2_i64, 2, 4, 0, IMPL64 | IMPL(TCG_TARGET_HAS_sub2_i64)) DEF(mulu2_i64, 2, 2, 0, IMPL64 | IMPL(TCG_TARGET_HAS_mulu2_i64)) DEF(muls2_i64, 2, 2, 0, IMPL64 | IMPL(TCG_TARGET_HAS_muls2_i64)) -DEF(muluh_i64, 1, 2, 0, IMPL(TCG_TARGET_HAS_muluh_i64)) -DEF(mulsh_i64, 1, 2, 0, IMPL(TCG_TARGET_HAS_mulsh_i64)) +DEF(muluh_i64, 1, 2, 0, IMPL64 | IMPL(TCG_TARGET_HAS_muluh_i64)) +DEF(mulsh_i64, 1, 2, 0, IMPL64 | IMPL(TCG_TARGET_HAS_mulsh_i64)) #define TLADDR_ARGS (TARGET_LONG_BITS <= TCG_TARGET_REG_BITS ? 1 : 2) #define DATA64_ARGS (TCG_TARGET_REG_BITS == 64 ? 1 : 2) From patchwork Tue Jun 19 01:42: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: 931304 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="vNvlZUGb"; 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 418skL5gMbz9s1R for ; Tue, 19 Jun 2018 12:44:42 +1000 (AEST) Received: from localhost ([::1]:38728 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6dM-0005OM-4r for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:44:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46313) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5ia-0002Cn-E1 for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:46:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5iZ-0000DR-Gd for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:46:00 -0400 Received: from mail-oi0-x232.google.com ([2607:f8b0:4003:c06::232]:42969) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5iZ-0000DI-AZ; Mon, 18 Jun 2018 21:45:59 -0400 Received: by mail-oi0-x232.google.com with SMTP id k190-v6so16695361oib.9; Mon, 18 Jun 2018 18:45: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; bh=Mlm6jOQJGA/cT1wNao1VFIsToR/c28rmbfNa3oiSO0o=; b=vNvlZUGbTlhpfcDHTjKpCFP1SnOCsdv4JCBAIhCGimAGzFBRpNKzM0LDGZZJjXGjh6 H9dimURXxZvwH9tBt02e9/F0HLLK8tBBUpsFUKAiFIFpeIuCa65gtAUP69TlmwKq7mgA Peyc/l1cge+CoQlAsZ/y0YW0inZ1NQZg87DEO/WCXqznWJuVYNgFTCl5dxz0bm5pbEdy 64S/isGMX3sWfOWXtscXDX1/aBDzqcqyfyVgRHEEJJJoc1XtD3bOM+FddO4roU8ya7f2 yT+EnpVkbYTKeur0ctCB+U+UD6RKD2i+vyQ7KpwTqgGZYt/HUhXkeSYN2RSHYMUSLPPm F/mQ== 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=Mlm6jOQJGA/cT1wNao1VFIsToR/c28rmbfNa3oiSO0o=; b=MM0vSEkOX/zMbnv2pusa54oj4oSKdt63aDzfGOXy5pkqE0w0WC6oorsAqwmQfSnpuA 9NLN+VLN36YEmtUtg/zPU/EbZJn1rTylEDY2ge+LGvE7R9XfZxu6JxRTj4mhVF+HZQzK Qg3Jw909CLuSWl0+IMYBIGW14aKs1bHUFomKzl7YNIsVJ6WKFP71jXkEGp0PuY5fZZfE 84y2Z4rf2X1Ac5TPN6mwyaMBteWhaDdWZ0iebmlKnBzJJGBE4XYPcWCU7Ph7BaZZh5f+ 4UG/qr3rV2XTcY1U1KC+x9gB0qToE4uGc0LjzDv30H5G7bHb2iL/4GW9LtkDRPkgun7L p5jw== X-Gm-Message-State: APt69E1D4CnZT9KdgVv6ywcFFLyq0/0L57rK7QcyKnfkClTWsyr6omXp Pn4yhf2GZ4ROjfIyIjl1nYGev0g1 X-Google-Smtp-Source: ADUXVKIJe5A3nI5xMcUotjE2t4rJtT0cY5UDUr1PK1vj9ZmbBy2gpIJZ+l/HbCtRrWvMy3QWTYeLwg== X-Received: by 2002:aca:cec4:: with SMTP id e187-v6mr7959942oig.225.1529372758223; Mon, 18 Jun 2018 18:45: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 f53-v6sm11180897otd.80.2018.06.18.18.45.56 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:45:57 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:17 -0500 Message-Id: <20180619014319.28272-52-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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 051/113] target/i386: Fix andn instruction 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, Alexandro Sanchez Bach Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Alexandro Sanchez Bach In commit 7073fbada733c8d10992f00772c9b9299d740e9b, the `andn` instruction was implemented via `tcg_gen_andc` but passes the operands in the wrong order: - X86 defines `andn dest,src1,src2` as: dest = ~src1 & src2 - TCG defines `andc dest,src1,src2` as: dest = src1 & ~src2 The following simple test shows the issue: #include #include int main(void) { uint32_t ret = 0; __asm ( "mov $0xFF00, %%ecx\n" "mov $0x0F0F, %%eax\n" "andn %%ecx, %%eax, %%ecx\n" "mov %%ecx, %0\n" : "=r" (ret)); printf("%08X\n", ret); return 0; } This patch fixes the problem by simply swapping the order of the two last arguments in `tcg_gen_andc_tl`. Reported-by: Alexandro Sanchez Bach Signed-off-by: Alexandro Sanchez Bach Cc: qemu-stable@nongnu.org Signed-off-by: Paolo Bonzini (cherry picked from commit 5cd10051c2e02b7a86eae49919d6c65a87dbea46) Signed-off-by: Michael Roth --- target/i386/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/i386/translate.c b/target/i386/translate.c index ed5b69d6af..b667753f46 100644 --- a/target/i386/translate.c +++ b/target/i386/translate.c @@ -3803,7 +3803,7 @@ static void gen_sse(CPUX86State *env, DisasContext *s, int b, } ot = mo_64_32(s->dflag); gen_ldst_modrm(env, s, modrm, ot, OR_TMP0, 0); - tcg_gen_andc_tl(cpu_T0, cpu_regs[s->vex_v], cpu_T0); + tcg_gen_andc_tl(cpu_T0, cpu_T0, cpu_regs[s->vex_v]); gen_op_mov_reg_v(ot, reg, cpu_T0); gen_op_update1_cc(); set_cc_op(s, CC_OP_LOGICB + ot); From patchwork Tue Jun 19 01:42:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 931313 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="qsjtja0w"; 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 418sth6zhZz9s1R for ; Tue, 19 Jun 2018 12:51:56 +1000 (AEST) Received: from localhost ([::1]:38772 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6kM-0002nQ-Ks for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:51:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46335) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5ic-0002FB-Av for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:46:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5ib-0000E3-J0 for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:46:02 -0400 Received: from mail-oi0-x229.google.com ([2607:f8b0:4003:c06::229]:46053) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5ib-0000Dr-DW; Mon, 18 Jun 2018 21:46:01 -0400 Received: by mail-oi0-x229.google.com with SMTP id 188-v6so16660466oid.12; Mon, 18 Jun 2018 18:46: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=ug6xJ20cVSYQTtCWLHP6nZTkiUG2oGKd806uvatKbUA=; b=qsjtja0wP8ChgSEt2z1EnB6jX5q+9znWCBIXTayvIrMVhX2TDkP3XZy8WQycShiHdU AE3sEuCNs4GujuNDGOoXbyGSAdl1d6Bp2CyHDa4S19gvxYzMelWkGJ3DtoafDjiGXJ/B GCYXeROOjGjwbDIXoSOOmnRO+oa8c0zv5xUpLpit1twWAeTIvC7ralnXRZWfPh38fk0g MLj31FKpAzOzsuYQuAUvpEFP0yoAULGR/e3Dk/pbVhJeHTcaZP1vtpVFyJJ0etttduPG sUFXVHQ9dRSlPSZ2xVY8E24gtsdmS0fwkPMXhcEg+2XFrnE8+RVkHBkcnUz1SnqaCmRZ WOLg== 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=ug6xJ20cVSYQTtCWLHP6nZTkiUG2oGKd806uvatKbUA=; b=uT6Ag94Z78iTG08+rCleg8873W0z/w9vwBeW3lTyTgU9JKugtpmA0x9B0hCMeDnLE/ eOu6ntx6RBKOu8JofBKMn8bGdtsNlaEO/o3CrizMrjno70kilVvimZ/QbPBOjcF6Y2NQ KYr8qx2hUCN7Nq2PV6V4Xxil6adVVlyzPVkj1MuwyaO0+rryr25E71KV/TZBO70Ow9Ha Bzzp2i/m2CutGn3+JrvDUngASnWwhosaSIJN7RGYWSj5e4zGo9d/bjirOhaEb/bULmF+ MNIaPIkXq3nIxmdensUboeVa1/SeWTE0nsMiIrV/oNhC3YBwZmy1WGFZ+APRen+And5W xaHw== X-Gm-Message-State: APt69E3yDXsskr3VZzC3Sx4EyaOh5fVY7GM99paoSSMg7oMU6MZCaoC2 0Gt5/xflkTPu9BRIgEUUzU8KFLwx X-Google-Smtp-Source: ADUXVKKpGWTJUftrGGP50GBN44ytwjc9wfbvSZK7pRPzp8sMPpK9nQZQRVVOEnp1TnLoyyWoCtKvsg== X-Received: by 2002:aca:5317:: with SMTP id h23-v6mr7885003oib.90.1529372760221; Mon, 18 Jun 2018 18:46: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 f53-v6sm11180997otd.80.2018.06.18.18.45.59 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:45:59 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:18 -0500 Message-Id: <20180619014319.28272-53-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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 052/113] exec: fix memory leak in find_max_supported_pagesize() 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 , Greg Kurz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Greg Kurz The string returned by object_property_get_str() is dynamically allocated. Signed-off-by: Greg Kurz Message-Id: <152231458624.69730.1752893648612848392.stgit@bahia.lan> Reviewed-by: Cornelia Huck Reviewed-by: Thomas Huth Signed-off-by: Eduardo Habkost (cherry picked from commit 72a841d2a403b56ff894fa007b172dc9bcb3dae8) Signed-off-by: Michael Roth --- exec.c | 1 + 1 file changed, 1 insertion(+) diff --git a/exec.c b/exec.c index 5f8017a5d7..e60ad94a42 100644 --- a/exec.c +++ b/exec.c @@ -1455,6 +1455,7 @@ static int find_max_supported_pagesize(Object *obj, void *opaque) mem_path = object_property_get_str(obj, "mem-path", NULL); if (mem_path) { long hpsize = qemu_mempath_getpagesize(mem_path); + g_free(mem_path); if (hpsize < *hpsize_min) { *hpsize_min = hpsize; } From patchwork Tue Jun 19 01:42: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: 931306 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="r5YRDvYF"; 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 418sn449Lrz9s3C for ; Tue, 19 Jun 2018 12:47:04 +1000 (AEST) Received: from localhost ([::1]:38747 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6fe-0007QT-7I for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:47:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46366) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5ih-0002Jn-EO for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:46:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5id-0000En-Gy for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:46:07 -0400 Received: from mail-ot0-x22e.google.com ([2607:f8b0:4003:c0f::22e]:37972) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5id-0000EY-Bj; Mon, 18 Jun 2018 21:46:03 -0400 Received: by mail-ot0-x22e.google.com with SMTP id p95-v6so20770384ota.5; Mon, 18 Jun 2018 18:46: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=/AkBUeJ0emDX8Gp1VJiDyYrDiNk3WFHEPBbeqTkrfhE=; b=r5YRDvYFEk4jYvc1K7ez3GBIeZj1OgJybyAl0g1GVsKXsXMW1xzTagbBv+krwg1Cj6 Uo6vkaypPvcYgFMUEmIM7s05fqMnuQVvnfKfLBduPOXluqmPBomi93IxaQgeaVVont55 eZcjbAMgpRQ6uO6SdAke/v+ChhKs+SfpxqjjtLhmiYi9y4kqC17oCarux1FioLsD77vx niXtpTUC9V99Ei/gTCRi/t59Ji6C8BrxZw7blpHLH5Zhe9Vf6KpKH/rZMUzECQKJYgKr iE4zdUWRrH1pt2Qmqxj3CAFJZstWqAY09uXGUsmLPyLS8Wpr3XfEVXduzkCs8IF5lBaj Z/Iw== 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=/AkBUeJ0emDX8Gp1VJiDyYrDiNk3WFHEPBbeqTkrfhE=; b=K9C3fIvNAeOMJhbTtxbMQ4Gaucftb9pAzoxPBDJtp1ERjCKWbpAwE+ar3oRQXGhsX4 qx3TLGq6uCLsnrfNzRBQB2UEsAoyNMNXyROfWJKzmLhBuym48JK9HJkMIq9c+wMzabFo qoWUifNlkUQDx2n5CITQLdQ2z1WM/1QVTZaBN18/SCuRLAM5EP/F8oJiK2iYtQek6gEO iruEu29kLG20sowtwjfYtrGkeUYm4y7t+LCJ59TeddULyUmneTcWt+6HDSzkUE+TQb1F k2wJ6jUhXp2WuG4flSIJv3zAV3QaTt07GNAWrmeFdzgTciuFcNTKDZpORtDCK3+BUgEa AvAA== X-Gm-Message-State: APt69E3KFn3056jDlWILqVriVqmGfGJEYmnLdAWmlLMSZX4uCjw9QMpx 6rNZBsR0pNe3KlcWbYSluWTjek7a X-Google-Smtp-Source: ADUXVKISpbjCDudcXEpzEE2Qb8GwhSMYE70cBJkTz244zZn59q5MQ8NH9SJEHHJqpPiiwBBGGK9m0A== X-Received: by 2002:a9d:400d:: with SMTP id m13-v6mr9903470ote.105.1529372762085; Mon, 18 Jun 2018 18:46: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 z96-v6sm7902655ota.28.2018.06.18.18.46.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:46:01 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:19 -0500 Message-Id: <20180619014319.28272-54-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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:c0f::22e Subject: [Qemu-devel] [PATCH 053/113] gluster: Fix blockdev-add with server.N.type=unix 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 The legacy command line interface gets the socket path from an option called 'socket'. QAPI in contract uses SocketAddress, where the corresponding option is called 'path'. Fix the gluster block driver to accept both 'socket' and 'path', with 'path' being the preferred syntax. https://bugzilla.redhat.com/show_bug.cgi?id=1545155 Cc: qemu-stable@nongnu.org Signed-off-by: Kevin Wolf Message-id: 20180403110810.25624-1-kwolf@redhat.com Signed-off-by: Jeff Cody (cherry picked from commit 9dae635afa98f83688806861cefe77ff1b4d76a8) Signed-off-by: Michael Roth --- block/gluster.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/block/gluster.c b/block/gluster.c index 0f4265a3a4..d09f4f2283 100644 --- a/block/gluster.c +++ b/block/gluster.c @@ -164,7 +164,12 @@ static QemuOptsList runtime_unix_opts = { { .name = GLUSTER_OPT_SOCKET, .type = QEMU_OPT_STRING, - .help = "socket file path)", + .help = "socket file path (legacy)", + }, + { + .name = GLUSTER_OPT_PATH, + .type = QEMU_OPT_STRING, + .help = "socket file path (QAPI)", }, { /* end of list */ } }, @@ -612,10 +617,18 @@ static int qemu_gluster_parse_json(BlockdevOptionsGluster *gconf, goto out; } - ptr = qemu_opt_get(opts, GLUSTER_OPT_SOCKET); + ptr = qemu_opt_get(opts, GLUSTER_OPT_PATH); + if (!ptr) { + ptr = qemu_opt_get(opts, GLUSTER_OPT_SOCKET); + } else if (qemu_opt_get(opts, GLUSTER_OPT_SOCKET)) { + error_setg(&local_err, + "Conflicting parameters 'path' and 'socket'"); + error_append_hint(&local_err, GERR_INDEX_HINT, i); + goto out; + } if (!ptr) { error_setg(&local_err, QERR_MISSING_PARAMETER, - GLUSTER_OPT_SOCKET); + GLUSTER_OPT_PATH); error_append_hint(&local_err, GERR_INDEX_HINT, i); goto out; } @@ -680,7 +693,7 @@ static struct glfs *qemu_gluster_init(BlockdevOptionsGluster *gconf, "file.server.0.host=1.2.3.4," "file.server.0.port=24007," "file.server.1.transport=unix," - "file.server.1.socket=/var/run/glusterd.socket ..." + "file.server.1.path=/var/run/glusterd.socket ..." "\n"); errno = -ret; return NULL; From patchwork Tue Jun 19 01:42:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 931308 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="dthUBTIP"; 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 418snx6Pjyz9s1R for ; Tue, 19 Jun 2018 12:47:49 +1000 (AEST) Received: from localhost ([::1]:38749 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6gN-0007vt-Hv for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:47:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46365) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5ih-0002Jl-EP for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:46:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5if-0000F9-GN for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:46:07 -0400 Received: from mail-ot0-x231.google.com ([2607:f8b0:4003:c0f::231]:33927) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5if-0000F3-Ax; Mon, 18 Jun 2018 21:46:05 -0400 Received: by mail-ot0-x231.google.com with SMTP id r18-v6so20783113otk.1; Mon, 18 Jun 2018 18:46: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=rOuwpNiiE+JdCAHr4P1l3+or/iloZktTvGW4y9eDwtg=; b=dthUBTIPndwHy/1GQitVuYlZEmHmgwvqiZLgobqkDF/fLmLFx6irQ7xry5eg6VO1Jg nCDq1BUnjEakjdNFriBlp2/Od3CCGRY5yX4j9Tg7b+4cYErHQ1L51iT6CD8/lGlVlWyj YNhVJN1tSBBe3eJ5pUMN/67JptHPujf56zppHYJGlG5F/WJ3f8ikHSGvtWj7/Wmz0wRV ih1Q+8fVLyAGJSBfJjGvEV7x/3gMa33ZYUKw0a/uwMv0h8xB6f8UdjJsvKf4NdRtAnSc iMnqmd1xgyEhCHqibUYeWUVHIQmhQEPZOLwZUvphUwkbweHQT94BHS6dy0k/IQtXrpLP 1Ekg== 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=rOuwpNiiE+JdCAHr4P1l3+or/iloZktTvGW4y9eDwtg=; b=JzCa/4+V1Si00N5EkQ0E8anSew7pa6S0q1U3hOIN9D6u/56fDgPM0hYu2JEusTeein jr6tPhekAnewRQjU2swVy5fGwlPM3nenUaOLElrDxhP3u6xTJ/NKlway/JIT1nOxnfzI Rn9v8ggieQHIGc8EABvf16Fdy4wWFzjsrxTGfDh6JjrL9yUe6OUbjOFdXXwjFHyq5jdb QJOWQ37gLzJoTcidPjdwBxIMfh/Hh+NLfarE34e5N48U+MfL25V8Cxutp6g17p2DbI/G Tm+fQw7k7NA7CKQ2VAWJy2rw+HajvLToaqVdlblv0GGLB4+deW8vistzUKMxWvOJySGj GAog== X-Gm-Message-State: APt69E3mwOiE3Zp3ulOjQNFVpP9dhd8HyWFEbCnawW0YaRjH2oh7b1bD YJQuVa2dne3r0BZNTiKksHEm8Tyb X-Google-Smtp-Source: ADUXVKJ6j+Hyqo37yF0JuTpJnyPs55/igWSo3s+gM0ZvuQ6WHQtTMWgZhL3ltENBDgQsWC4889Guuw== X-Received: by 2002:a9d:440d:: with SMTP id u13-v6mr9919613ote.374.1529372764135; Mon, 18 Jun 2018 18:46: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 t77-v6sm7294818oie.3.2018.06.18.18.46.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:46:03 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:20 -0500 Message-Id: <20180619014319.28272-55-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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:c0f::231 Subject: [Qemu-devel] [PATCH 054/113] cpus.c: ensure running CPU recalculates icount deadlines on timer expiry 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 When we run in TCG icount mode, we calculate the number of instructions to execute using tcg_get_icount_limit(), which ensures that we stop execution at the next timer deadline. However there is a bug where currently we do not recalculate that limit if the guest reprograms a timer so that the next deadline moves closer, and so we will continue execution until the original limit and fire the timer later than we should. Fix this bug in qemu_timer_notify_cb(): if we are currently running a VCPU in icount mode, we simply need to kick it out of the main loop and back to tcg_cpu_exec(), where it will recalculate the icount limit. If we are not currently running a VCPU, then we retain the existing logic for waking up a halted CPU. Cc: qemu-stable@nongnu.org Fixes: https://bugs.launchpad.net/qemu/+bug/1754038 Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Alex Bennée Message-id: 20180406123838.21249-1-peter.maydell@linaro.org (cherry picked from commit c52e7132d7c885841500f5277f7305f62767fe1d) Signed-off-by: Michael Roth --- cpus.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cpus.c b/cpus.c index 114c29b6a0..96bb688d7b 100644 --- a/cpus.c +++ b/cpus.c @@ -843,11 +843,19 @@ void qemu_timer_notify_cb(void *opaque, QEMUClockType type) return; } - if (!qemu_in_vcpu_thread() && first_cpu) { + if (qemu_in_vcpu_thread()) { + /* A CPU is currently running; kick it back out to the + * tcg_cpu_exec() loop so it will recalculate its + * icount deadline immediately. + */ + qemu_cpu_kick(current_cpu); + } else if (first_cpu) { /* qemu_cpu_kick is not enough to kick a halted CPU out of * qemu_tcg_wait_io_event. async_run_on_cpu, instead, * causes cpu_thread_is_idle to return false. This way, * handle_icount_deadline can run. + * If we have no CPUs at all for some reason, we don't + * need to do anything. */ async_run_on_cpu(first_cpu, do_nothing, RUN_ON_CPU_NULL); } From patchwork Tue Jun 19 01:42: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: 931315 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="lTQhJKzk"; 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 418swD5HLrz9s1R for ; Tue, 19 Jun 2018 12:53:16 +1000 (AEST) Received: from localhost ([::1]:38777 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6le-0003pw-Ak for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:53:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46384) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5ii-0002KY-56 for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:46:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5ih-0000Fb-7s for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:46:08 -0400 Received: from mail-ot0-x244.google.com ([2607:f8b0:4003:c0f::244]:40776) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5ih-0000FX-2p; Mon, 18 Jun 2018 21:46:07 -0400 Received: by mail-ot0-x244.google.com with SMTP id w9-v6so20746699otj.7; Mon, 18 Jun 2018 18:46: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=G4/CnrWRGeHzp/VLZBveCQgvdh57EOJOeTX51ClzTK0=; b=lTQhJKzkWvesDlBen8txLxU/G8wuvQe2RnB6/8s5NJF9Ol5Nb2fIJBsYlZuu31WQoI sAdncMZmiODCCoNC/1TPTn5VgbXy1jcpNXg8FIJx2SRBtnscM67bJAxrpmV5BLe8QOfr ft34lNlMv7UFMkJR5iYYDuYaE4eT2N6fi2H8WBU8hklqiou9zTqmQE5X3IINJWj3r5cm b71LfchQajg53gY27vDhFlwaVsDdasnrQgWTH+7nm8D4RV6PZne0YYAZu58q0YtktTt1 h5a5Na9K+sP0O0u1bP2d901MKArXz/46UtvkTCtjXxQl5KIl0anFMzW+yeaNdggYiwV2 zseA== 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=G4/CnrWRGeHzp/VLZBveCQgvdh57EOJOeTX51ClzTK0=; b=KYVUToUu1nt31TT1FzJ9oE/haOvvl3kmWggrYyVD/Rb0ShmgXOpKDghvsWppeE0HlD zEI7nrbfP2W4TEeVP6bKGR0vzEmIAESqsDUbXckGmY73eRcYv1z71LqaWYHHkHNa1aJw XyGL/ELbanIaBcfFUTi+IAvNGBwzFO8vVk5myGlvZLblgfsjqe9jWc5r80nWLSMRWbmo bnmR+rgXttqBOHxXJurpupxt+TA21ufuHWzj7uOSjW5BJg08Jk3mX9CW2c1Hs4c4bkVJ tWeAhLhjFG/ubxpsdnJQT0baQfqdrjjo5tARRH/xXO1ZXWqSsTYtKCERQU6e6hI26SRJ mqIA== X-Gm-Message-State: APt69E1i9N7y1hAAZXNdjoV41ABniTu4xbolH1wlZ5K4hTrfgG/VZut0 IsFqp9YDhms0+bjjUIj5pCuD/kmp21g= X-Google-Smtp-Source: ADUXVKKKVwl+++71hTFWvV0RoOP3R1uGiu0p+0bcJxZfIoTigC/qLGz1qRq3S0B9ljlJAMOj583pUQ== X-Received: by 2002:a9d:3835:: with SMTP id i50-v6mr9651942otc.382.1529372765990; Mon, 18 Jun 2018 18:46:05 -0700 (PDT) Received: from localhost ([2600:1700:70:e488:b0ee:9bda:ee6f:91be]) by smtp.gmail.com with ESMTPSA id j196-v6sm8557604oib.14.2018.06.18.18.46.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:46:04 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:21 -0500 Message-Id: <20180619014319.28272-56-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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:c0f::244 Subject: [Qemu-devel] [PATCH 055/113] vfio-ccw: fix memory leaks in vfio_ccw_realize() 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, Greg Kurz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Greg Kurz If the subchannel is already attached or if vfio_get_device() fails, the code jumps to the 'out_device_err' label and doesn't free the string it has just allocated. The code should be reworked so that vcdev->vdev.name only gets set when the device has been attached, and freed when it is about to be detached. This could be achieved with the addition of a vfio_ccw_get_device() function that would be the counterpart of vfio_put_device(). But this is a more elaborate cleanup that should be done in a follow-up. For now, let's just add calls to g_free() on the buggy error paths. Signed-off-by: Greg Kurz Message-Id: <152311222681.203086.8874800175539040298.stgit@bahia> Signed-off-by: Cornelia Huck (cherry picked from commit be4d026f645eb31078e08d431c93a898b895024e) Signed-off-by: Michael Roth --- hw/vfio/ccw.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c index 636729c03d..c74e107a04 100644 --- a/hw/vfio/ccw.c +++ b/hw/vfio/ccw.c @@ -357,11 +357,13 @@ static void vfio_ccw_realize(DeviceState *dev, Error **errp) if (strcmp(vbasedev->name, vcdev->vdev.name) == 0) { error_setg(&err, "vfio: subchannel %s has already been attached", vcdev->vdev.name); + g_free(vcdev->vdev.name); goto out_device_err; } } if (vfio_get_device(group, cdev->mdevid, &vcdev->vdev, &err)) { + g_free(vcdev->vdev.name); goto out_device_err; } From patchwork Tue Jun 19 01:42: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: 931311 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="pi3eDgg8"; 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 418srp3rwnz9s1R for ; Tue, 19 Jun 2018 12:50:18 +1000 (AEST) Received: from localhost ([::1]:38759 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6im-0001Tg-4L for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:50:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46416) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5ik-0002MV-3T for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:46:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5ij-0000Gb-7u for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:46:10 -0400 Received: from mail-oi0-x236.google.com ([2607:f8b0:4003:c06::236]:42973) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5ij-0000GQ-2B; Mon, 18 Jun 2018 21:46:09 -0400 Received: by mail-oi0-x236.google.com with SMTP id k190-v6so16695623oib.9; Mon, 18 Jun 2018 18:46: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=4R6ARzY8+8VwJMFZpP/OCG0IArvc4QNiNxh6KffRUaU=; b=pi3eDgg8XC8wdHFaL1XuVYLw8Kt79OpqcWhaIyLWJdZc46aY2McG9KIw27lMIB3cUO ujcqLzZPU8mDAYUQETKs5dpqH5YvphKknp633DrG50PIMpAxDU3g/ubrXkZ63L/wmfMs 4LrqW78J40ZeVZDLePJbFQEr9r7nnzrY+jM66/8AaY0669PkCtWOi/32yn6tpNGwEsQl ck/NugDMJFjwfaZLucD6f3m0RIXAjENFB+2npHNmdUfrv32ff5Rk0oviIY2UuGVOXkRB y8INQW5HF5JRJ+4BJuFYaTcT3rkFhaWMqatsPHEQ7lEGbZdwm4UNoYIYn7KEVkmvqq4V CRIQ== 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=4R6ARzY8+8VwJMFZpP/OCG0IArvc4QNiNxh6KffRUaU=; b=fS28fsNMDzCxroYFKx9Td1+kM28FJRNJkBuSeZ+JI0K8UtrQliXVvFpviG1Q9Oka3h TWSHlyq9Wb7Vs99Nsmi/lLHdFUy5ylYiWLohUTawl8RUvu69OLadlG0RTZ30T1GWeHCs HKPVCfM8xgApMhzjxEGg/0y/1YKk4BYaw6TZKNywvCh8uSVJuEIFFJfWSaUI+EowZ3F0 +6UMPX8brVjD3cYZth+MIvhz28CryQd5ter2SbOJwiVrWI2N91n9+kHWe1OFO/FfSWg4 0EzV03HnVs5VnSC9Oi1rbbYzrKZIG67HM95ymHMmgzEvzSw/S+33RGeJx6tXv/SwZGnn XmDA== X-Gm-Message-State: APt69E0XzBNx8GfVSLNIDMqEbNIbpULeujZX0wBSEMYbs5nYzJIM2q4M 8PktgbGUD43x8KKTqL65jrXAsyh7vQc= X-Google-Smtp-Source: ADUXVKIBzCUVx85Rkv2GGZerJ5UIiN+C70qhGUqd/gVpSsmjGpuJafJrBm8ujsDyLIQIXPBZwIQQ3Q== X-Received: by 2002:aca:b782:: with SMTP id h124-v6mr8713245oif.7.1529372767877; Mon, 18 Jun 2018 18:46:07 -0700 (PDT) Received: from localhost ([2600:1700:70:e488:b0ee:9bda:ee6f:91be]) by smtp.gmail.com with ESMTPSA id q7-v6sm15882369otq.39.2018.06.18.18.46.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:46:06 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:22 -0500 Message-Id: <20180619014319.28272-57-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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::236 Subject: [Qemu-devel] [PATCH 056/113] hw/block/pflash_cfi: fix off-by-one error 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, =?utf-8?q?Phili?= =?utf-8?q?ppe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé ASAN reported: hw/block/pflash_cfi02.c:245:33: runtime error: index 82 out of bounds for type 'uint8_t [82]' Since the 'cfi_len' member is not used, remove it to keep the code safer. Cc: qemu-stable@nongnu.org Reported-by: AddressSanitizer Signed-off-by: Philippe Mathieu-Daudé Signed-off-by: Kevin Wolf (cherry picked from commit 07c13a71721d9f8c690b66752964e254af247475) Signed-off-by: Michael Roth --- hw/block/pflash_cfi01.c | 10 ++++------ hw/block/pflash_cfi02.c | 9 ++++----- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c index 1113ab1ccf..2e8284001d 100644 --- a/hw/block/pflash_cfi01.c +++ b/hw/block/pflash_cfi01.c @@ -90,7 +90,6 @@ struct pflash_t { uint16_t ident1; uint16_t ident2; uint16_t ident3; - uint8_t cfi_len; uint8_t cfi_table[0x52]; uint64_t counter; unsigned int writeblock_size; @@ -153,7 +152,7 @@ static uint32_t pflash_cfi_query(pflash_t *pfl, hwaddr offset) boff = offset >> (ctz32(pfl->bank_width) + ctz32(pfl->max_device_width) - ctz32(pfl->device_width)); - if (boff > pfl->cfi_len) { + if (boff >= sizeof(pfl->cfi_table)) { return 0; } /* Now we will construct the CFI response generated by a single @@ -385,10 +384,10 @@ static uint32_t pflash_read (pflash_t *pfl, hwaddr offset, boff = boff >> 2; } - if (boff > pfl->cfi_len) { - ret = 0; - } else { + if (boff < sizeof(pfl->cfi_table)) { ret = pfl->cfi_table[boff]; + } else { + ret = 0; } } else { /* If we have a read larger than the bank_width, combine multiple @@ -791,7 +790,6 @@ static void pflash_cfi01_realize(DeviceState *dev, Error **errp) pfl->cmd = 0; pfl->status = 0; /* Hardcoded CFI table */ - pfl->cfi_len = 0x52; /* Standard "QRY" string */ pfl->cfi_table[0x10] = 'Q'; pfl->cfi_table[0x11] = 'R'; diff --git a/hw/block/pflash_cfi02.c b/hw/block/pflash_cfi02.c index c81ddd3a99..75d1ae1026 100644 --- a/hw/block/pflash_cfi02.c +++ b/hw/block/pflash_cfi02.c @@ -83,7 +83,6 @@ struct pflash_t { uint16_t ident3; uint16_t unlock_addr0; uint16_t unlock_addr1; - uint8_t cfi_len; uint8_t cfi_table[0x52]; QEMUTimer *timer; /* The device replicates the flash memory across its memory space. Emulate @@ -235,10 +234,11 @@ static uint32_t pflash_read (pflash_t *pfl, hwaddr offset, break; case 0x98: /* CFI query mode */ - if (boff > pfl->cfi_len) - ret = 0; - else + if (boff < sizeof(pfl->cfi_table)) { ret = pfl->cfi_table[boff]; + } else { + ret = 0; + } break; } @@ -663,7 +663,6 @@ static void pflash_cfi02_realize(DeviceState *dev, Error **errp) pfl->cmd = 0; pfl->status = 0; /* Hardcoded CFI table (mostly from SG29 Spansion flash) */ - pfl->cfi_len = 0x52; /* Standard "QRY" string */ pfl->cfi_table[0x10] = 'Q'; pfl->cfi_table[0x11] = 'R'; From patchwork Tue Jun 19 01:42: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: 931312 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="C0tu49ft"; 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 418ssb13Fsz9s1R for ; Tue, 19 Jun 2018 12:50:59 +1000 (AEST) Received: from localhost ([::1]:38766 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6jQ-000235-Lx for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:50:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46446) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5im-0002Ot-FR for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:46:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5il-0000HX-Hl for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:46:12 -0400 Received: from mail-oi0-x22e.google.com ([2607:f8b0:4003:c06::22e]:36396) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5il-0000HF-C2; Mon, 18 Jun 2018 21:46:11 -0400 Received: by mail-oi0-x22e.google.com with SMTP id 14-v6so16692522oie.3; Mon, 18 Jun 2018 18:46: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=ezUafyHTkoYy5utYrpDUYrzLfAPSG5t+PRP0S/F5e6k=; b=C0tu49ftoScXjyJEcBCX10D/i17/qx4MelPHEXLQAsvYwnguPCIyxgf2vHgMelm6IW JvhsmTG6HwHngZ9EvfORtuEzG5mCtbKgnk/lnLw1YFgD/tFhgrLSW4h6TMyTUxcuZmb5 QtRNo46UUCcTgzN2Fpgd2WUbNlkRjy6dw2c5O3e+3ZB1ZDsuALiArGHaJRHpMJM1v3rh cUwYKhdSgGb5B8zNW7gG5tMHHzZG8BYrX/M7QbFFZshKzLZYuIvHyly9d2n0JBRNEPEX ho0vPUYnQUIqUtMkvfGrpkBrrAy+9CSiAuItt1xCc7U/svRnssT3ylLvbJRmfLpT2xEP /FUA== 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=ezUafyHTkoYy5utYrpDUYrzLfAPSG5t+PRP0S/F5e6k=; b=GBnNEgdz8OvJFNHRCqOh6iDISzxFIdIERkMUkNFObI1dxki6XpDZOA/zq8lGooyEuC drxlFsjYHtgTL143MV6xraWQwsEQuj61aDhPJtF7UNERiZQ6HtywCra1RONWWd7VVhhj MkM8aFxGuOc9OeHhJanBEhB6ja1gHv5mic4Os887fBekM51t4AZ3n2mgVQ7CynExDKal 3upg6+nAbmS+ssUJDjfSLyJLmVrA3ZTvMV+mhjs7zgtokACmsw4fkrytflvQw1jjbhqx uFAVsED+kSsAbVHlpQtosVlayR2uVQqdzwsbf2+w/Trv3AonFB6hXQD6x9V6JrTDxJXE sScw== X-Gm-Message-State: APt69E18j+gKyK/jRzJRTLK5i2clwhns7JJvrLQZn8VK3GuRzcjPIQMx v5pVkLX/q+acPBmjhpRrzFWq43PmVXA= X-Google-Smtp-Source: ADUXVKKm6eaoOrLXW1nSyes2gqt2TS9VQN95QCwwemIcyFPwfhsKjyenDlODp2E9GEuOvIxGrupS4g== X-Received: by 2002:aca:f545:: with SMTP id t66-v6mr7738492oih.316.1529372770075; Mon, 18 Jun 2018 18:46:10 -0700 (PDT) Received: from localhost ([2600:1700:70:e488:b0ee:9bda:ee6f:91be]) by smtp.gmail.com with ESMTPSA id f97-v6sm7715853otb.9.2018.06.18.18.46.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:46:09 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:23 -0500 Message-Id: <20180619014319.28272-58-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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 057/113] tcg: Introduce tcg_set_insn_start_param 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 parameters for tcg_gen_insn_start are target_ulong, which may be split into two TCGArg parameters for storage in the opcode on 32-bit hosts. Fixes the ARM target and its direct use of tcg_set_insn_param, which would set the wrong argument in the 64-on-32 case. Cc: qemu-stable@nongnu.org Reported-by: alarson@ddci.com Signed-off-by: Richard Henderson Message-id: 20180410003558.2470-1-richard.henderson@linaro.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell (cherry picked from commit 9743cd5736263e90d312b2c33bd739ffe1eae70d) Conflicts: target/arm/translate.h tcg/tcg.h * rework to avoid functional dependency on 15fa08f Signed-off-by: Michael Roth --- target/arm/translate.h | 2 +- tcg/tcg.h | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/target/arm/translate.h b/target/arm/translate.h index 410ba79c0d..0c6a24d287 100644 --- a/target/arm/translate.h +++ b/target/arm/translate.h @@ -118,7 +118,7 @@ static void disas_set_insn_syndrome(DisasContext *s, uint32_t syn) /* We check and clear insn_start_idx to catch multiple updates. */ assert(s->insn_start_idx != 0); - tcg_set_insn_param(s->insn_start_idx, 2, syn); + tcg_set_insn_start_param(s->insn_start_idx, 2, syn); s->insn_start_idx = 0; } diff --git a/tcg/tcg.h b/tcg/tcg.h index cb7b329876..d88d3520ac 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -783,6 +783,16 @@ static inline void tcg_set_insn_param(int op_idx, int arg, TCGArg v) tcg_ctx->gen_op_buf[op_idx].args[arg] = v; } +static inline void tcg_set_insn_start_param(int op_idx, int arg, target_ulong v) +{ +#if TARGET_LONG_BITS <= TCG_TARGET_REG_BITS + tcg_set_insn_param(op_idx, arg, v); +#else + tcg_set_insn_param(op_idx, arg * 2, v); + tcg_set_insn_param(op_idx, arg * 2 + 1, v >> 32); +#endif +} + /* The number of opcodes emitted so far. */ static inline int tcg_op_buf_count(void) { From patchwork Tue Jun 19 01:42: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: 931317 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="MoKqJaTg"; 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 418szZ3yFnz9s3C for ; Tue, 19 Jun 2018 12:56:10 +1000 (AEST) Received: from localhost ([::1]:38798 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6oS-0006RY-89 for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:56:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46497) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5ir-0002Sk-Jg for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:46:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5in-0000IG-KM for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:46:17 -0400 Received: from mail-ot0-x22c.google.com ([2607:f8b0:4003:c0f::22c]:44557) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5in-0000I3-Ez; Mon, 18 Jun 2018 21:46:13 -0400 Received: by mail-ot0-x22c.google.com with SMTP id w13-v6so20758894ote.11; Mon, 18 Jun 2018 18:46: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 :mime-version:content-transfer-encoding; bh=upoUpTUx54PoqmTgNon2saxWoWBtl1z80fkO6l8JrNA=; b=MoKqJaTgcHo9usj2pryYXS3IQUPA2RmC3R6aTqnhDOHFCrqWyxD4sQN/1AYrQhJt8r H2ZCw42GxdmCWWOF1Jhpbo+Op6onsiFk10x364+VZKUfH1s8K+2bZ037nMcD6l4Jy3aJ C8MH6CUpVbx9TWivYY/fueohcLIr0NYNbhv2QPxz4CDOrtYkqgZ0FPOcTGZS91OHB7vx e1XnbZ3QMtqb4J0B/i1LQkbEdJmByVq/NSzUkk8bSavJutNDeOnoxbp4Q/Mnx/E7VmZw KS3UVAupWt4rDTgLpIcsIGn7UBujpMalxMTBxH6kLzMgtkNOBETJYwSFJrEckWENlqWQ EyKw== 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=upoUpTUx54PoqmTgNon2saxWoWBtl1z80fkO6l8JrNA=; b=ksJmyWv+MQOUoE07njQt6tlPbcIdOJIVNhSKFrq7q6jkZlEi4z4hl5ReJO9bsTCJwN w1j7Qrkf4alvjwKb/eUt5Ie7xlq7LzUge4UeteacG8sNgUyTlu6sgkilD7XXSv1qC+Ym 1UkUkB8fM6P8vunfJJnJPW+ykuVrbPUB687ewNqpHntcfoz14LTrom6zT67ZCp/J9YYT FXw4x1ilEjZ7J0vlNaWoUxHpP08fiD0N3XIEyvzcF20r3vqKfrVbN4zWDemADq8Std0y Ke4uBI06mpCpp5loP7njDRTdmPtmt4IRGDazLploV8GdPSeudTG91QNQJtgZdGUDY1PC zHmA== X-Gm-Message-State: APt69E0egaGRBku9wQEepCmSj4SALYbaW4juWa7oxZIh3+XdlwvBGGTa fa30sXFiYCixNmfrjCgj7V/2kKb5syY= X-Google-Smtp-Source: ADUXVKLofd109RwoO6iJNOOQ/bLSTRbP6WdaJhQCV3cSe3kmvR09JGppBBf7CF7wc8Vhc/CiQ3t86Q== X-Received: by 2002:a9d:32e1:: with SMTP id u88-v6mr9612759otb.173.1529372772273; Mon, 18 Jun 2018 18:46: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 s22-v6sm10290687ote.14.2018.06.18.18.46.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:46:11 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:24 -0500 Message-Id: <20180619014319.28272-59-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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:c0f::22c Subject: [Qemu-devel] [PATCH 058/113] hw/char/cmsdk-apb-uart.c: Correctly clear INTSTATUS bits on writes 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 The CMSDK APB UART INTSTATUS register bits are all write-one-to-clear. We were getting this correct for the TXO and RXO bits (which need special casing because their state lives in the STATE register), but had forgotten to handle the normal bits for RX and TX which we do store in our s->intstatus field. Perform the W1C operation on the bits in s->intstatus too. Fixes: https://bugs.launchpad.net/qemu/+bug/1760262 Cc: qemu-stable@nongnu.org Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Peter Maydell Message-id: 20180410134203.17552-1-peter.maydell@linaro.org (cherry picked from commit 6670b494fdb23f74ecd9be3d952c007f64e268f1) Signed-off-by: Michael Roth --- hw/char/cmsdk-apb-uart.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/char/cmsdk-apb-uart.c b/hw/char/cmsdk-apb-uart.c index 1ad1e14295..9c0929d8a2 100644 --- a/hw/char/cmsdk-apb-uart.c +++ b/hw/char/cmsdk-apb-uart.c @@ -274,6 +274,7 @@ static void uart_write(void *opaque, hwaddr offset, uint64_t value, * is then reflected into the intstatus value by the update function). */ s->state &= ~(value & (R_INTSTATUS_TXO_MASK | R_INTSTATUS_RXO_MASK)); + s->intstatus &= ~value; cmsdk_apb_uart_update(s); break; case A_BAUDDIV: From patchwork Tue Jun 19 01:42: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: 931316 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="VSoeRHUz"; 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 418sxS2QL5z9s47 for ; Tue, 19 Jun 2018 12:54:20 +1000 (AEST) Received: from localhost ([::1]:38781 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6mf-0004gY-Vh for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:54:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46489) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5iq-0002RM-Hp for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:46:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5ip-0000Iw-M8 for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:46:16 -0400 Received: from mail-ot0-x244.google.com ([2607:f8b0:4003:c0f::244]:34691) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5ip-0000In-Gt; Mon, 18 Jun 2018 21:46:15 -0400 Received: by mail-ot0-x244.google.com with SMTP id r18-v6so20783439otk.1; Mon, 18 Jun 2018 18:46: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=k6/w1rpGjiNqRRhCRJUgb2PxWnD89JPo6WYqzRJkytc=; b=VSoeRHUzZKtT2XFwHyrnCOh02lrW8z1CNk2ST+1ogos0KZWGR17SDsdNPe+WULDPBP fRQGp+xBdRTRKbe61EjB4aJO3gc13dFgp5xqDeFmb4oYzejy39eK1OWu8r5S9wCqpZrV O4nxRXj5RcTG7YuZO7ny2baQs2y2KF6XlRlkx6qhkYMcuK/mGqNBgGMVz6+qzBYKpsmQ ZvvdbTmONfZlFJS55+HT00h/gqgTHO/F20QN4AClOYMi6WYhSj5sE379xG3k7TkP5vsz 9uEDZ1bHHF/b9Q2d+KhTE8ToXpNhs/8p/5SfObc02mQW1BDilAwz8dOvytE1RNJPvK58 aHCA== 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=k6/w1rpGjiNqRRhCRJUgb2PxWnD89JPo6WYqzRJkytc=; b=fn3HDIrMjGv6FUhITgSWeg8QCdis93OBqLOGwygMzqHlCGzZ7+7cHNr/LPOmNhdtEz 9NIyq97ygtE/09JP9/2rvCeRIUkaszQaJojWS7pV4ONnOLIidFWCwxfj3oBzZZ28rVNb /MoIBXV5RJVrrBZOprBeenFH0wKZZGBb0rpA6zX/y0S89QabuFP2SdD7T3XNX5015Nhu o4bSkR6RoJaggJqyF3casEqYusTLT3Hyay6DO3U3LEJGYj+CzROmyLkSGJCicTCo+63U NUJqA29HVxcnOXBBpygSO78NgyhDkXgdqtSxGRehqfQ952E5LJfYxdSsWX8D+O/+VURt uxnQ== X-Gm-Message-State: APt69E10S09BC4g84sZdNpDgyVbI5xaxZ4bUQgHO8tFkXejGpzpG2fys YFcdeX9PYO38IDb7psc5diubhGPVvvY= X-Google-Smtp-Source: ADUXVKJzOas8ODjunNpCgKl20L1H+yNWHOQP0AXEgQ3GplEOvp+yMYimKgqtZoDAItrLS1zWwsG63w== X-Received: by 2002:a9d:3663:: with SMTP id w90-v6mr8571663otb.96.1529372774340; Mon, 18 Jun 2018 18:46:14 -0700 (PDT) Received: from localhost ([2600:1700:70:e488:b0ee:9bda:ee6f:91be]) by smtp.gmail.com with ESMTPSA id a52-v6sm12159480ote.30.2018.06.18.18.46.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:46:13 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:25 -0500 Message-Id: <20180619014319.28272-60-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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:c0f::244 Subject: [Qemu-devel] [PATCH 059/113] 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 a24ddff02b..9eb5fae738 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 Tue Jun 19 01:42:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 931320 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="Lgv2oJpN"; 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 418t0r3Whkz9s1R for ; Tue, 19 Jun 2018 12:57:15 +1000 (AEST) Received: from localhost ([::1]:38807 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6pT-0007Gm-N1 for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:57:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46512) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5is-0002Tm-Jv for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:46:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5ir-0000JS-Ma for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:46:18 -0400 Received: from mail-ot0-x22e.google.com ([2607:f8b0:4003:c0f::22e]:32870) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5ir-0000JE-Gs; Mon, 18 Jun 2018 21:46:17 -0400 Received: by mail-ot0-x22e.google.com with SMTP id h6-v6so20792175otj.0; Mon, 18 Jun 2018 18:46: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=0T9QhLYwUdFfWjsaVo/KXFxtgS5rAt2072PnezkWJkw=; b=Lgv2oJpNzYeZ9403BsFQVq8uvV2g+SulM1vxtuagE5cOXIgQbwkSU+QqsVeUPexHNk S5RA7oPiJ7Zb6oFviev1br7Knf6L6i5GBQBHNp00EH3Upt9Ewuy8ePTPZXX81BM18iOO vnq0FrlTJWY/nh2oNc8pcgY+qk58IY92swXwW7RclMJaNeyVul8QgvFI0lvW5GDsklsk OoXe/+AjcaudLUZpUDDXx48ZmYVNo9ST6e5kPw9nDpFij6oyl8vjWspgs1HIyN9ymV0R qIYFlKv9NOk9KaIp30s+rkrePy5HSGlCYxC91flnApotmI9NJgEp8lVaczw3gFoa4ntz kGtA== 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=0T9QhLYwUdFfWjsaVo/KXFxtgS5rAt2072PnezkWJkw=; b=gRZu1e07STR6xCorG0QtvFdSNcr5ZCFRqreKy/f6291E0jTn+EiYq9yp5euFJoII4/ 2UyJ95EQOWHcfDcur6aqYJ86Ng+LEiG3WT9XAsb2ziXAzq4Ug7An2jlGPjuvJ+CvT+4p HXh0G25nb4bsjJNX93SvGy7+YmHAeksY/WLVho7c71gvm0cc6QtdbLVeavtsdYB9XG01 WOuEiDyKIhov2U7lx0lCtNSUHvkBoLSRPb2wkNVF9seemGLbbNNZI4I91BqiXS3Hsq6G i5KeUo0kCam6eJsSzEh13Ddp1sGmJ3OBUw9p55kYa01SSG7np54kv3y9l3jO62pUkYvK NbGA== X-Gm-Message-State: APt69E1FNBsmYyeIInViUcne1Vb/YhkK3VBYw67T4JjtXX4R+ukWk89K mYhVMGDUqjedCw3mr03aU0rwaMcpN0k= X-Google-Smtp-Source: ADUXVKJkZBFOnXOxS4fcR2IpJ/CF5gONr+19aR3V2zDdzZiH4im9Bdix+Kj1bTCFNPjPF/jgcg4V2A== X-Received: by 2002:a9d:126:: with SMTP id 35-v6mr8520652otu.167.1529372776120; Mon, 18 Jun 2018 18:46:16 -0700 (PDT) Received: from localhost ([2600:1700:70:e488:b0ee:9bda:ee6f:91be]) by smtp.gmail.com with ESMTPSA id t7-v6sm7582154oth.12.2018.06.18.18.46.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:46:15 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:26 -0500 Message-Id: <20180619014319.28272-61-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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:c0f::22e Subject: [Qemu-devel] [PATCH 060/113] 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 e334d3be11..4be60a8310 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 Tue Jun 19 01:42: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: 931283 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="a/rHP47k"; 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 418sJh3cxyz9s37 for ; Tue, 19 Jun 2018 12:25:56 +1000 (AEST) Received: from localhost ([::1]:38611 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6LC-00071H-3J for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:25:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46580) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5ix-0002ZY-Q9 for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:46:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5iw-0000Lx-SJ for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:46:23 -0400 Received: from mail-ot0-x230.google.com ([2607:f8b0:4003:c0f::230]:32872) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5iw-0000Lp-N5; Mon, 18 Jun 2018 21:46:22 -0400 Received: by mail-ot0-x230.google.com with SMTP id h6-v6so20792322otj.0; Mon, 18 Jun 2018 18:46:22 -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=oy25+ZaVV7xsey0Sb3QeP29b1RUA74k4kYyQKvloSu0=; b=a/rHP47kF1X4QX0kBnZ8b9b1CR/9IAQOYUsLpRpZFnM45qbc9S2VJK5XdmofidwBBI 8zcvn/DokgXAqBmGRYY2Rw2z9fna9u1Q5p7MBJIbxu53hh8GqP5IKsgdyqMmCENdSenv OV39LCdisr//y0gJY8lhhf+VstVtxExOwsjZIWxRgD8Arzw/LxfXcQH93MrA7C5EjFre x0rE5ZfnrBb2OjIvR7mG4DD1Z/fmtfuhoxJQYSxzLfJXYNqDV+kR7RwNdGUoXFwohRuf 6i7ksHBjNYMQn/RVO+3xBjZ/MVTQibRgq2I/VmLJw7mgj1A6C7GFjiWUdiJk5ZfZu1Ba +Icg== 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=oy25+ZaVV7xsey0Sb3QeP29b1RUA74k4kYyQKvloSu0=; b=ELg3EZKdrgc1XbTmudxJCjJZouF4lhrQP6epBaAhmccez4k99Z4vG4B+xQcgL6pvh0 AgDd8aj8ry5eOZnhuRugOie3Y+pTKNbM464zcKR4GgX/EYI+c358dsVmyPI4eDWueitO H7BPxKx2guoPcmdQ0aNCvJ5r3OqBXoaYbpWYDknjVgyVdyU+B/2mvz+qdqhXHwEWddeo ji/Qlwt1kv7CFGsruboy5oSzVFxQLTmH9FIgaXd96wpmZfWrRxkQj8lc/D6FcVeMYZ4P VtBnU7hGjsUv5dXpyvkx0fUdX9J1a6DtcuxzTjjXFRcviydtS6+noKUKgwz0JdpmiIFO M3yA== X-Gm-Message-State: APt69E3hFh84kESLgvew/E9/FaxX1nb9/3/uJ+VpvA7gj7wCAjIm+xsl 0fibhGoxATEOvfksmOZeTrJeJ4SbEdo= X-Google-Smtp-Source: ADUXVKJuKm693ZLMmARVoXVD4zYnHpuy6CpR250OjIWA3C+KD80wrIkqY0IwWsSVYcgKJf0FDeooOA== X-Received: by 2002:a9d:272c:: with SMTP id r41-v6mr9810900ota.46.1529372781542; Mon, 18 Jun 2018 18:46:21 -0700 (PDT) Received: from localhost ([2600:1700:70:e488:b0ee:9bda:ee6f:91be]) by smtp.gmail.com with ESMTPSA id b12-v6sm6813055oiy.43.2018.06.18.18.46.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:46:20 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:27 -0500 Message-Id: <20180619014319.28272-62-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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:c0f::230 Subject: [Qemu-devel] [PATCH 061/113] 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 eea236ca06..0906d7b2c5 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 Tue Jun 19 01:42: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: 931324 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="gMjSnWFh"; 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 418t6X4bwlz9s1R for ; Tue, 19 Jun 2018 13:02:12 +1000 (AEST) Received: from localhost ([::1]:38864 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6uI-0003CB-BE for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 23:02:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46651) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5j3-0002e3-6A for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:46:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5iz-0000Ms-2n for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:46:29 -0400 Received: from mail-ot0-x229.google.com ([2607:f8b0:4003:c0f::229]:47065) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5iy-0000Mj-UJ; Mon, 18 Jun 2018 21:46:25 -0400 Received: by mail-ot0-x229.google.com with SMTP id v24-v6so12228704otk.13; Mon, 18 Jun 2018 18:46: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; bh=Gkw1g3XCFkrXU2javTcEWVy2J1meRvRzlxfdIx4+afg=; b=gMjSnWFhPQ0X6zZGprYfM6TG85yhC3OhCdW61x51ZbaAJi8XmMlF5fy0COUgnO5qL6 gYv4QT2fniEU/jy9aXom9GAO5k2vgkrvWFjwoaNw/UDHd6lobLb0RYT6wUXMtHPid9eK lvl5uvkS9gUUcUGzCaHymOczTaP/AsFlkPeZ/08RJfAOlyr8YHdAPnPYU8i2e+/uBcVC FGfAZVaKtBYWbzI/KnvTxLAQaSlD3CaXI3R4ePduc9zQLGnJ0EK0m9Q+lJgS0SQNMa9x k0Wrhr8d0LQ945F7IL6+aTaI+yVjKFI0E/XuO8TmxHmR+h+DFGqnMdjFjz4epq7syN55 5FJg== 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=Gkw1g3XCFkrXU2javTcEWVy2J1meRvRzlxfdIx4+afg=; b=kgoz5f12qhtZEAkWHe8BXPmiMyU18jTP+Hx6/pZnbYFolnVxEOCwxENw4pjUIDAzW5 mJOF2Vt7Bsbyb0BnAhtnSBMVjoK0CW1JXrlnGZZhY8iUO0luIFOlsJoQbZPLZIKKX/fu twMZ2uEPUkceaLnkEEQS2bL8xUgb14iF3WYNaUCNcFkjKtnOS/LWCJuZ6KAJ62jMs+K1 98Uty7WDiW+kAR0Rr8oCQvw0ZunRZpy7F1vg5FTPldpyFEgqnDJJcjwti4M0BjIKhFBV V4qsXACY6iJeHROOENU/HG54Hzu+tOT2G/bBdQABuIXboGBM+ZCxBJSV37zHT8s+iqiH cHbA== X-Gm-Message-State: APt69E1ma19Iditb8x08RxIDpI4mq2UAgbMNK19E2TO8VHG4GBdJjJLJ vqz9PMIMKFLVZylyP/M9m20qCOTyF3w= X-Google-Smtp-Source: ADUXVKKWIoTJDBk4NpdlawMl9ly3Efe0ojIQyFwyLWQ/XPCM9rTxOz9JzgxAPeWGRnHlOCHwtNQRXQ== X-Received: by 2002:a9d:3351:: with SMTP id u17-v6mr9964899otd.221.1529372783753; Mon, 18 Jun 2018 18:46:23 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id j65-v6sm8103385otc.21.2018.06.18.18.46.22 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:46:22 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:28 -0500 Message-Id: <20180619014319.28272-63-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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:c0f::229 Subject: [Qemu-devel] [PATCH 062/113] s390: Do not pass inofficial IPL type to the guest 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, Viktor Mihajlovski Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Viktor Mihajlovski IPL over a virtio-scsi device requires special handling not available in the real architecture. For this purpose the IPL type 0xFF has been chosen as means of communication between QEMU and the pc-bios. However, a guest OS could be confused by seeing an unknown IPL type. This change sets the IPL parameter type to 0x02 (CCW) to prevent this. Pre-existing Linux has looked up the IPL parameters only in the case of FCP IPL. This means that the behavior should stay the same even if Linux checks for the IPL type unconditionally. Signed-off-by: Viktor Mihajlovski Message-Id: <1522940844-12336-4-git-send-email-mihajlov@linux.vnet.ibm.com> Reviewed-by: Christian Borntraeger Signed-off-by: Cornelia Huck (cherry picked from commit e8c7ef288abb05b741a95418ee2de85c1071e0db) Signed-off-by: Michael Roth --- pc-bios/s390-ccw/bootmap.c | 7 +++++++ pc-bios/s390-ccw/iplb.h | 15 +++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/pc-bios/s390-ccw/bootmap.c b/pc-bios/s390-ccw/bootmap.c index 67a6123ed4..bc01bbccbe 100644 --- a/pc-bios/s390-ccw/bootmap.c +++ b/pc-bios/s390-ccw/bootmap.c @@ -50,6 +50,13 @@ static void jump_to_IPL_code(uint64_t address) { /* store the subsystem information _after_ the bootmap was loaded */ write_subsystem_identification(); + + /* prevent unknown IPL types in the guest */ + if (iplb.pbt == S390_IPL_TYPE_QEMU_SCSI) { + iplb.pbt = S390_IPL_TYPE_CCW; + set_iplb(&iplb); + } + /* * The IPL PSW is at address 0. We also must not overwrite the * content of non-BIOS memory after we loaded the guest, so we diff --git a/pc-bios/s390-ccw/iplb.h b/pc-bios/s390-ccw/iplb.h index 890aed9ece..40fc2d8e21 100644 --- a/pc-bios/s390-ccw/iplb.h +++ b/pc-bios/s390-ccw/iplb.h @@ -77,16 +77,27 @@ extern IplParameterBlock iplb __attribute__((__aligned__(PAGE_SIZE))); #define S390_IPL_TYPE_CCW 0x02 #define S390_IPL_TYPE_QEMU_SCSI 0xff -static inline bool store_iplb(IplParameterBlock *iplb) +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; asm volatile ("diag %0,%2,0x308\n" : "+d" (addr), "+d" (rc) - : "d" (6) + : "d" (store ? 6 : 5) : "memory", "cc"); return rc == 0x01; } + +static inline bool store_iplb(IplParameterBlock *iplb) +{ + return manage_iplb(iplb, true); +} + +static inline bool set_iplb(IplParameterBlock *iplb) +{ + return manage_iplb(iplb, false); +} + #endif /* IPLB_H */ From patchwork Tue Jun 19 01:42: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: 931322 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="HLmmaqfV"; 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 418t3w4C8Nz9s1R for ; Tue, 19 Jun 2018 12:59:56 +1000 (AEST) Received: from localhost ([::1]:38826 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6s6-00017V-1f for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:59:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46652) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5j3-0002e5-6I for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:46:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5j1-0000Np-DJ for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:46:29 -0400 Received: from mail-oi0-x244.google.com ([2607:f8b0:4003:c06::244]:44565) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5j1-0000NY-7h; Mon, 18 Jun 2018 21:46:27 -0400 Received: by mail-oi0-x244.google.com with SMTP id c128-v6so16680060oig.11; Mon, 18 Jun 2018 18:46:27 -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=aOrKmW2sd4tPob/8TzwsyM9R8BlFiVTlufQmA5RfQIE=; b=HLmmaqfVEJX4+LWhNmCeh9YdasRmuDTohTHKBPusKIZD8n7QGnesUcs/i6USJVaAyc fxNIpI+WdbbYoEYbkc5mOHf9VxcYcfQtQNSv8QP4Jxv7LgmJl/5BNMiu66zxqlfgg/NY GvLNDQjV3TFdxx7mUA8PSONifblq9rdtd80vBIDdhddSNeELII+14A8ZqalkZN9tE0lF F8Ua6KVC9ZPNvQkhWay6sooMfd/QEd7l/IIZbfuh9+D0b9sMbWDvfpDyik9K7Ec8Et+E Ox+sf2cYsLUWYD+lt/pwLCScW9sfyygqyU+jw46kAMkxow2ICw5Z6/DX/Brg9sdF1DKE hxZg== 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=aOrKmW2sd4tPob/8TzwsyM9R8BlFiVTlufQmA5RfQIE=; b=BDDUbDz+/ORy1efpMtzTcRZSkBpLqXwsyRAmQ6Bv/AZxDgDum8tY90oYOJrFH9nFMX ehBqce3pYgMTtsUpJuVGgpTsqKfv7NMIgdJWxWkKQ5iN1lYTB5gBzD23GzIzFBPe2BqH Rv7bYvBJx9VJg5Rrj+Zn+Cf6NaaAjb3TSSSHkf4Qw/I9yeaa2d2yncszeFYVultfeDAc K2EvTE1OBa6iJulg/k/b0Vm7vq4/ULtP65mrBepFQ4gpCQ2kVZexb9YQRPUIK2zXulRd p9c6S+SFr5zDmRFaeq6i42tfSTIM/eNZhxNrkQ2VsLTCNFWfntCfuRiNXh5OeIPh+p68 tjcQ== X-Gm-Message-State: APt69E35MoGMKfDaPfOuaomD7TtO6NOS76SkhpQny2nJBM/QNuRb5ym6 kpAcEwjEOudwi14DrFn1228THmYR3z0= X-Google-Smtp-Source: ADUXVKKpVkMEKlfZmA6W9MPkv0i/AQIzeugBRewADYEiVaoLgwQ5Ck20CRASCyeb1d+lHlitZxHCEA== X-Received: by 2002:aca:61c5:: with SMTP id v188-v6mr8897866oib.28.1529372786072; Mon, 18 Jun 2018 18:46: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 a41-v6sm10863875otj.45.2018.06.18.18.46.24 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:46:25 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:29 -0500 Message-Id: <20180619014319.28272-64-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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 063/113] 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 40fc2d8e21..da0cab0102 100644 --- a/pc-bios/s390-ccw/iplb.h +++ b/pc-bios/s390-ccw/iplb.h @@ -81,10 +81,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 Tue Jun 19 01:42: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: 931327 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="qLPIFBYG"; 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 418t981RLHz9s1R for ; Tue, 19 Jun 2018 13:04:28 +1000 (AEST) Received: from localhost ([::1]:38880 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6wT-0004us-Qk for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 23:04:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46669) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5j4-0002eI-Gz for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:46:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5j3-0000Ot-La for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:46:30 -0400 Received: from mail-ot0-x242.google.com ([2607:f8b0:4003:c0f::242]:46322) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5j3-0000OY-GK; Mon, 18 Jun 2018 21:46:29 -0400 Received: by mail-ot0-x242.google.com with SMTP id v24-v6so12228844otk.13; Mon, 18 Jun 2018 18:46:29 -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=BguzolFWXl+W3ujQpdUm/+0lbazkkDZNVKMZ88T52Y0=; b=qLPIFBYGcioZsKk/vkrX8cpFrtMzebcCKaVIZFJEHcvVey4EtAbfH/IjeuLSF0/a7p sCj3+VzAUHBSfQdGlnqivKRtWDQWk0fLq89U6FNFFwMEYyXniVsdYFIjb3uylloGt57n ZlwVURpnOq/UIKUyEcagM7i3BDbo7tnIBw/NXxyHkO1icMqUuoXzQRPUm628nR0juTpP 2rILYTMJbAci5DctFT+FJHRk7ERYlxIPVc3c3z0XPUC4zNxpcUvJpEZlotB9ZsO32LWX X04HR7hB7rBEpmGPBsNw+BPXOk8RL185iH5vdTHsEtM0ITBoH7s4gSc808kIwKWkpAq6 y3dQ== 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=BguzolFWXl+W3ujQpdUm/+0lbazkkDZNVKMZ88T52Y0=; b=f5QUA3hiazKKBT/DuoodHWqAghj2BNBtWeRl8pXq5ZGEsLgIMJyAdjDR05QmdZJvQg xP9J8tb2x2SORhan5mrt18PKCwrv9esAWpFNf+1DBaqm1N4cQtgn/ERoiO+lQ3kD0LHT F+ye7Ec6mLJyf2G0DX8Fp69XVYQdrxqw4kZg4a9YytI/nCNHagJTD6bRnyRZHh3pHhj7 car9ymOeagjsr6JRZRiNMoINcxHDygfPMDsjLAMnte41lm9foFNlwBL4SKJ2Ilsmw9iw S+JpEQPL6nMHEjkw7EOeqUcOQMvhj4xqvNaVx3se0j8Ovg6wjbZBs4x1dDwnHg98Fevy ymkQ== X-Gm-Message-State: APt69E0TKXWiLcOnfQZi1ugO//GCqXhb47OMDCc83Z54TmZZ63c+V+V/ LqwnljONEl8nRZlEnl1JD03yU7jZdFY= X-Google-Smtp-Source: ADUXVKK/3VDkdEVgICNGcodu8WTpeLwZZN5kxcFrn8nD1Oloa60DbYvi6fVyYyKvPv0m95I95DqSJA== X-Received: by 2002:a9d:4c02:: with SMTP id l2-v6mr8724075otf.242.1529372788378; Mon, 18 Jun 2018 18:46:28 -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-v6sm6630390oia.35.2018.06.18.18.46.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:46:27 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:30 -0500 Message-Id: <20180619014319.28272-65-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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:c0f::242 Subject: [Qemu-devel] [PATCH 064/113] 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 98a12535a5..ccbd324262 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 Tue Jun 19 01:42: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: 931331 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="L4QRiqXB"; 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 418tCd5rJMz9s1R for ; Tue, 19 Jun 2018 13:06:37 +1000 (AEST) Received: from localhost ([::1]:38895 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6yZ-0006sz-Fv for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 23:06:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46708) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5j6-0002fP-R2 for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:46:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5j5-0000Pa-Oi for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:46:32 -0400 Received: from mail-oi0-x22f.google.com ([2607:f8b0:4003:c06::22f]:37063) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5j5-0000PL-JQ; Mon, 18 Jun 2018 21:46:31 -0400 Received: by mail-oi0-x22f.google.com with SMTP id l22-v6so16718271oib.4; Mon, 18 Jun 2018 18:46:31 -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=8IvJppQ7K4e0ec4Tu1tPfeuKWzXeZ7Q12FRDR3t1nJw=; b=L4QRiqXB+FpaCw0IcmN5CSFcAO4EF4kC13XkfJxi6TRH/okj6AMZcc4R127dKTWJmR vPV8xkSaWeUedSfxMVoi457VBBy4DK/6A40sZb9E6G1GYeoeXVIzVg0hpcC0Ek4E/StF q2Rg1b6cndV3AcNTftGozLYPRWxKwBqD4d5GfQtcuzUB/o4Zqa6FrMQMOso56R9s2lf5 gZ0C0GxaGtZtt5EsEFoFsdefKjyBAJ+J8WLZxSeChzdbKXxzP1p3qbwI4byC/Ub3KK6D q7krkfjLGio7kMXV5nwMpOFDPNp1G1EDUtx2fZC9KhjJChQM9DS2Y71pIekiDVQarvWf LVDQ== 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=8IvJppQ7K4e0ec4Tu1tPfeuKWzXeZ7Q12FRDR3t1nJw=; b=QV/VPtnaIpZLz/MB6KVYEE1knsVNxStpP4kJ7ueCVI63BZyP/cJjahvRhu/uxjI1YS g8bmnXcq12qHstkC4GkqXGzMRdB3eep+MmYGw1D1vHsUzde6GZk3WNwlC+o4Zfle3l6D 0fXaHe7TJtlwgiHVKtNZwhACWeq8myqsgtl/vAxrR44zsa0udrEXMkE1Unhwun95alHR WcLgh+cb+/UjHfAAFC501xYCICuwo7YFR43jqdBl3mXeCjlnvSIs7gO9aSF47E9zy5Je CeGUjkUrajHW44QodZKc+9rD0gDHtF4Qd4BMMAZ1mU3BkHo/oD66oFtz2PFawhcozzDi v+ew== X-Gm-Message-State: APt69E0auGY83e65oEuNaxSgftZOW+4dDtlziWbKTpEGWOZxqhRwHo2e RrmZNApn9xS9u7lSSYOVZSsj8U67sLU= X-Google-Smtp-Source: ADUXVKJ3X2FLaaZH4d+s1tUTqhLn2HoQsr6/meK9nZeYu27b6bAK0l0ZQvQHUGuFYxpASkx+ue38wQ== X-Received: by 2002:aca:501:: with SMTP id 1-v6mr8584115oif.217.1529372790390; Mon, 18 Jun 2018 18:46:30 -0700 (PDT) Received: from localhost ([2600:1700:70:e488:b0ee:9bda:ee6f:91be]) by smtp.gmail.com with ESMTPSA id z44-v6sm9636236otc.46.2018.06.18.18.46.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:46:29 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:31 -0500 Message-Id: <20180619014319.28272-66-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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 065/113] 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 f120932f44..a8e8168a06 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -10511,8 +10511,23 @@ static int 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 Tue Jun 19 01:42: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: 931325 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="Y1jOGUmO"; 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 418t7X5ZqLz9s3C for ; Tue, 19 Jun 2018 13:03:04 +1000 (AEST) Received: from localhost ([::1]:38872 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6v8-0003p5-D8 for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 23:03:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46730) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5j8-0002hA-KZ for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:46:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5j7-0000Qm-P9 for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:46:34 -0400 Received: from mail-ot0-x244.google.com ([2607:f8b0:4003:c0f::244]:42760) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5j7-0000QY-KF; Mon, 18 Jun 2018 21:46:33 -0400 Received: by mail-ot0-x244.google.com with SMTP id 92-v6so20761714otw.9; Mon, 18 Jun 2018 18:46:33 -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=XO3xLv2nVNNZizsElZCHP2rld+H3I5aK+P4ErQU1/Uc=; b=Y1jOGUmOdj6PJhZbYMC1C/Blbz1lbvPNSqpyD+RNJO2R2r9fhTWPIesOaXyEpAB5B9 MJl7ySk5vIa5osMNv3NDcgQXcdSN9NXsKkRaLWiVeI3wK1Hk8TbohlFYIhZ1hiALLEJv JZMeJ6H8f9Y4Ixsgwbz/+AS2F5ZWnTV+v4jsV9TmId29Fk6TJ9LIrllmD2tywoKoIzIU RcSz1WdyCSyRyMOsXg2lVGJwPZQeXsa2jUn6VumLpiPkIfZjZdF8TrqBLzEQuSZw8ko/ fJj1TX7LN2DY0bgVm7YmjUgYucsbM8WaGJqp+UMHy2uTnLLMBnNv3+lHhRqFdlDpV/zC +z0g== 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=XO3xLv2nVNNZizsElZCHP2rld+H3I5aK+P4ErQU1/Uc=; b=jYobJu5tX8nSStmjFvQXhICrzwv4sE8VBjrmzJSPQEKa2u9zDP1ScuvrHwx5foHfBt Ta1pEZnhr5CPaiqfAX8llcT8hEH63U8wahudlD400f5TDtqnM7SoV/pEiJTGD5C5D6Na UoN2hx6WAXMWWtuzu/u0q3lhdLpZF9UC1lzYpPDFxAr2WfnACWh93NmcUzYPrnU+QfhP Bai9HcXSBPp6CcydFRP1Q+FcRxvdbNH0Ud2OcdDyEDL9CT7aQZg9PMKtj26a1+C0dVwG aYhQiu2/fctrbRvqZ5ANDSCsOCoXzRFyin+MmiiMvgvnVzAVALHhFbhzIvUBIarfjHsf 5vAg== X-Gm-Message-State: APt69E3orkXjijQGGsYikRHsgo5zCvDAp4/fWuOQpBCxby3+bi/45DAB sM6oycZyv3s4iHJmNUQpik4pVXbU2H4= X-Google-Smtp-Source: ADUXVKKSbZVHmNLDKvIiF4cAPN//6XcyxYKC4gjzAHbUGw99Y/qxVqhA0GusT6GBEYUG5JOc+grT1g== X-Received: by 2002:a9d:70d3:: with SMTP id w19-v6mr8477232otj.147.1529372792482; Mon, 18 Jun 2018 18:46:32 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id p128-v6sm6852482oif.21.2018.06.18.18.46.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:46:31 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:32 -0500 Message-Id: <20180619014319.28272-67-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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:c0f::244 Subject: [Qemu-devel] [PATCH 066/113] 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 e475206c6a..feeb449e4d 100644 --- a/target/ppc/machine.c +++ b/target/ppc/machine.c @@ -192,6 +192,11 @@ static int cpu_pre_save(void *opaque) if (cpu->pre_2_8_migration) { cpu->mig_msr_mask = env->msr_mask; 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 Tue Jun 19 01:42: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: 931318 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="ZJKcR+bl"; 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 418t080QJsz9s1R for ; Tue, 19 Jun 2018 12:56:40 +1000 (AEST) Received: from localhost ([::1]:38803 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6ov-0006pK-K8 for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:56:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46757) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5jB-0002kH-I2 for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:46:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5jA-0000RW-GM for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:46:37 -0400 Received: from mail-oi0-x244.google.com ([2607:f8b0:4003:c06::244]:35012) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5jA-0000RQ-Ag; Mon, 18 Jun 2018 21:46:36 -0400 Received: by mail-oi0-x244.google.com with SMTP id e8-v6so16715150oii.2; Mon, 18 Jun 2018 18:46:36 -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=9tjAKbPgny696731XBfyhj+4ngyr+HgUq64S7Qf3juk=; b=ZJKcR+bl35bN29b1VqJfQGMbyZ93OvW+5qLVG/Y4fe1Rg2DCmgeoZJhTTxpJAUzeap 8WaNgrzOM/XQSdoJXsFRbaEcNQ7WguoO+nwgoYGzrDwyLOdGqpWe6EvhilVq/1JI677F dXR+jSj0d55GOiqJGChdaF7qdFVL/+fMyt52NGwd2azF5XMQEfCeKoYHV76boxs//rI/ 3ThryIxLZtIfNL3rFv2/h0e+c7747l6o0XlnVV6a7LClW/HhDN5TnkynGdp1anQ7+r0O JaXPty8UvmTIzAQhxKWHi/WA9BlvD/gNqNLhSAv0cDrH4My0Ao9IcU2+FILsKDpR/O4X yWyA== 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=9tjAKbPgny696731XBfyhj+4ngyr+HgUq64S7Qf3juk=; b=jgH/yS3l1/Cvklni5xRG4UxwEnhaVBN99wUl0w4y9PpQgGgTOpA43Q5hCA+3AasK6o N3+ugrwTOL/wNzP/mIscSJJTSkMyRC+RVpgr4CxsMBL2MVKfKCNEqfC8JgdWiTWTGEjo oZ8eUS9rPVZpbs5ABIcbv7PEKfuMQp3H4EdzRuYir/Gy7wZ1Zk9Gvc4zP9b+U70oSeM5 hIDaPtOfR2kXT9ONYLz6xNjANB1r5bwQyRjQPsHRd8mu9574oMhWCBrG0jRnkjnSC1Sj ZHiTqE+JsftWkrlLUYCggHVQvDyZLRdkVvwaxhKKEO4VDlRtReJcyh2roQnCmes8GoHn uP1g== X-Gm-Message-State: APt69E2LLUgdd3tC9RIIYCFe4RTRjGlo6S3UZ5ZAJHA21PW8nY2Mjven hCqFAiGbUk+DsqM/gos8iU/C+rGuq0U= X-Google-Smtp-Source: ADUXVKJD9/2Jqv4vZwrXuTcmXT03a9ClgSG2D+cyBXoskW71plunWiv9EyiTOcuJAs0awbStbfoaZg== X-Received: by 2002:aca:75cc:: with SMTP id q195-v6mr7736064oic.292.1529372794979; Mon, 18 Jun 2018 18:46:34 -0700 (PDT) Received: from localhost ([2600:1700:70:e488:b0ee:9bda:ee6f:91be]) by smtp.gmail.com with ESMTPSA id q45-v6sm8236618otg.56.2018.06.18.18.46.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:46:33 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:33 -0500 Message-Id: <20180619014319.28272-68-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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 067/113] spapr: don't advertise radix GTSE if max-compat-cpu < power9 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 On a POWER9 host, if a guest runs in pre POWER9 compat mode, it necessarily uses the hash MMU mode. In this case, we shouldn't advertise radix GTSE in the ibm,arch-vec-5-platform-support DT property as the current code does. The first reason is that it doesn't make sense, and the second one is that causes the CAS-negotiated options subsection to be migrated. This breaks backward migration to QEMU 2.7 and older versions on POWER8 hosts: qemu-system-ppc64: error while loading state for instance 0x0 of device 'spapr' qemu-system-ppc64: load of migration failed: No such file or directory This patch hence initialize CPUs a bit earlier so that we can check the requested compat mode, and don't set OV5_MMU_RADIX_GTSE for power8 and older. Signed-off-by: Greg Kurz Signed-off-by: David Gibson (cherry picked from commit 0550b1206a91d66051a21441a02c4ff126b531fe) Signed-off-by: Michael Roth --- hw/ppc/spapr.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 6499a86752..a74eb2dc68 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2356,6 +2356,7 @@ static void ppc_spapr_init(MachineState *machine) long load_limit, fw_size; char *filename; Error *resize_hpt_err = NULL; + PowerPCCPU *first_ppc_cpu; msi_nonbroken = true; @@ -2448,11 +2449,6 @@ static void ppc_spapr_init(MachineState *machine) } spapr_ovec_set(spapr->ov5, OV5_FORM1_AFFINITY); - if (!kvm_enabled() || kvmppc_has_cap_mmu_radix()) { - /* KVM and TCG always allow GTSE with radix... */ - spapr_ovec_set(spapr->ov5, OV5_MMU_RADIX_GTSE); - } - /* ... but not with hash (currently). */ /* advertise support for dedicated HP event source to guests */ if (spapr->use_hotplug_event_source) { @@ -2469,6 +2465,15 @@ static void ppc_spapr_init(MachineState *machine) spapr_init_cpus(spapr); + first_ppc_cpu = POWERPC_CPU(first_cpu); + if ((!kvm_enabled() || kvmppc_has_cap_mmu_radix()) && + ppc_check_compat(first_ppc_cpu, CPU_POWERPC_LOGICAL_3_00, 0, + spapr->max_compat_pvr)) { + /* KVM and TCG always allow GTSE with radix... */ + spapr_ovec_set(spapr->ov5, OV5_MMU_RADIX_GTSE); + } + /* ... but not with hash (currently). */ + if (kvm_enabled()) { /* Enable H_LOGICAL_CI_* so SLOF can talk to in-kernel devices */ kvmppc_enable_logical_ci_hcalls(); From patchwork Tue Jun 19 01:42: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: 931329 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="HUYUjhPR"; 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 418tB26Bwyz9s1R for ; Tue, 19 Jun 2018 13:05:14 +1000 (AEST) Received: from localhost ([::1]:38883 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6xE-0005is-C8 for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 23:05:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46770) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5jD-0002lX-T7 for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:46:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5jD-0000S6-0r for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:46:39 -0400 Received: from mail-oi0-x22b.google.com ([2607:f8b0:4003:c06::22b]:34776) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5jC-0000Rx-Ru; Mon, 18 Jun 2018 21:46:38 -0400 Received: by mail-oi0-x22b.google.com with SMTP id i205-v6so16713617oib.1; Mon, 18 Jun 2018 18:46:38 -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=iZ8qvO+ZthfWmT8UtU4hUZ4/ij2J03vCuiusrDC9TS0=; b=HUYUjhPR6AROHbsOmnc8xbNNs4R9yFO9P973Xw0dvLVPuTmilay2y11+vKSWMJ8kh1 bzmH/IE6cxU0uvbmhZ0WhMBc+SCj8QG/LetaEtTTGizDFURS2HRPflilxSA29vDHZvHD 5sBPJyuR4g0RkFIK721dWuETdzDvk4j5+jg6gAspLiOPwm8ljFDMOE2mVceQtYMsDbLp wtwJje8mG9aZ4bvQeIMpTsCXMviCROsb9WnZrLlvSz+lBqVTnt3H3oAPTJsM2cXKgqAN YZ9d+4qAcbzEYwEaevxkguix4sTjKtSXSREqpJU8wGtIbrRyNrVRWrQ7LJkf75957RJ5 KR3w== 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=iZ8qvO+ZthfWmT8UtU4hUZ4/ij2J03vCuiusrDC9TS0=; b=rOsjTMjfuY6egdfRXtjXGloZEIbTtjvixXC17T3WhkdjCLE0+TEyFVSQNT3a7MP1rQ U3FsDl0AloookEPz3aWTTX2sR8P5rr887tdcos6qOa3ihuzptYdk5z+1ir3RXxy1yNEI ziu5wOrctyOL265dK8CBj5nVnvfJW6euJfdhHmGav83uZlpwrqvQNbH3xuiF/1rU+RP0 jG86la1T4fOx0QZYxhhVMrdNfqLS27IB40AhlSYhmOfuPZMLmGmUxIYWcjSPgeNis1GJ 6fc+u3/u2GixLMZQKW2zt313ikFdqJ9WarII+XK9rvxefb4nq3jMOuDwkfascJQrQ8Ml p2gA== X-Gm-Message-State: APt69E3o+kwnZlWUMHU7se8B25kxphJxOev8m3bIpgOtiWrw5PBW9O18 tfoSpssqgsKiwyJUkGwcmoEo5k4Z/rY= X-Google-Smtp-Source: ADUXVKLsji5KLAKfveu8ZP9CeAMdlOrRQTwwsn9Dr98eVRhU0q/w2bJtuCq+wp+hGCfaH31p/P7RVQ== X-Received: by 2002:aca:e60d:: with SMTP id d13-v6mr7888141oih.114.1529372797590; Mon, 18 Jun 2018 18:46:37 -0700 (PDT) Received: from localhost ([2600:1700:70:e488:b0ee:9bda:ee6f:91be]) by smtp.gmail.com with ESMTPSA id 3-v6sm6733328oin.12.2018.06.18.18.46.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:46:36 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:34 -0500 Message-Id: <20180619014319.28272-69-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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::22b Subject: [Qemu-devel] [PATCH 068/113] 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 90e0865618..9c1c44481f 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 Tue Jun 19 01:42: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: 931323 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="ioL9NN7f"; 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 418t4B3sVSz9s3C for ; Tue, 19 Jun 2018 13:00:10 +1000 (AEST) Received: from localhost ([::1]:38846 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6sK-0001Vx-3C for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 23:00:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46802) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5jF-0002nQ-SD for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:46:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5jE-0000TC-UR for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:46:41 -0400 Received: from mail-ot0-x243.google.com ([2607:f8b0:4003:c0f::243]:44072) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5jE-0000Se-PP; Mon, 18 Jun 2018 21:46:40 -0400 Received: by mail-ot0-x243.google.com with SMTP id w13-v6so20759751ote.11; Mon, 18 Jun 2018 18:46:40 -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=dB7eNsV3/5KszEfn85GleEj3RdrZyyUz/jcdMxUFYYc=; b=ioL9NN7fLG3PJyD5vDhIrmztHjPDDBhuMe1Qz88v9QNUA4bELzwlPgqm4uSYlVukcV /ub9JCEv9ZizVbQScjEsSkWpgw60HCr0aSHtlhs1pjzmdso2onI7HELCBp8rnRXcFlE2 ckvod1P5d6280vT13F5mhr2OtDPKeauQ7Zw5o8NtV71u5DdHZUWAACE+TACGiJ0s24Um niFU315U1UaFbhEVOiddo9Lemz5ZGjKhrzdgQ2RGQE+OzHldQhfElJBVfN2933MQBQSd 3COFEdMYp/m6QU646zZLrQewI1gh8W/XtoiQeNOFYpLncU7iuGkOGiRq9wwkt0Ga05Rv hyeA== 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=dB7eNsV3/5KszEfn85GleEj3RdrZyyUz/jcdMxUFYYc=; b=NGraPPWPejWxD08imigOSMax/A1orFm8mDXJdqT6VulxbJqIBB8Uh8kTt0XEqDo19v eVvCjpBVoSKWNXXYME14LKR7U9tE7d2afN6q6MVIVNfT0LEvOL+2JkX2pvYyS+gJrK8I P/PYJZdOJcbzXvlMNP7J6tz8zVriOrI2VU/kDsxhWV2+3PeFulmcH/UfBuYTpIMNyH50 +tOjm7HbXv/LbqOaBWfryWllQ/o0WpImvo2W7bLjTXjJycw/1hGI6US8ca04VsH6BUUL 9RNjdEPmQQ/E70hwgJ12hlBzs9KZwDytFfS6u+gDIf4o/sVhpfkcLOt/Y0sZdZk8TWMK NZNg== X-Gm-Message-State: APt69E0kWjC/fqC1r3UQBR6o21F8yW5nNd8t1S8zjdqfaDDqlRDRlHbc hpZsoRP6XXF/xBWmHZQ4pM6+9J9fbbM= X-Google-Smtp-Source: ADUXVKKuXNvBjICUxKyrr6CFAQ+oDR4kZ9ZA4HrLNjRUHq5H6N52q8bgOg+zcKsCQBgCisfxG7GwDA== X-Received: by 2002:a9d:1c1:: with SMTP id e59-v6mr9987890ote.134.1529372799565; Mon, 18 Jun 2018 18:46:39 -0700 (PDT) Received: from localhost ([2600:1700:70:e488:b0ee:9bda:ee6f:91be]) by smtp.gmail.com with ESMTPSA id a1-v6sm4610088oti.70.2018.06.18.18.46.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:46:38 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:35 -0500 Message-Id: <20180619014319.28272-70-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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:c0f::243 Subject: [Qemu-devel] [PATCH 069/113] 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 3c8e66c750..ceec276693 100755 --- a/configure +++ b/configure @@ -930,6 +930,8 @@ for opt do ;; --firmwarepath=*) firmwarepath="$optarg" ;; + --host=*|--build=*|\ + --disable-dependency-tracking|\ --sbindir=*|--sharedstatedir=*|\ --oldincludedir=*|--datarootdir=*|--infodir=*|--localedir=*|\ --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*) From patchwork Tue Jun 19 01:42: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: 931332 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="TB+t0Urw"; 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 418tDX3Fzrz9s0W for ; Tue, 19 Jun 2018 13:07:24 +1000 (AEST) Received: from localhost ([::1]:38898 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6zJ-0007VX-Mh for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 23:07:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46826) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5jH-0002pO-Sh for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:46:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5jG-0000Wv-T1 for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:46:43 -0400 Received: from mail-ot0-x229.google.com ([2607:f8b0:4003:c0f::229]:43681) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5jG-0000WU-Nq; Mon, 18 Jun 2018 21:46:42 -0400 Received: by mail-ot0-x229.google.com with SMTP id i19-v6so20745164otk.10; Mon, 18 Jun 2018 18:46:42 -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=je34LTX4eMybtYjkeA2lMVpkRUFq8BJWpRwQTvDYGVQ=; b=TB+t0Urw56lsiQ72ixdQTcmVAMVeg2nPgYgY6iZY0G7V5xc3LkS5OlmdMEkWf8yIkT LIJi8fbRm7lP94sZSDuzkBq9XgG91BSGd+03jQjzrtk9a+Z2i8a/s6Nf5IamnTFadnmo qCWLhqfz4IyUCsh7uBdRxFMV8wJoYzJQCNHOzqA0ZaCSRMWyUmWw7cVrFXnPD09kQ0ok tHfV71Pj6NLzuKGCJuSjBzf/29oXO9nKOaahb+Vp/djEow7RGFnkXZdI19VHCp9A4utF sTcfj6sEOAZJW3gN36ygqmpn20T6z7UtCLJpxyaIZ04oTcOr0nuYpHipFZvptpBO+ZGl QxqA== 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=je34LTX4eMybtYjkeA2lMVpkRUFq8BJWpRwQTvDYGVQ=; b=S5tiDSpYjpnn2r4gJEyJjoOYmIaVCn/U76WcnhCEQ8FAtH2LI1B6hX81Qxu2J/u0p4 7CKAp8TffwBlaRhGj2aWbEOR49oYCJA4Htfm3Qgf8OuAS0AK4M4chcDpUsDFUfdWD0SD yOftzrc1K8Vyjh+oLMyofZZpBUxrLbOhLhQOo1oXFXsQhsM9CickhlFoAJb2sKDoNTdG arKLHdntHLdkpuGHNS9DgieJXKT3ZyKRnJp+66F4ZIIv0rc/aEYFyGk9F9DWQ/uxLwHs KuhcXhW4dwGMWQydwfolq4tTIDjGxQSjWCcZuBAHJDkJS7zr33dqKJOj5f5Yy4OlU1la kjyw== X-Gm-Message-State: APt69E1wBKL7Oa/hauSKVS8JB0khLNOKY/95TP4OEGz/eYeij2Nd9rJA i2vyunIJk2s4Eu1hUOHIxzEm39/QJmc= X-Google-Smtp-Source: ADUXVKJqEu+6mfqmmgnhpPiA2CYRnisNzjhe0ILOJsc3XI3V+ueY/OD6MusaHRv9+iKdJLV1y61qyg== X-Received: by 2002:a9d:3163:: with SMTP id v32-v6mr9760445otd.363.1529372801606; Mon, 18 Jun 2018 18:46:41 -0700 (PDT) Received: from localhost ([2600:1700:70:e488:b0ee:9bda:ee6f:91be]) by smtp.gmail.com with ESMTPSA id n3-v6sm7245066otk.38.2018.06.18.18.46.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:46:40 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:36 -0500 Message-Id: <20180619014319.28272-71-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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:c0f::229 Subject: [Qemu-devel] [PATCH 070/113] 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 68b375f998..03da42dae2 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -3190,6 +3190,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); @@ -3198,8 +3201,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 Tue Jun 19 01:42: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: 931334 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="g8Nq+Vag"; 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 418tGc4NxBz9s0W for ; Tue, 19 Jun 2018 13:09:12 +1000 (AEST) Received: from localhost ([::1]:38909 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV714-0000TH-5W for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 23:09:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46868) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5jM-0002wR-Sk for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:46:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5jL-0000gw-Ju for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:46:48 -0400 Received: from mail-oi0-x232.google.com ([2607:f8b0:4003:c06::232]:46939) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5jL-0000fy-D3; Mon, 18 Jun 2018 21:46:47 -0400 Received: by mail-oi0-x232.google.com with SMTP id h79-v6so16687174oig.13; Mon, 18 Jun 2018 18:46: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=A2k3Ge2jKD+AUwjKnEqK8a8+3YJqbl+BBY+aCv6m5L4=; b=g8Nq+Vag5R0dkt0lmj4FUkjecLgRMGAGO8h6ro75G08dOJlQ2rws/+/TLqE8QwVRiL NwELNFTfBwPS4z82R3BCbYd0eL27sTxsk2UU+1852enLWN+HWCxN3kfSqjWhRqCLdUOg ZXAjGfzA5uziY72WyG7c3boMX9oje0zPL0PmxBvSh2zbtI0sEE2TvscvzMfzZ9S88cJV 4GewcU/ZpDEadBrFyH0toyL0Ak7sxFzlzgM38dZApnIlrsf92h6oMVanZ6Qz412yKb6y Lj/jBip8GbM8EdarN7ID+A0/L4y8dMUCG1eQfFEozWcGoZoMWybAMgmItM5kDBfc2DdA ND/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; bh=A2k3Ge2jKD+AUwjKnEqK8a8+3YJqbl+BBY+aCv6m5L4=; b=hqSZWqHHGeETSWcUzHizntUKz4kzG7cEMyg7RT89o8xos/eVsRTo9sUZ3nKdrdCMsd AGc+Xbl3EuyQ3zczOK40NaUSns6XYXepx/XMFYyejVJLmabtzkRnnNcIP1IBQcD9El3w gnWXvt6NuNic8yTixuMC6XWajUjafSFPDnpNd2z74FXxx/YIzRjO/tEejJphGFgxOSta 35gCoergV1P473QAOKzcr3Wb+pi4YWvUDLWifvTBl//BDetn5S9urDMnOpII/Pl3crHA BUrUTTASgrVGhONS5nPDHEk6lUGLtrnoo0TCRUKOf6zzSsthX1yNvKMu1nBi69qvrdQ6 nCzw== X-Gm-Message-State: APt69E0FvUjlKu6Xps+Gx5VuPQs7HZIbuo/RSf/NieKu2gcAq4QyzUBd wDJ39nrSl69zqYXgEaR55g6KuDRTSi0= X-Google-Smtp-Source: ADUXVKLHURtLmWBbF9+Eh0t5cRXy8u6jY05HwwUbHRUZfE3tx2aZTg4pfc7o/Kr344CACQ2neVd/7A== X-Received: by 2002:aca:6a4e:: with SMTP id f75-v6mr8745743oic.233.1529372806208; Mon, 18 Jun 2018 18:46:46 -0700 (PDT) Received: from localhost ([2600:1700:70:e488:b0ee:9bda:ee6f:91be]) by smtp.gmail.com with ESMTPSA id p8-v6sm7160601oti.66.2018.06.18.18.46.44 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:46:45 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:37 -0500 Message-Id: <20180619014319.28272-72-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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 071/113] 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 Tue Jun 19 01:42: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: 931288 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="UqBAeS3t"; 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 418sR211PJz9s37 for ; Tue, 19 Jun 2018 12:31:24 +1000 (AEST) Received: from localhost ([::1]:38648 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6QT-000377-Bf for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:31:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46883) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5jP-0002yd-8x for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:46:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5jN-0000lG-Tp for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:46:51 -0400 Received: from mail-ot0-x236.google.com ([2607:f8b0:4003:c0f::236]:41140) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5jN-0000ks-Oc; Mon, 18 Jun 2018 21:46:49 -0400 Received: by mail-ot0-x236.google.com with SMTP id d19-v6so20759420oti.8; Mon, 18 Jun 2018 18:46: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=ftdDvZT2hIih6q8dZVCgSF9+SG+DfEhlilK05fl6Sbk=; b=UqBAeS3tYt53m41d1FcD3ch39DAyyFvHo3r7V04xNRoR1nXyYCuw0sYtGPwUUDWh+w QKNiZ0in8O0bG3iaE0hcNtXeULwiljMBzV0pfhoYMRsyosdAaGOFKiBH52tJES+nxbk7 E0Pt0e5Gnb3uqPSVmgpAYqoPUnUjv9AE+WUxJ8yiA0I/YvKpG9mrXNhTtK0bpsSAHfy8 I7sKkWRrnIsliHB9vx58urIR8Mlvk29JbXouGMSrA0JLN8XQMGcogKxHu5oOxtvidcF4 mXsbGjjLKhvBckbukd8TjpK4axINte356E413H3d31aBbtV9tT5OFZxrdZJUXhhPT2De 6qMQ== 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=ftdDvZT2hIih6q8dZVCgSF9+SG+DfEhlilK05fl6Sbk=; b=l2k0UDwO/+gZM45ZlheT8f5pizkYBiJwJBsJiPMHRhxuQa7qFamc5RNeDZ67YkbVTr a7R+TERHpgk6SD7El0Iskm38pKJx2jcjnHRsfMyG995EUcqhkY9MQjd2HDUtehLSLAJ6 ZYlc/JfNmHAfYDFt0OxmSNd5/gEX7dZTRfSmtQloxKDfq6AqkDW0BHfxR+R4r073GB2e P1djU24bPv/DaIn/BVCf8uRiaj/qWy1kkAainDJFSglz3TlhYzRmdR44E+9jBTc4ZkGP LnpS3jzrIUPMDdcuq4ZFDb5iaziS7PwOk9iF6oVmmJ+a2fEpOGnAK9Hxqtiu7D8RYyYv LpRw== X-Gm-Message-State: APt69E0QqGyFlorXpue8b2Ln64kAiyTSorIFqKiDN1H3jPerErvuESMQ LThZpkuQgiAIK/Xv67CT2Le2rN5hLOg= X-Google-Smtp-Source: ADUXVKKbYxu31ps2oIax3ltTc5BIFVGMqa/v7BAbgCm2cGtQGcyH7F03I5suleLVewkirOFtZgWp+A== X-Received: by 2002:a9d:cd:: with SMTP id 13-v6mr9584011otk.155.1529372808557; Mon, 18 Jun 2018 18:46: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 v8-v6sm16549341oti.35.2018.06.18.18.46.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:46:47 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:38 -0500 Message-Id: <20180619014319.28272-73-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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:c0f::236 Subject: [Qemu-devel] [PATCH 072/113] 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 c70bde3eb1..e6b608a564 100644 --- a/qemu-io.c +++ b/qemu-io.c @@ -71,12 +71,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 Tue Jun 19 01:42: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: 931335 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="YQ7Q+MTb"; 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 418tHl6Sngz9s0W for ; Tue, 19 Jun 2018 13:10:11 +1000 (AEST) Received: from localhost ([::1]:38914 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV721-0001G2-Gt for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 23:10:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46916) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5jQ-0002z2-V8 for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:46:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5jQ-0000nU-0n for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:46:53 -0400 Received: from mail-oi0-x22e.google.com ([2607:f8b0:4003:c06::22e]:43937) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5jP-0000nI-Rp; Mon, 18 Jun 2018 21:46:51 -0400 Received: by mail-oi0-x22e.google.com with SMTP id t133-v6so16697998oif.10; Mon, 18 Jun 2018 18:46:51 -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=fdNqkFcsS1Ole0HvZZCC/+O6h6J/pwPhpCO2sqQl6Uo=; b=YQ7Q+MTbt5T3mn8Hlhes5Ocrpw7f5oU8u93DABV6uNPz0H9uZzQBPXCHKZGlVpxvXv ZvluCJcrnVFnHW3ZB0JOT1kipTnXYxMp0lYC6nlD0pBqt9R5mRM66lgm0aFyELNTbTdM it5B5Io0C8yBm69hyX2smuGOSFha3SaQS8A9xgSw7Hp/za9LWlV8BMiDcC0Olc+7eejh eTwLWVCo41P2o2moP33b7jwGMqopfHuUErowHSgKxVB96uqFv71vsg5QwLEcnr2A/GCD ThOf8TGh8eNRVWV7m1Mu1lSNk1/eWIYFFKY+ffIFCyUGCr0POYF++Ld/M3R5wnILb1/q Qjxg== 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=fdNqkFcsS1Ole0HvZZCC/+O6h6J/pwPhpCO2sqQl6Uo=; b=EeZZcxS7r62g1AszWQ0Y/X6kjYUtzahdneVHG3/McqENUWA2OJVupXrjb6D0esRuT+ G4S4YDzOWEW2dPE8efZ3HH2OLwrg4YXmA6dHCUzj6iDpGo0EluWvy2u+2S56yvXJ+Tue VjkwhTHFN2Qmhjmj+s2iXqAClYEP5OnKzMTu22sr4t6WgePCnvjkO0NinfB6K0rR6YIQ PpoWY1/mo7sCt+ArixbBWif05iIVHQbEqeKpHvR87vhyIlLMNC7aC/2tBzQapJ2BScDS CeUldxP7cjw3O94ztziVwxY/7xrDnqa7IbeT9OBTxeqopAFsjYQfJThIeviPc7nQki2x 4HMA== X-Gm-Message-State: APt69E0q8AFB86LR88gYohH7lLuyCZO2W1KdaLXuY6SfHlzNJCtXvatr wjpkTuuWBSEeaAoncqCIJlvRLTU1kWU= X-Google-Smtp-Source: ADUXVKLV8x2zm78eigCDPkwpos0/Q+1jULQX6xXVh4W+kPtveznDsASRdlIjyKaYg6eM5eVvua9EgQ== X-Received: by 2002:aca:496:: with SMTP id 144-v6mr8625291oie.275.1529372810725; Mon, 18 Jun 2018 18:46:50 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id s22-v6sm10292724ote.14.2018.06.18.18.46.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:46:49 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:39 -0500 Message-Id: <20180619014319.28272-74-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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 073/113] 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 03da42dae2..86060aab71 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -276,12 +276,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 Tue Jun 19 01:42: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: 931338 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="UTxk6xeq"; 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 418tLH4JzXz9s3C for ; Tue, 19 Jun 2018 13:12:23 +1000 (AEST) Received: from localhost ([::1]:38928 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV749-0003A3-7T for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 23:12:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46942) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5jS-0002ze-RA for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:46:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5jR-0000oL-W5 for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:46:54 -0400 Received: from mail-oi0-x236.google.com ([2607:f8b0:4003:c06::236]:34787) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5jR-0000o9-RI; Mon, 18 Jun 2018 21:46:53 -0400 Received: by mail-oi0-x236.google.com with SMTP id i205-v6so16713978oib.1; Mon, 18 Jun 2018 18:46:53 -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=prcDOY/5HSmcYgrkY1IjVc13TrapKerTK5J5UQw9tmY=; b=UTxk6xeqs8znhKaxagRN4KbN+Bg4y5j3iUGHiMDcfCnTM3wMQNHOmSsGgWsJq+WwIk jf24mFxtKc9EYhAH0xdBpAaNVkQlsp0ohDEFc8DZNd+chRYDW6J5aSUYSe76Fdv09pq/ 0EC84PeRDk77fsst0y9sz7Vb0jNjcsYWhTy5EyRXdbfgMcc5vEpsDMiUeGW0jbvbLZO6 mPc6Ep4wgQ0PQE1Qoup+rEI/x4npacub70/8qsjLkXpGW+Oh6W6sIikqE/WC4eyI7kRZ E/+VafesLRf2Djjvf3BvYD65zPHkUWZREFvxMH1Wqr71iLt9l9OKdMtS4TNvAnUtFLoH fbkA== 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=prcDOY/5HSmcYgrkY1IjVc13TrapKerTK5J5UQw9tmY=; b=HyWTtFKWrvRTR6I7EC3/t02/l81FV1tjAVbYjyZUmgXXBvDTpdPDOO2GM/65czvc0a vT7ADhpDhrDsZJ8nhi1L+bY2kWL7PpEWG7Ib59OR7kUMK7LK7abIePjLZF9PpkZgw9Mt BKNuB2eTWCz3UFqyD4LnC2mJeTS2L9O1OsOaokBRahG/ht8bChUfNfPhRs8XU7VKk4WI R/rXudGvNW+gO2V2HOCUxDsv4WPCIz2wuNX1zJiHQCt5XRa3VcsRw5M9xyCF7wLSmi2P ocDRyHSakWwqPCF6Ik4VvfqkL2ZoX2QELWW1SMYJn9D1DStzBvo8jwDx4gStczf5AxVU 5DvA== X-Gm-Message-State: APt69E0Dwa5rYmuS8pYzOQVOV+Ye0x8lRSUGeEV2NObLa9SmG35zNSLc ux0h+0qdwA2ohpD0BnPXUxWYhhGDwPE= X-Google-Smtp-Source: ADUXVKJ1pe7oN6D2Mor961tEvMbW3iuPiNkJbM5q9680xVYifIIEnxUHhF/3GkPtlgXb0dyLksKjiQ== X-Received: by 2002:aca:7541:: with SMTP id q62-v6mr7616028oic.319.1529372812692; Mon, 18 Jun 2018 18:46:52 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id q23-v6sm10138207otd.25.2018.06.18.18.46.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:46:51 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:40 -0500 Message-Id: <20180619014319.28272-75-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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 074/113] 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 fa25eb24bd..b3fa308171 100755 --- a/tests/qemu-iotests/153 +++ b/tests/qemu-iotests/153 @@ -228,6 +228,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 5b917b177c..dcce03ae4d 100644 --- a/tests/qemu-iotests/153.out +++ b/tests/qemu-iotests/153.out @@ -393,4 +393,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 Tue Jun 19 01:42: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: 931294 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="ek3GuzsF"; 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 418sWg0nZkz9s37 for ; Tue, 19 Jun 2018 12:35:27 +1000 (AEST) Received: from localhost ([::1]:38668 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6UO-0005t4-KJ for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:35:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46975) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5jU-00031x-Vz for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:47:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5jU-0000p8-47 for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:46:57 -0400 Received: from mail-oi0-x230.google.com ([2607:f8b0:4003:c06::230]:44451) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5jT-0000oj-VB; Mon, 18 Jun 2018 21:46:56 -0400 Received: by mail-oi0-x230.google.com with SMTP id c128-v6so16680784oig.11; Mon, 18 Jun 2018 18:46:55 -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=i6VbW3kr7OQvfnMzpfKE0GIhhoa7W0K+wZd4IdB5yB0=; b=ek3GuzsF9MZxExzSjGmQwl0TF9XELIQ5+Fpl+qyR+wKS79ZPaocrcpzfXxWepe6u3U WB1KRfmP0r92Da6JoNYPEsSVaGePiZreEHr9W0zShKKuwka/T6k36r/AYEFbDXJmPofJ kKV71abkrKrxPuXaLivLCDOenH4q265PWEHMJUTGXd3+YxzyDRsbVxOEfx7byD1hCNr0 XO3NBYfeoiz/fB5nHOaVmDjQMN67Iwncie9Sjh0bGTNWrDW82MYLkthI/zhavlpJ7Zq4 78fEe7/OdjB2sK3g3x+NeUDfJzllIB7UY8BS1sRtbvkLhXwrCUxQNRTVI/0SiZznL9gw e2uQ== 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=i6VbW3kr7OQvfnMzpfKE0GIhhoa7W0K+wZd4IdB5yB0=; b=sfNy+o5z+5qhkGfOykV7eCQDJ15fC23KkN8c8e5igy63wjC4NQPr3aSkGtMOnB8//l 1RA93q3xelehm7h/bsSfa5u7oIVOgPcLxXxFJuBDXYTuu/XVB8MK/FwhRj5e3UqVlWr0 lasH455BagfJw7JyFXPHbjjMNKnnvquTni3hBJ4ptQ3KZIYlD+biUF8VNDTEVKPHv1oB Y7lGitaYJkEavwe7yJZ5sCeydpnXYhS/15F2i4t2mjfI6RPj0jsH/v1O4ZwtuXPEDNbK kNeEByJYEwY5+9lyCkORhoc+N5Uy5YhrKW2fBd2mYDkSK90BCnCH2WL2D4rcTOI/gfGL N1Nw== X-Gm-Message-State: APt69E32+o/m/oLY7PacB2cizFpBZCW2pKOrQeevxaYFc1dCyEQCLN7F ym30RX5ePmFfAVsE0Dn6t7J56hRxJN4= X-Google-Smtp-Source: ADUXVKIbIjfdQ+xzZsOioRQ7lmfVqJ6LlA5lTNuo3rJ8kAN5f1yw9a+acQqBq3qxIn07Na8Crns/Tw== X-Received: by 2002:aca:d0a:: with SMTP id 10-v6mr8802859oin.277.1529372814724; Mon, 18 Jun 2018 18:46:54 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id g8-v6sm8905967otc.68.2018.06.18.18.46.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:46:53 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:41 -0500 Message-Id: <20180619014319.28272-76-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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 075/113] 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 2177c8ad12..93b8d09794 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 Tue Jun 19 01:42: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: 931343 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="RPk6Wxue"; 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 418tQj2DT4z9s0W for ; Tue, 19 Jun 2018 13:16:13 +1000 (AEST) Received: from localhost ([::1]:38953 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV77q-0006Q9-VB for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 23:16:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47005) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5ja-00034P-0G for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:47:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5jW-0000pZ-6j for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:47:02 -0400 Received: from mail-ot0-x231.google.com ([2607:f8b0:4003:c0f::231]:43689) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5jW-0000pU-0T; Mon, 18 Jun 2018 21:46:58 -0400 Received: by mail-ot0-x231.google.com with SMTP id i19-v6so20745642otk.10; Mon, 18 Jun 2018 18:46:57 -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=ZpqoWvJ2rwctORfvNpYG0m1cmeNh8t2Re4bsiKGiHs8=; b=RPk6WxuecGCyqk/sBXhFZK+GSBQk6fAQM1KA5wYncUPArdg9dn2Sc7nDxHyCNvFSxo VcgCkDmsPuPM/73ivItuNOZjg4tEvJwQRfaSz2C872qpCgBiAfAfbedCBaGUxCcINMeB 8r4RUr+M6VVmsvaOADBJB3JIP5IX13l2jqAWQvDR7lDPYkkc+yxieiEaqUePecymynR3 Dmvwx5KVtC7S9p3AJVFqOIrPBOMgmY/NiaLSM7Exzx2zwd4HSANuAboxgMOWHnX/xA5i JWKowShdLKLjucRL3aN/ycHyyWI4Fz2Mij0rlIe8nkxKp+pmfcGog5EWS2yKnUUMcbWE sp/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=ZpqoWvJ2rwctORfvNpYG0m1cmeNh8t2Re4bsiKGiHs8=; b=UcXVPDikamxmpwfSRVBWWOC3LS8qMBhDCQi9fNlxwVyxy5J/xJjRs8DH5ZTZ3qsVUQ +/lGMnmS9AFBdwF90+8UQ8zjv+PIYjs8Z/zhivjJSl8pE2YW5dpmuP+eEtRaOGwzNsOw YlEzrdSo6qxqarCo/lfGKCVZLYQQJ7in9gr42TvHuwponjWsfsWH2viEek4izsi/9CnZ t9AhkO6V5hy+9lRdcP2lJBi6t0xBsA7pxIGWCAS4FbhUpTgiDhUDpFUsd9zCdzUg3iAc ZJNXwfhG4/zW/hd8wPSFpTYky0c5Pe5H9jDI/uytnNdW0ASsE5essmgUvmTRQFCpdmmo fmBQ== X-Gm-Message-State: APt69E06a5IAE+Roq5ifmUQf4n1Twm3Gs9WV8tf6h2Snk+cb7hWmL5gH aDEv3fnNZGSXdioBvBfV9gVDxx1zYzA= X-Google-Smtp-Source: ADUXVKJQTp96YRfQ4bsziEyPfBM1CzhS7qurp2tmJBs2QAhedhPj75OZpGieO3W+OAXpUiSaN0Ktdg== X-Received: by 2002:a9d:251d:: with SMTP id k29-v6mr9716393otb.149.1529372816829; Mon, 18 Jun 2018 18:46:56 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id c2-v6sm7233001oia.53.2018.06.18.18.46.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:46:55 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:42 -0500 Message-Id: <20180619014319.28272-77-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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:c0f::231 Subject: [Qemu-devel] [PATCH 076/113] 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 ab552c0954..c77290b93f 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 Tue Jun 19 01:42: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: 931340 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="tbYby/lz"; 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 418tN76ZLWz9s0W for ; Tue, 19 Jun 2018 13:13:59 +1000 (AEST) Received: from localhost ([::1]:38936 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV75h-0004R7-Hw for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 23:13:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47007) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5ja-00034Q-0Z for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:47:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5jY-0000qB-CC for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:47:02 -0400 Received: from mail-oi0-x243.google.com ([2607:f8b0:4003:c06::243]:33889) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5jY-0000pm-7S; Mon, 18 Jun 2018 21:47:00 -0400 Received: by mail-oi0-x243.google.com with SMTP id i205-v6so16714196oib.1; Mon, 18 Jun 2018 18:47: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; bh=DS7+5rKSwez6w7Aogo7OEn4YFoPXOKiBCGxBUtaeTIk=; b=tbYby/lzQSfl00oN1hAUFGmlXtKw6LrnsCXmAdDPS32/Ha4hQvC4yQsWWcbh2H9hz/ yxsEQZkTjT2H7HZxr7KzH6dtz6eg8A/wgINtzTyMMzF2QPSlYipxz9Ri4L1ZbwtNTft8 0I2lDsUmA8sTr2sI8V4+XBNzmAIVWWYmhMGIEqP5C2eyxxc7/hM59VTT1en6+CNmbneP E+a3iBer2G4mypbev0v/NwOqYMxczSU9X5XqOD2XWuFM8yP4sxuuFJwssIg+xrq4B8UD ghn0LXod3Vql+77jvXuPCg/Y3ZjSqG3F3Z7M3HdaMtH0wp/Et+4JpF3wYtN1cxsW+KZM ibYQ== 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=DS7+5rKSwez6w7Aogo7OEn4YFoPXOKiBCGxBUtaeTIk=; b=O3jw+tCgQbSm//I5JgzooAeC33N7+njWImazfrUhxG86p3JjxyWPaHERiD7f8f0f+h D6ymOrhuIRn0sGfsURbszl1ezdgNq9ARNooi0noNPnigbLvKC5ftgq2TOlAUSYKXMT7q N3wYf13hCt+BuxDpPrAn8RdYIAGyDDfaxhrsjHgPkTPdU822iNg/1vEAKq2X7+9SkPof aDbfx7WswvEkM/+bwaspWTD6Fhs4swWIQfgjITQSJba7Cj24RXw1hoNQ5bVhAilUIimO +qMGub/GgAEL36OctVhp35A3Tr69kOLuBl/cL1eLey1y04AmDi0njf5fMc2DCQdhxdjh 2nHg== X-Gm-Message-State: APt69E0EKMRtUgx2lDVCe+LlFKJcbMlyPuD1Oa6M9vQoFiQkerBveSyT VEFZM6Rq4Gd7PsYQ8FA3stiYRMj2xJ4= X-Google-Smtp-Source: ADUXVKKzfu/oMUWtpEJ3ZhJaqJVw3bv5DI9K0vZvYGNuvpOzLJP0xWRei4O/FhS7UZMVkm+HR7BPfg== X-Received: by 2002:aca:e4c8:: with SMTP id b191-v6mr7657257oih.106.1529372819027; Mon, 18 Jun 2018 18:46: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 s12-v6sm8531248ota.55.2018.06.18.18.46.57 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:46:58 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:43 -0500 Message-Id: <20180619014319.28272-78-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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 077/113] 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 f6b5c807cd..f530080243 100644 --- a/hw/s390x/css.c +++ b/hw/s390x/css.c @@ -618,6 +618,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 Tue Jun 19 01:42: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: 931341 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="ln9lCICQ"; 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 418tNr5Mhgz9s3C for ; Tue, 19 Jun 2018 13:14:36 +1000 (AEST) Received: from localhost ([::1]:38939 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV76I-0004vw-Cg for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 23:14:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47030) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5jb-00036M-8b for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:47:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5ja-0000r3-DK for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:47:03 -0400 Received: from mail-ot0-x232.google.com ([2607:f8b0:4003:c0f::232]:33930) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5ja-0000ql-8J; Mon, 18 Jun 2018 21:47:02 -0400 Received: by mail-ot0-x232.google.com with SMTP id r18-v6so20784940otk.1; Mon, 18 Jun 2018 18:47:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=0qlR3rSlK8DzNJTG4Fb2fqNBJBmgd1QCCWI4QD1Lig8=; b=ln9lCICQR7hiM8BNGqT+jIxE/M4C3s+FzVQWq+fZOYxNH5O2OIENvcW9uT/y9OkpKr i8n9bxkI//PoGfhO5U8xkSzzDJF/rJ+A9QbbEABfwYbLUIgFKPLqf6KsJGoeYWpBptia eVNRIO+TIs/EmbX/L8oU1hNdMxfHYQMKLC71iU58HnmrFNo99KdIFJoK1oqf6xeQguWd EQaFC8ajZEBd4jvse3DHsvJcIAH2yE7dIoH+i98CEUA9GhWSNGI4AcsfNruNE6D1Qqri qbdMOsqdiIIz4nFh/NPzT6YBduvg5NbtkXMgKY99rvw6cTBDwBzxVX7nEjXUGQEeUPjO yOcw== 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=0qlR3rSlK8DzNJTG4Fb2fqNBJBmgd1QCCWI4QD1Lig8=; b=AvtSS5ZAo1dgttrqf0J5kjiF0CXYmsuf3fdADBexh3M15IiTwX7A+kAwipODcsYhXL xY+FuePW1t6v78Bsdda0sSTx/VaUIla+g0qjFPLtSn4GUeG9UfyiRmgo9/6wZH4aosSs DiABTM9mY7vez1PEt/Fg7utX8qj7Z/bMYjC8Mz2NzhA9J1yOEVX7qGIiYVMVTkT/W+RT qP1NXR1Q3PFyDdfZ++/6+9Z/iSBXSOvdUi85zTVy7JuISGPRlvsOqWbdLueYI2a5Yma/ xfM9BfETuQa7HjIrelrZIgE3JfQuyfISSk2pjd8gyDWE6K7T5Dv6QotUPv0a9E+5OKmT yAxA== X-Gm-Message-State: APt69E1hKsImULRXaV1d7k0/nD8iA6Vz03nIUt5sUxMepNvx8QPpdq5P akh2Kqk2txGukFT5HjI8b5zDjy4t6vE= X-Google-Smtp-Source: ADUXVKKDO2NUD8ZYz4yqt7jwUbGd/a8H/qyz0LwejS6Z5JT5/heO5goyiE7DfvT+EMZjr9xhkveHIA== X-Received: by 2002:a9d:a12:: with SMTP id 18-v6mr8723160otg.359.1529372821087; Mon, 18 Jun 2018 18:47: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 q23-v6sm10138556otd.25.2018.06.18.18.46.59 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:47:00 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:44 -0500 Message-Id: <20180619014319.28272-79-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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:c0f::232 Subject: [Qemu-devel] [PATCH 078/113] 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 Tue Jun 19 01:42: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: 931326 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="nItPz0el"; 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 418t7Z4gQFz9s3C for ; Tue, 19 Jun 2018 13:03:06 +1000 (AEST) Received: from localhost ([::1]:38873 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6vA-0003qD-7s for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 23:03:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47042) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5jd-00036P-6B for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:47:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5jc-0000rb-GE for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:47:05 -0400 Received: from mail-ot0-x22c.google.com ([2607:f8b0:4003:c0f::22c]:41131) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5jc-0000rX-Az; Mon, 18 Jun 2018 21:47:04 -0400 Received: by mail-ot0-x22c.google.com with SMTP id d19-v6so20759839oti.8; Mon, 18 Jun 2018 18:47: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=MR4LCV4oBeZSOvrc3wM8hhBpZl2AkGFbmJW36StvYe4=; b=nItPz0elJWgETLQnwGXSyo0zIs/yTJvg2ej6UzLMWjqZHGrV4cMvzwLhGL8YoS7tvS SYbKkRw8y7m8gYDeoAk8+2cOs4Vfv2l2vOTg9C+riiSAJjnxiAZAvY8NLG6rI8U5+ijC be8SGE/QIh/qS4M9JmYcoU3b7sluPh3+HltvRirdlwSyLZuin98843NF5BgE48CaVkC6 cQEnjlc3RE3c4lf94aIeySyib3bLaCz5fOy/tczEnlejUGjNMFGTqMJ9wTbhO/7jFevY eYNpkok4Kw4noDY055CazzMSqZJjg++jCC/JR5s0bATLFTx5nz8eam9MJLld2HQo1yYi cE8w== 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=MR4LCV4oBeZSOvrc3wM8hhBpZl2AkGFbmJW36StvYe4=; b=HmCkHXLXheLpOfD3sDkck6iJ0dgIj4fP+BILt8WXOEUw6wYkpnY2aYNLBbLEDwbP6a u/HvjP4+idkQRcNBTezN/8gCFVBIvUgWjgcBrifQ1hNFw8fMdzyIalT8nMXeGYpsh3xC EY9sGnqUU5qSbrksnlijcsciiHji7Fd65ESMIFsvWFxiXE0fSuXwF19fxmMSL33dv7qS ydXxgEN+5aiSSEK0B8OD9Fkxxkx9HPghx3NIU4auQsJVsVE9oEMEpMAMXnDY4WDyEVzq F6hQiz34sisOqJ7LHxuPpmAp7HmSm3lRnnSrxlvaDVtA9is3mLGkKF7vHOLqj0v0p3Gd 8qsQ== X-Gm-Message-State: APt69E2Mb8OPj6xO779OElQAkRWjnVUNVlTmwWZQgH9pnGUQvaLQQJc7 aLZ4JoJD6XhL7dmc6MD6X3rPumYOPdk= X-Google-Smtp-Source: ADUXVKLbmCQjsJyRxfhLDDaNhIuDIqLl47uyGCvqOfoVF73yufuEB8xumKmvh7w/9jhwp/heMIMj6A== X-Received: by 2002:a9d:61ce:: with SMTP id h14-v6mr8816476otk.225.1529372823216; Mon, 18 Jun 2018 18:47:03 -0700 (PDT) Received: from localhost ([2600:1700:70:e488:b0ee:9bda:ee6f:91be]) by smtp.gmail.com with ESMTPSA id q205-v6sm7239068oia.7.2018.06.18.18.47.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:47:02 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:45 -0500 Message-Id: <20180619014319.28272-80-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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:c0f::22c Subject: [Qemu-devel] [PATCH 079/113] qdev: rename typedef qdev_resetfn() -> DeviceReset() 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é following the DeviceRealize and DeviceUnrealize typedefs, this unify a bit the new QOM API. Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20180114020412.26160-2-f4bug@amsat.org> Reviewed-by: Laurent Vivier Signed-off-by: Paolo Bonzini (cherry picked from commit b850f664a1dbbc1ea27bef12cd251ee5da0bfe05) *prereq for 0c53057adb Signed-off-by: Michael Roth --- include/hw/qdev-core.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index 0a71bf83f0..83db53b3f5 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -32,9 +32,9 @@ typedef enum DeviceCategory { typedef int (*qdev_initfn)(DeviceState *dev); typedef int (*qdev_event)(DeviceState *dev); -typedef void (*qdev_resetfn)(DeviceState *dev); typedef void (*DeviceRealize)(DeviceState *dev, Error **errp); typedef void (*DeviceUnrealize)(DeviceState *dev, Error **errp); +typedef void (*DeviceReset)(DeviceState *dev); typedef void (*BusRealize)(BusState *bus, Error **errp); typedef void (*BusUnrealize)(BusState *bus, Error **errp); @@ -117,7 +117,7 @@ typedef struct DeviceClass { bool hotpluggable; /* callbacks */ - void (*reset)(DeviceState *dev); + DeviceReset reset; DeviceRealize realize; DeviceUnrealize unrealize; From patchwork Tue Jun 19 01:42:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 931296 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="OmxFTu/w"; 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 418sb83qzRz9s1R for ; Tue, 19 Jun 2018 12:38:28 +1000 (AEST) Received: from localhost ([::1]:38687 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6XK-0008RP-5N for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:38:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47092) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5jf-00038U-Ht for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:47:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5je-0000sf-KV for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:47:07 -0400 Received: from mail-ot0-x22f.google.com ([2607:f8b0:4003:c0f::22f]:35258) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5je-0000sC-FC; Mon, 18 Jun 2018 21:47:06 -0400 Received: by mail-ot0-x22f.google.com with SMTP id q17-v6so20780716otg.2; Mon, 18 Jun 2018 18:47: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 :mime-version:content-transfer-encoding; bh=2UMT+GFNZKTuXW3jx4E5cgr0GCvUy1Ici4Cy1mboVZM=; b=OmxFTu/wUUS7A7L3cby3QujyW3jWnkT2Gk4mwO8+OS3JoGKgoEqJqyAYY81cx5dpu3 k922klp0aJfjl0cekmOvn3M14yRzHMc+StXBfatpL7EpZUY/ey9D035yRX7rp1d6u0dg bEpzEpMeCxrddcWG6/f7vCi/nT4SkrA/48xT7Stms+u3u5tCBPEeEpJo1joi+nUurzLk YrdDmGdML0mPCj5euzkxdf6BsqCzut5uBMj0Bki4De8HTDnTL0HCdmz35dxVxZaWnXhx i3Yw+XXFLCY6cbZsb5BF1ufwLMXLp4R7Sri87MdXq2j6Pwno+QRD83pyO7zN2262BIBc 8p5Q== 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=2UMT+GFNZKTuXW3jx4E5cgr0GCvUy1Ici4Cy1mboVZM=; b=NVduCvc4PeX/tA/FksLLn4JqMoF0x6Fo0iSl6Aqk81HRUTsH4SOsOGwrJ/bSDW5mRg 5fjqiTi/L/8ODMJzl8R1DzKPB7Np4u96GEGcJw8VcPSvX2ADpBaqfVOINATZ5SeM+JI8 20ela6HM9FIifkvJXFbXE87uBTTCIpN9dVu7b3ZFct0Eng2O0RMCcQuZOTGordJQ+c+q UiPKUAnhWmYMaPPnxQtQfyRT4s3Zpj3S5SX5ntTGCNi1aX9eseGClwTISJIF2HHUxJ8i mxYQcM6Wzh2DTkhD9o4RYgXwG9Xn/9DqDXRh2ESDHdr8wKLy3CuKLs28xYXSdOEVfUH4 4yVQ== X-Gm-Message-State: APt69E03SVLYrqSR6RPp6EaZscf5NJSR9sFkys4U78xBSJjI5eFlJNQm j1pouVV92fpF2KbKahr55kxWbPtezVQ= X-Google-Smtp-Source: ADUXVKKUt2cMoM9JR02Bhxh4TGKyc+BIB9XmfSX72dBdgTwCnkLfQzZjVh+85BxqTZwEn46poh2LKg== X-Received: by 2002:a9d:4905:: with SMTP id e5-v6mr9713923otf.101.1529372825212; Mon, 18 Jun 2018 18:47:05 -0700 (PDT) Received: from localhost ([2600:1700:70:e488:b0ee:9bda:ee6f:91be]) by smtp.gmail.com with ESMTPSA id b26-v6sm7272963otl.41.2018.06.18.18.47.03 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:47:04 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:46 -0500 Message-Id: <20180619014319.28272-81-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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:c0f::22f Subject: [Qemu-devel] [PATCH 080/113] qdev: add helpers to be more explicit when using abstract QOM parent functions 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é QOM API learning curve is quite hard, in particular when devices inherit from abstract parent. To be more explicit about when a device class change the parent hooks, add few helpers hoping a device class_init() will be easier to understand. Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20180114020412.26160-3-f4bug@amsat.org> Reviewed-by: Laurent Vivier Signed-off-by: Paolo Bonzini (cherry picked from commit 46795cf2e2f643ace9454822022ba8b1e9c0cf61) *prereq for 0c53057adb Signed-off-by: Michael Roth --- hw/core/qdev.c | 24 ++++++++++++++++++++++++ include/hw/qdev-core.h | 10 ++++++++++ 2 files changed, 34 insertions(+) diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 11112951a5..a71cd264e2 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -1140,6 +1140,30 @@ static void device_class_init(ObjectClass *class, void *data) dc->user_creatable = true; } +void device_class_set_parent_reset(DeviceClass *dc, + DeviceReset dev_reset, + DeviceReset *parent_reset) +{ + *parent_reset = dc->reset; + dc->reset = dev_reset; +} + +void device_class_set_parent_realize(DeviceClass *dc, + DeviceRealize dev_realize, + DeviceRealize *parent_realize) +{ + *parent_realize = dc->realize; + dc->realize = dev_realize; +} + +void device_class_set_parent_unrealize(DeviceClass *dc, + DeviceUnrealize dev_unrealize, + DeviceUnrealize *parent_unrealize) +{ + *parent_unrealize = dc->unrealize; + dc->unrealize = dev_unrealize; +} + void device_reset(DeviceState *dev) { DeviceClass *klass = DEVICE_GET_CLASS(dev); diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index 83db53b3f5..0fc53b33d0 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -381,6 +381,16 @@ void qdev_machine_init(void); */ void device_reset(DeviceState *dev); +void device_class_set_parent_reset(DeviceClass *dc, + DeviceReset dev_reset, + DeviceReset *parent_reset); +void device_class_set_parent_realize(DeviceClass *dc, + DeviceRealize dev_realize, + DeviceRealize *parent_realize); +void device_class_set_parent_unrealize(DeviceClass *dc, + DeviceUnrealize dev_unrealize, + DeviceUnrealize *parent_unrealize); + const struct VMStateDescription *qdev_get_vmsd(DeviceState *dev); const char *qdev_fw_name(DeviceState *dev); From patchwork Tue Jun 19 01:42: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: 931345 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="B0WUhYUa"; 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 418tTk6Lbnz9s3C for ; Tue, 19 Jun 2018 13:18:50 +1000 (AEST) Received: from localhost ([::1]:38971 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV7AO-0008NP-Hd for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 23:18:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47169) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5jk-0003DB-0J for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:47:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5ji-0000uA-F3 for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:47:12 -0400 Received: from mail-oi0-x22f.google.com ([2607:f8b0:4003:c06::22f]:35628) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5ji-0000tn-8J; Mon, 18 Jun 2018 21:47:10 -0400 Received: by mail-oi0-x22f.google.com with SMTP id e8-v6so16716020oii.2; Mon, 18 Jun 2018 18:47: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=2sv0RtVZTt50sXylQZf9RQAUeeIB7zRRdlsTCZ0G5Ak=; b=B0WUhYUaoBohlJJ0ukWrx8vXGUefLiMZdYJQ77PAUOvpyTASgNm7WQ5VOwSpeGSHW7 qPoVqLiuKZYTJNiSV7K5VJKjqIqY/yXsQ639VykKoqnzxH+OP+avXQ/8bElmd5FFaQIt WFBqnkB1HHS2OVkfFKVpTFdFeU5s8KZ8j0UuKx0nDRJThTei/fd9zo68ojBoLI+Bxc+a zbbI2fdx5uXtQoGhif3tY5+SPFqTDnu1kiTLp/OlNHy6WjPWjVgEH07CmBuGZroywLyW ge0DiREgY3+slrJR3OFib2JHdjM++LaEAGSV6G1N2Yi9H2ra1lJGtQv54Yt1YM0/Jb/q ekvA== 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=2sv0RtVZTt50sXylQZf9RQAUeeIB7zRRdlsTCZ0G5Ak=; b=laYa1HrARYyQwT5WwwtLTmncIyxvrFXvOPzaEw1+S91pQC+BxOXUsfMjtx4OHn64aI kE6PExQy6igdTvM6q6TlZhGUkVCHH9a2dx8rIR0c4qIawhf1DMa3Ytbt6hsJeWgwoxHy UAAZ51pk4fZ1iqU7LaMAe8him3bJra0+J0VLYottMboXMNAkNDaxtRf3cUjSW1Hi52Af FdpyKVWmjA+rVYD6kfBfWZ0y1xyEWIWKKeVCtA9fU5Aw28l6fV/+/ToY33/JmNMXClcw 5B6MTY4prTsNIXoanwmPG5oG4yHS3IIF5YHk5fI0bBTNnyCvG2F0C1XiPz8rNvD5Wy2S VbBw== X-Gm-Message-State: APt69E3PVEmi9HGYwEsRXVAiza5vwaAu14U64GX6q+tSAE6utXgOVcQe a4FsmNOKsObUnySQx8OduwJOGglvxKA= X-Google-Smtp-Source: ADUXVKLfj9xPTmKItpVrpxklJql64ioUyGwYXt2SCs9wcZmI30GW0WM074mPNNMvAR7npVXUWTP2nw== X-Received: by 2002:aca:abca:: with SMTP id u193-v6mr8817660oie.124.1529372829104; Mon, 18 Jun 2018 18:47:09 -0700 (PDT) Received: from localhost ([2600:1700:70:e488:b0ee:9bda:ee6f:91be]) by smtp.gmail.com with ESMTPSA id l7-v6sm6625163oii.29.2018.06.18.18.47.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:47:08 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:47 -0500 Message-Id: <20180619014319.28272-82-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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 081/113] s390x/virtio: Convert virtio-ccw from *_exit to *_unrealize 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: Nia Alarie , Cornelia Huck , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Nia Alarie Signed-off-by: Nia Alarie Message-Id: <20180307162958.11232-1-nia.alarie@gmail.com> Reviewed-by: Stefan Hajnoczi Signed-off-by: Cornelia Huck (cherry picked from commit 24118af846868bb22e573be206c63e684ba9846a) *prereq for 0c53057adb Signed-off-by: Michael Roth --- hw/s390x/virtio-ccw.c | 34 +++++++++++++++++----------------- hw/s390x/virtio-ccw.h | 2 +- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c index 184515ce94..8f2998e8ac 100644 --- a/hw/s390x/virtio-ccw.c +++ b/hw/s390x/virtio-ccw.c @@ -751,7 +751,7 @@ out_err: g_free(sch); } -static int virtio_ccw_exit(VirtioCcwDevice *dev) +static void virtio_ccw_unrealize(VirtioCcwDevice *dev, Error **errp) { CcwDevice *ccw_dev = CCW_DEVICE(dev); SubchDev *sch = ccw_dev->sch; @@ -759,12 +759,12 @@ static int virtio_ccw_exit(VirtioCcwDevice *dev) if (sch) { css_subch_assign(sch->cssid, sch->ssid, sch->schid, sch->devno, NULL); g_free(sch); + ccw_dev->sch = NULL; } if (dev->indicators) { release_indicator(&dev->routes.adapter, dev->indicators); dev->indicators = NULL; } - return 0; } static void virtio_ccw_net_realize(VirtioCcwDevice *ccw_dev, Error **errp) @@ -1343,7 +1343,7 @@ static void virtio_ccw_net_class_init(ObjectClass *klass, void *data) VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass); k->realize = virtio_ccw_net_realize; - k->exit = virtio_ccw_exit; + k->unrealize = virtio_ccw_unrealize; dc->reset = virtio_ccw_reset; dc->props = virtio_ccw_net_properties; set_bit(DEVICE_CATEGORY_NETWORK, dc->categories); @@ -1371,7 +1371,7 @@ static void virtio_ccw_blk_class_init(ObjectClass *klass, void *data) VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass); k->realize = virtio_ccw_blk_realize; - k->exit = virtio_ccw_exit; + k->unrealize = virtio_ccw_unrealize; dc->reset = virtio_ccw_reset; dc->props = virtio_ccw_blk_properties; set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); @@ -1399,7 +1399,7 @@ static void virtio_ccw_serial_class_init(ObjectClass *klass, void *data) VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass); k->realize = virtio_ccw_serial_realize; - k->exit = virtio_ccw_exit; + k->unrealize = virtio_ccw_unrealize; dc->reset = virtio_ccw_reset; dc->props = virtio_ccw_serial_properties; set_bit(DEVICE_CATEGORY_INPUT, dc->categories); @@ -1427,7 +1427,7 @@ static void virtio_ccw_balloon_class_init(ObjectClass *klass, void *data) VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass); k->realize = virtio_ccw_balloon_realize; - k->exit = virtio_ccw_exit; + k->unrealize = virtio_ccw_unrealize; dc->reset = virtio_ccw_reset; dc->props = virtio_ccw_balloon_properties; set_bit(DEVICE_CATEGORY_MISC, dc->categories); @@ -1455,7 +1455,7 @@ static void virtio_ccw_scsi_class_init(ObjectClass *klass, void *data) VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass); k->realize = virtio_ccw_scsi_realize; - k->exit = virtio_ccw_exit; + k->unrealize = virtio_ccw_unrealize; dc->reset = virtio_ccw_reset; dc->props = virtio_ccw_scsi_properties; set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); @@ -1482,7 +1482,7 @@ static void vhost_ccw_scsi_class_init(ObjectClass *klass, void *data) VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass); k->realize = vhost_ccw_scsi_realize; - k->exit = virtio_ccw_exit; + k->unrealize = virtio_ccw_unrealize; dc->reset = virtio_ccw_reset; dc->props = vhost_ccw_scsi_properties; set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); @@ -1519,7 +1519,7 @@ static void virtio_ccw_rng_class_init(ObjectClass *klass, void *data) VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass); k->realize = virtio_ccw_rng_realize; - k->exit = virtio_ccw_exit; + k->unrealize = virtio_ccw_unrealize; dc->reset = virtio_ccw_reset; dc->props = virtio_ccw_rng_properties; set_bit(DEVICE_CATEGORY_MISC, dc->categories); @@ -1557,7 +1557,7 @@ static void virtio_ccw_crypto_class_init(ObjectClass *klass, void *data) VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass); k->realize = virtio_ccw_crypto_realize; - k->exit = virtio_ccw_exit; + k->unrealize = virtio_ccw_unrealize; dc->reset = virtio_ccw_reset; dc->props = virtio_ccw_crypto_properties; set_bit(DEVICE_CATEGORY_MISC, dc->categories); @@ -1595,7 +1595,7 @@ static void virtio_ccw_gpu_class_init(ObjectClass *klass, void *data) VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass); k->realize = virtio_ccw_gpu_realize; - k->exit = virtio_ccw_exit; + k->unrealize = virtio_ccw_unrealize; dc->reset = virtio_ccw_reset; dc->props = virtio_ccw_gpu_properties; dc->hotpluggable = false; @@ -1624,7 +1624,7 @@ static void virtio_ccw_input_class_init(ObjectClass *klass, void *data) VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass); k->realize = virtio_ccw_input_realize; - k->exit = virtio_ccw_exit; + k->unrealize = virtio_ccw_unrealize; dc->reset = virtio_ccw_reset; dc->props = virtio_ccw_input_properties; set_bit(DEVICE_CATEGORY_INPUT, dc->categories); @@ -1704,12 +1704,12 @@ static void virtio_ccw_busdev_realize(DeviceState *dev, Error **errp) virtio_ccw_device_realize(_dev, errp); } -static int virtio_ccw_busdev_exit(DeviceState *dev) +static void virtio_ccw_busdev_unrealize(DeviceState *dev, Error **errp) { VirtioCcwDevice *_dev = (VirtioCcwDevice *)dev; VirtIOCCWDeviceClass *_info = VIRTIO_CCW_DEVICE_GET_CLASS(dev); - return _info->exit(_dev); + _info->unrealize(_dev, errp); } static void virtio_ccw_busdev_unplug(HotplugHandler *hotplug_dev, @@ -1727,7 +1727,7 @@ static void virtio_ccw_device_class_init(ObjectClass *klass, void *data) k->unplug = virtio_ccw_busdev_unplug; dc->realize = virtio_ccw_busdev_realize; - dc->exit = virtio_ccw_busdev_exit; + dc->unrealize = virtio_ccw_busdev_unrealize; dc->bus_type = TYPE_VIRTUAL_CSS_BUS; } @@ -1803,7 +1803,7 @@ static void virtio_ccw_9p_class_init(ObjectClass *klass, void *data) DeviceClass *dc = DEVICE_CLASS(klass); VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass); - k->exit = virtio_ccw_exit; + k->unrealize = virtio_ccw_unrealize; k->realize = virtio_ccw_9p_realize; dc->reset = virtio_ccw_reset; dc->props = virtio_ccw_9p_properties; @@ -1852,7 +1852,7 @@ static void vhost_vsock_ccw_class_init(ObjectClass *klass, void *data) VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass); k->realize = vhost_vsock_ccw_realize; - k->exit = virtio_ccw_exit; + k->unrealize = virtio_ccw_unrealize; set_bit(DEVICE_CATEGORY_MISC, dc->categories); dc->props = vhost_vsock_ccw_properties; dc->reset = virtio_ccw_reset; diff --git a/hw/s390x/virtio-ccw.h b/hw/s390x/virtio-ccw.h index 3905f3a3d6..2fc513001e 100644 --- a/hw/s390x/virtio-ccw.h +++ b/hw/s390x/virtio-ccw.h @@ -76,7 +76,7 @@ typedef struct VirtioCcwDevice VirtioCcwDevice; typedef struct VirtIOCCWDeviceClass { CCWDeviceClass parent_class; void (*realize)(VirtioCcwDevice *dev, Error **errp); - int (*exit)(VirtioCcwDevice *dev); + void (*unrealize)(VirtioCcwDevice *dev, Error **errp); } VirtIOCCWDeviceClass; /* Performance improves when virtqueue kick processing is decoupled from the From patchwork Tue Jun 19 01:42: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: 931344 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="HMivgnSG"; 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 418tT86WBnz9s3C for ; Tue, 19 Jun 2018 13:18:19 +1000 (AEST) Received: from localhost ([::1]:38966 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV79r-0007wd-MB for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 23:18:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47193) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5jl-0003FF-QT for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:47:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5jk-0000vP-Ot for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:47:13 -0400 Received: from mail-ot0-x229.google.com ([2607:f8b0:4003:c0f::229]:43682) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5jk-0000vG-Hi; Mon, 18 Jun 2018 21:47:12 -0400 Received: by mail-ot0-x229.google.com with SMTP id i19-v6so20746164otk.10; Mon, 18 Jun 2018 18:47: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=qAoGHw69s/9NyudgDsjO5zXUThKXPUmDUY+0d2D9acE=; b=HMivgnSGxonH5QgQH8wMG5jprRqz8M164XfDsvuvLsH9ivH1I9tMCBDKXurJRfyA1L 9dpGukF78Dq1hAB54keJvXcAMEY3vzqEm84YM5OHDebz5CSVb9FuyxrUQIo48W6JBXqy ZX6BtCOvYdZZ4dz78bs6QmolzX4GWPFLUee8QrVbmKmS3VkP55sz2ndWJ14kihEy800A HHcnzqb0aW8nmHUvGM9Ts92CdFWMY4ROPxaWrTBgA3hf3Vzb3QsHhA31ZAWsKWr8rr3h h47tzGaHiqzygKzH234PwoaO9zR9gzgSyPQuyibtAffryYQtESXSm7mwhh0AI1GQW1Ch 3ygQ== 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=qAoGHw69s/9NyudgDsjO5zXUThKXPUmDUY+0d2D9acE=; b=ELJYleq7rRqENlBwpW0HqX6KS+uLig94tQvqsFziwfXnIioF6jlMSJ3xF8paphG3A3 6i/xRxPQVsEYFplW3GqFV+/kECxFo8tLz3tdIsUxYEp0dxJ7F5HfSUBbWcER5APqOoRD Pc8J+uaxKyQoOtJWusTkwcFqqag8q28qLPqDX44YlRBIyLpGLow9diupANQGOiwtSpqJ 7GbgpolCplxYFZI2huEvGVEklLiu+23fSMiE4prEQkIrgTPHiwX0M2mFghwi5vyjZ/yY kMKdPs2pXNeek6Eir8AeuYYogI3AUMiw/aAe611Ln9RdhC0IkRykEjK3sE85ZGeaShv1 Vhrg== X-Gm-Message-State: APt69E1VXmLnRVq2q1TnBqz24dAbZPuqTUoOkgguDyk/S3LQLDO2fHxL LnmQqEN4wfgduVpRh+8dqi4iwd06pHg= X-Google-Smtp-Source: ADUXVKIWZIofsePsMMGySTCe++NxH2cCLxDu8jpcMGUGdkMNjlhbiIKqx4pGmlZBH/nxuP5xYbsK+Q== X-Received: by 2002:a9d:6245:: with SMTP id i5-v6mr9866012otk.253.1529372831357; Mon, 18 Jun 2018 18:47:11 -0700 (PDT) Received: from localhost ([2600:1700:70:e488:b0ee:9bda:ee6f:91be]) by smtp.gmail.com with ESMTPSA id 64-v6sm7820417ots.36.2018.06.18.18.47.09 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:47:10 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:48 -0500 Message-Id: <20180619014319.28272-83-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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:c0f::229 Subject: [Qemu-devel] [PATCH 082/113] 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 8f2998e8ac..3197ca30be 100644 --- a/hw/s390x/virtio-ccw.c +++ b/hw/s390x/virtio-ccw.c @@ -1344,7 +1344,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); } @@ -1372,7 +1371,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); } @@ -1400,7 +1398,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); } @@ -1428,7 +1425,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); } @@ -1456,7 +1452,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); } @@ -1483,7 +1478,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); } @@ -1520,7 +1514,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); } @@ -1558,7 +1551,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); } @@ -1596,7 +1588,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); @@ -1625,7 +1616,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); } @@ -1729,6 +1719,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 = { @@ -1805,7 +1796,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); } @@ -1855,7 +1845,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 Tue Jun 19 01:42: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: 931347 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="VwMNYbJa"; 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 418tXQ2VKvz9s0W for ; Tue, 19 Jun 2018 13:21:10 +1000 (AEST) Received: from localhost ([::1]:38990 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV7Cd-0001vd-Vw for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 23:21:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47219) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5jn-0003G6-Vg for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:47:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5jm-0000wI-W0 for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:47:16 -0400 Received: from mail-oi0-x235.google.com ([2607:f8b0:4003:c06::235]:41489) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5jm-0000w2-Qu; Mon, 18 Jun 2018 21:47:14 -0400 Received: by mail-oi0-x235.google.com with SMTP id a141-v6so16696585oii.8; Mon, 18 Jun 2018 18:47: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=mFvF8XwxHWYHs0mlXrO+lkEeaM8MHCNJ+iNrOvWliIY=; b=VwMNYbJaUEn6WJDQpELpyl5xYaxpHU+7vq98+7ac1jLeyESSlqt2eLwCjOteJUPdbl CoO4u9/DjKHLPdVkW5UaANGzY/4PtW6d/DYMRFPyT2yl2MElex5tu0LBxXVbR5/sF0c2 PdfIZeZJ/u3eNLdkkFcNYJzZnSxOsQ7Xdw0JgOCAKszk4uP6jFxGyulzN3SeSJlOM0Yw PGnfYWPVmAP9NnM29NWwSplOfoE22/B2dGyTdk4tllVkSad3WOhoo5+V7tT9lxqjE7bB 9JH83sA9aaRWb3PmLaNyLe7k7D+UTCgx7+neeOFHeSYI9kwj+XAbTlB/DVvpX4PhG3Xp 5l4Q== 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=mFvF8XwxHWYHs0mlXrO+lkEeaM8MHCNJ+iNrOvWliIY=; b=FT8OS5kdhYjdgojw3wgFigiQBPqCH+GbS7smY8k8pD2YenWlrR9t4QethFViMJirFW UMDtj576fW+nWAclDVVA1V5/sD9XfDNpCnvIWTa8gDq+f9dugWvo7KxEoNSyvi3EfjYa J0h1REoGiTCjgK90TH46aVoYTkbO6YnQZ7HsOmym3CmgXcPaYLifEZO7ZsZ8+dLOZkc8 0mj1NX/BT8LIL5q7BeGyGnuonynr89dBP2EhW3heWaP9/0sbcqSjHVmDGNu2EVKnuSMg 3wtRtKwqZiMBOW6IW6bMb7/qtKekVVLkcBJYq91PipMvaTatzftYmQZuSi9IYoUEoOil HKIA== X-Gm-Message-State: APt69E2M/fQrDCkWu7ayPJwihwOQQrprH3GExs/fhogKSRFN6vIaQv1S RtZkkRYQFX40YsbWBJ3y3Qmxh6ucsZQ= X-Google-Smtp-Source: ADUXVKLIiV2z5PxcnRdLOl+2SsGK5p8PVBn8fsUdB3eSzWkUnQ5fXysuwkJ9nRojkqN1jSwbFqTi4Q== X-Received: by 2002:aca:e7c8:: with SMTP id e191-v6mr8040577oih.202.1529372833560; Mon, 18 Jun 2018 18:47:13 -0700 (PDT) Received: from localhost ([2600:1700:70:e488:b0ee:9bda:ee6f:91be]) by smtp.gmail.com with ESMTPSA id f64-v6sm8460031oib.10.2018.06.18.18.47.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:47:12 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:49 -0500 Message-Id: <20180619014319.28272-84-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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 083/113] 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 3197ca30be..e9a594ca86 100644 --- a/hw/s390x/virtio-ccw.c +++ b/hw/s390x/virtio-ccw.c @@ -1057,10 +1057,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) @@ -1714,12 +1716,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 Tue Jun 19 01:42: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: 931348 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="u4I0vrvh"; 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 418tb05pkzz9s19 for ; Tue, 19 Jun 2018 13:23:23 +1000 (AEST) Received: from localhost ([::1]:39002 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV7Em-0003gQ-4a for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 23:23:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47241) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5jp-0003H3-IC for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:47:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5jo-0000wo-Sc for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:47:17 -0400 Received: from mail-ot0-x241.google.com ([2607:f8b0:4003:c0f::241]:40782) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5jo-0000wf-Nh; Mon, 18 Jun 2018 21:47:16 -0400 Received: by mail-ot0-x241.google.com with SMTP id w9-v6so20748890otj.7; Mon, 18 Jun 2018 18:47:16 -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=UhM4EtKvojSnL2UCEGrkZClAl5TYIKOqJIN4IMMdDMs=; b=u4I0vrvhkVhXnxKWerLAo8KzawiHgc17qM5D3OxjT3VlFnIaAVClXS3xQxJfabTEEj 3SrtpYPzUZTsw07OmYFYKZl61I+fX5Alb71I+7ogFvbTUhJnQDNdr1GKKvrJ5gMZFYhM CyHpsy09uiAL0qy+7UTw2jwsljC/9AL0flaG9KXBQiazCo5A8WpP1WTFM4hODde7Sep8 IKNOzkuN1UpY5doOj3jj09EBGAlwweieXZ9HhALWGz5cIQ9PnDUZQtFRo2cZM7uZye6a n3Q1w8Iyzu2ndgRav3VT6M994sKEa2Chp2NCUoA8LqsuXlP4UHdAdwO0dGDhXFeJQ0+E VZcQ== 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=UhM4EtKvojSnL2UCEGrkZClAl5TYIKOqJIN4IMMdDMs=; b=kXejr3UdFniYKKraQaDcPMLZDRjq3gOpmYa5LP+OITmdn4xc/pa7LqvcRIPvPsoPI8 Xn+10ww3Nz9aatwPuU2D39P5rPL5fGiPyZmYWsG1nSFPH94YI96awyATbzC6Z821XPZT IdZ2opktcu0ikZhfDiplNKt4A0QN7UblvMMeGHJ7WWw/ydHSBGK2WpUV+ylVYV+NAUPb 5NF7dOGPoWYE7sjkvUeKpXWO4cltcHy2EiwReZP+1xdFrQAWp+hJmf6q7E2kwhaV+yIV h3K53n3IiS2z1726TNSuFNwHmlT9frKyIOdliEqelYDTfiEGvfPgi3bue61g7e1AqDyU f0LQ== X-Gm-Message-State: APt69E29pwDx81zLKj/zB5jP9BSwJ8n5R500SRGHwIsprzG9ChuN2cK0 zWjqMK8BBC4gggKfJsuQqv15p9P7Al4= X-Google-Smtp-Source: ADUXVKIjHy0xRjRD/sSbUjc1oDaO/TTVcKBNjdpCcY0d7LbKZ4EuPuHF+WzXc0hecD0URpCSkj8bOg== X-Received: by 2002:a9d:2371:: with SMTP id k46-v6mr9815457otd.210.1529372835402; Mon, 18 Jun 2018 18:47:15 -0700 (PDT) Received: from localhost ([2600:1700:70:e488:b0ee:9bda:ee6f:91be]) by smtp.gmail.com with ESMTPSA id m191-v6sm7996266oig.0.2018.06.18.18.47.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:47:14 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:50 -0500 Message-Id: <20180619014319.28272-85-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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:c0f::241 Subject: [Qemu-devel] [PATCH 084/113] 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 c4c95abed7..96272b5c45 100644 --- a/ui/console.c +++ b/ui/console.c @@ -354,6 +354,11 @@ void qmp_screendump(const char *filename, Error **errp) graphic_hw_update(con); surface = qemu_console_surface(con); + if (!surface) { + error_setg(errp, "no surface"); + return; + } + ppm_save(filename, surface, errp); } From patchwork Tue Jun 19 01:42:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 931333 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="pberpOqG"; 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 418tG15mpRz9s0W for ; Tue, 19 Jun 2018 13:08:41 +1000 (AEST) Received: from localhost ([::1]:38905 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV70Z-0008Up-Et for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 23:08:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47283) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5jr-0003JU-VC for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:47:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5jr-0000y0-0B for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:47:20 -0400 Received: from mail-oi0-x232.google.com ([2607:f8b0:4003:c06::232]:38232) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5jq-0000xl-Qh; Mon, 18 Jun 2018 21:47:18 -0400 Received: by mail-oi0-x232.google.com with SMTP id d5-v6so16700622oib.5; Mon, 18 Jun 2018 18:47: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; bh=K1fVvFVR9psmpjKEpC+WYzWAk6uhWDnKxocJlF0NK2o=; b=pberpOqGFixdzk5GV14h+jpWcAbrsAHWo5R6H+FGqVQpNp+oP6sunz9+tc8pbquAk+ GYNOwtnlN2xe40NT/DN8rOlFzuGfl8ORf87KboUfBzskSvjtnTc9HSqbZdjxt1kEBZrQ 731Qx6LT39CUXRfcU5atVmvvxGjpLBpfZCnOXdk8S8WlvK93lIRWeDJ1t9FPb46541aj sO/5KPH8/vJXEDH0OArO3AJGdcyejdApN8sfaLaWrRrkL0tx7ljkRvmmwq7hotveNd7I qVllXwtMKFwtd52N4kTYYS/27+HSroBxTntHrvv18XWGPdh8oI2t6yir0hxTx9p9wp9M 0dlQ== 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=K1fVvFVR9psmpjKEpC+WYzWAk6uhWDnKxocJlF0NK2o=; b=Un+zF82dhJ64IUgslmMgFs2lD2+pOtfu7es2hw7DPd7PXHhny48setT82soayYQ/dK /2hPbutteH3/fFbylAmCMgahaOpxhbfB0x6U30vIDOHeP180dKCKjqs6uugj+OHM1HxF Np82vrSCEEbl+8Yucpy3BINx3AkZZEEz7H11JImeVtNpfTjkFIky3NVIhYjB083Doqhc KYkqFb98nawmM/eLlouLce3VSHqYhrEwWuLSqMntxXKYrQGH4LX3tuXfk60ODwjH0E/u puRstz/anR454/psNjR+iRzVHbUKrv3b0kxtVuc3seRMYJUl697il/RsuSSaQ0h3w3BJ F5Dg== X-Gm-Message-State: APt69E2TRDus+HaawxMoyRKYefnNL5x+lKxI3AJPSkGnSl/FPHdofR10 6Urt8EFg7wRIN9WshiwcL/ZydBrjo1g= X-Google-Smtp-Source: ADUXVKL6IskJlq8yTi3zX334iW6NEyfOf6uXw0Ue7KtCvoYJc57gpeyG+LORSyzX3aEA1v4yrKGHog== X-Received: by 2002:aca:a887:: with SMTP id r129-v6mr8473274oie.253.1529372837663; Mon, 18 Jun 2018 18:47:17 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id j47-v6sm217635oth.49.2018.06.18.18.47.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:47:16 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:51 -0500 Message-Id: <20180619014319.28272-86-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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 085/113] 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 5cbafaf497..519d581bb6 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 Tue Jun 19 01:42:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 931339 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="sZyBSuiV"; 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 418tMD0Mf6z9s0W for ; Tue, 19 Jun 2018 13:13:12 +1000 (AEST) Received: from localhost ([::1]:38931 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV74v-0003ll-Mx for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 23:13:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47330) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5jy-0003Ow-7Z for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:47:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5jt-0000yi-9U for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:47:26 -0400 Received: from mail-ot0-x22e.google.com ([2607:f8b0:4003:c0f::22e]:36940) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5jt-0000yX-30; Mon, 18 Jun 2018 21:47:21 -0400 Received: by mail-ot0-x22e.google.com with SMTP id 101-v6so20786741oth.4; Mon, 18 Jun 2018 18:47:20 -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=TercCgeGprzlU0q8nFGzc+57jexaNaCXIULE4AAJmgs=; b=sZyBSuiVs41TvyO0Yn+uJbanesd3aUAWZ/fZ3QSDUWkElQST+aO6YST2BkRdJalZCM aLLIQOTUmrGCwQhmTAqiQV+IZ26OYywVjW4JgYBG7kNeQf7HHql/8RjWHPdwXySwUJPs eT1m6POv1LUpo8Xa1EblD5u9dVlrsfEQhWkZZZXCB+aKxIrsOR0HBTRF6HIznarehZby jg5PoPgv4I/kTBN09dFifO0GCyc7DZYtCKdQQ8nxv7X+4hC7JFFXRcyS9qh1vjCV2Xmg ecYokOdmW4srgGSUTGpw+rs/PgCbFtF8ftwier5Ggs0CfRObBVClDl5fIkiWM8ZmzRG3 T5mQ== 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=TercCgeGprzlU0q8nFGzc+57jexaNaCXIULE4AAJmgs=; b=Cn6v1z7tfrrAZfrTM30+sNq40yCudlWV6j7szhjlQdbzvt4gTY50ij0icg1HByge8a uQtbpeU1G16/FAS9K4GDzMMvL/pQST9y2sSURUWKz9vFdHc019aajr1XMcQjWMB3r+fV 4v/rWq1AgQtWa+e1YOfHt2yb0VjrsvB93R1uWPcP/v/L6BoMYJtcb86AL5qbWdtMn67N Wj/CVtcah6z3GbsViK8F3c9TMIlykgVvtll7sYYEuVOFnZZ9RSFeSTsacrK2eZIjdkIo 26DxOccyi7GClDgaxuueBSVJ1n/KFxt9cJpzhS1t2m/qy5zI69j9s4WRrxgn+/UhZgSK xtUw== X-Gm-Message-State: APt69E2y1mCjsaWUACFIRe+ficKrSj4PFz5BfQy01WZBjKqzOqUr+qiQ 6889l9n7zPzRWkkmngvgplMyJDZgr0s= X-Google-Smtp-Source: ADUXVKJ8fxsjQZ3rX8+fDKLA0KCX9XddyC03dfjMyeWHWhpswUI10XfcAGtLQ+qveykpPDqv4SnPHQ== X-Received: by 2002:a9d:4a63:: with SMTP id d32-v6mr9953276otj.194.1529372839742; Mon, 18 Jun 2018 18:47:19 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id 97-v6sm7801975oth.15.2018.06.18.18.47.18 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:47:18 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:52 -0500 Message-Id: <20180619014319.28272-87-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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:c0f::22e Subject: [Qemu-devel] [PATCH 086/113] intel-iommu: Redefine macros to enable supporting 48 bit address width 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 S . Tsirkin" , qemu-stable@nongnu.org, Prasad Singamsetty , Prasad Singamsetty Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Prasad Singamsetty The current implementation of Intel IOMMU code only supports 39 bits host/iova address width so number of macros use hard coded values based on that. This patch is to redefine them so they can be used with variable address widths. This patch doesn't add any new functionality but enables adding support for 48 bit address width. Signed-off-by: Prasad Singamsetty Reviewed-by: Peter Xu Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin (cherry picked from commit 92e5d85e8345a22e87eda940ffe0f6422eb45360) Signed-off-by: Michael Roth --- hw/i386/intel_iommu.c | 54 ++++++++++++++++++++++++------------------ hw/i386/intel_iommu_internal.h | 34 +++++++++++++++++++------- include/hw/i386/intel_iommu.h | 6 +++-- 3 files changed, 61 insertions(+), 33 deletions(-) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 3a5bb0bc2e..53b3bf244d 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -523,7 +523,7 @@ static inline dma_addr_t vtd_ce_get_slpt_base(VTDContextEntry *ce) static inline uint64_t vtd_get_slpte_addr(uint64_t slpte) { - return slpte & VTD_SL_PT_BASE_ADDR_MASK; + return slpte & VTD_SL_PT_BASE_ADDR_MASK(VTD_HOST_ADDRESS_WIDTH); } /* Whether the pte indicates the address of the page frame */ @@ -624,19 +624,12 @@ static inline bool vtd_iova_range_check(uint64_t iova, VTDContextEntry *ce) return !(iova & ~(vtd_iova_limit(ce) - 1)); } -static const uint64_t vtd_paging_entry_rsvd_field[] = { - [0] = ~0ULL, - /* For not large page */ - [1] = 0x800ULL | ~(VTD_HAW_MASK | VTD_SL_IGN_COM), - [2] = 0x800ULL | ~(VTD_HAW_MASK | VTD_SL_IGN_COM), - [3] = 0x800ULL | ~(VTD_HAW_MASK | VTD_SL_IGN_COM), - [4] = 0x880ULL | ~(VTD_HAW_MASK | VTD_SL_IGN_COM), - /* For large page */ - [5] = 0x800ULL | ~(VTD_HAW_MASK | VTD_SL_IGN_COM), - [6] = 0x1ff800ULL | ~(VTD_HAW_MASK | VTD_SL_IGN_COM), - [7] = 0x3ffff800ULL | ~(VTD_HAW_MASK | VTD_SL_IGN_COM), - [8] = 0x880ULL | ~(VTD_HAW_MASK | VTD_SL_IGN_COM), -}; +/* + * Rsvd field masks for spte: + * Index [1] to [4] 4k pages + * Index [5] to [8] large pages + */ +static uint64_t vtd_paging_entry_rsvd_field[9]; static bool vtd_slpte_nonzero_rsvd(uint64_t slpte, uint32_t level) { @@ -874,7 +867,7 @@ static int vtd_dev_to_context_entry(IntelIOMMUState *s, uint8_t bus_num, return -VTD_FR_ROOT_ENTRY_P; } - if (re.rsvd || (re.val & VTD_ROOT_ENTRY_RSVD)) { + if (re.rsvd || (re.val & VTD_ROOT_ENTRY_RSVD(VTD_HOST_ADDRESS_WIDTH))) { trace_vtd_re_invalid(re.rsvd, re.val); return -VTD_FR_ROOT_ENTRY_RSVD; } @@ -891,7 +884,7 @@ static int vtd_dev_to_context_entry(IntelIOMMUState *s, uint8_t bus_num, } if ((ce->hi & VTD_CONTEXT_ENTRY_RSVD_HI) || - (ce->lo & VTD_CONTEXT_ENTRY_RSVD_LO)) { + (ce->lo & VTD_CONTEXT_ENTRY_RSVD_LO(VTD_HOST_ADDRESS_WIDTH))) { trace_vtd_ce_invalid(ce->hi, ce->lo); return -VTD_FR_CONTEXT_ENTRY_RSVD; } @@ -1207,7 +1200,7 @@ static void vtd_root_table_setup(IntelIOMMUState *s) { s->root = vtd_get_quad_raw(s, DMAR_RTADDR_REG); s->root_extended = s->root & VTD_RTADDR_RTT; - s->root &= VTD_RTADDR_ADDR_MASK; + s->root &= VTD_RTADDR_ADDR_MASK(VTD_HOST_ADDRESS_WIDTH); trace_vtd_reg_dmar_root(s->root, s->root_extended); } @@ -1223,7 +1216,7 @@ static void vtd_interrupt_remap_table_setup(IntelIOMMUState *s) uint64_t value = 0; value = vtd_get_quad_raw(s, DMAR_IRTA_REG); s->intr_size = 1UL << ((value & VTD_IRTA_SIZE_MASK) + 1); - s->intr_root = value & VTD_IRTA_ADDR_MASK; + s->intr_root = value & VTD_IRTA_ADDR_MASK(VTD_HOST_ADDRESS_WIDTH); s->intr_eime = value & VTD_IRTA_EIME; /* Notify global invalidation */ @@ -1479,7 +1472,7 @@ static void vtd_handle_gcmd_qie(IntelIOMMUState *s, bool en) trace_vtd_inv_qi_enable(en); if (en) { - s->iq = iqa_val & VTD_IQA_IQA_MASK; + s->iq = iqa_val & VTD_IQA_IQA_MASK(VTD_HOST_ADDRESS_WIDTH); /* 2^(x+8) entries */ s->iq_size = 1UL << ((iqa_val & VTD_IQA_QS) + 8); s->qi_enabled = true; @@ -2772,12 +2765,12 @@ static void vtd_address_space_unmap(VTDAddressSpace *as, IOMMUNotifier *n) * VT-d spec), otherwise we need to consider overflow of 64 bits. */ - if (end > VTD_ADDRESS_SIZE) { + if (end > VTD_ADDRESS_SIZE(VTD_HOST_ADDRESS_WIDTH)) { /* * Don't need to unmap regions that is bigger than the whole * VT-d supported address space size */ - end = VTD_ADDRESS_SIZE; + end = VTD_ADDRESS_SIZE(VTD_HOST_ADDRESS_WIDTH); } assert(start <= end); @@ -2866,6 +2859,7 @@ static void vtd_iommu_replay(IOMMUMemoryRegion *iommu_mr, IOMMUNotifier *n) static void vtd_init(IntelIOMMUState *s) { X86IOMMUState *x86_iommu = X86_IOMMU_DEVICE(s); + uint8_t aw_bits = VTD_HOST_ADDRESS_WIDTH; memset(s->csr, 0, DMAR_REG_SIZE); memset(s->wmask, 0, DMAR_REG_SIZE); @@ -2882,10 +2876,24 @@ static void vtd_init(IntelIOMMUState *s) s->qi_enabled = false; s->iq_last_desc_type = VTD_INV_DESC_NONE; s->next_frcd_reg = 0; - s->cap = VTD_CAP_FRO | VTD_CAP_NFR | VTD_CAP_ND | VTD_CAP_MGAW | - VTD_CAP_SAGAW | VTD_CAP_MAMV | VTD_CAP_PSI | VTD_CAP_SLLPS; + s->cap = VTD_CAP_FRO | VTD_CAP_NFR | VTD_CAP_ND | + VTD_CAP_MAMV | VTD_CAP_PSI | VTD_CAP_SLLPS | + VTD_CAP_SAGAW_39bit | VTD_CAP_MGAW(VTD_HOST_ADDRESS_WIDTH); s->ecap = VTD_ECAP_QI | VTD_ECAP_IRO; + /* + * Rsvd field masks for spte + */ + vtd_paging_entry_rsvd_field[0] = ~0ULL; + vtd_paging_entry_rsvd_field[1] = VTD_SPTE_PAGE_L1_RSVD_MASK(aw_bits); + vtd_paging_entry_rsvd_field[2] = VTD_SPTE_PAGE_L2_RSVD_MASK(aw_bits); + vtd_paging_entry_rsvd_field[3] = VTD_SPTE_PAGE_L3_RSVD_MASK(aw_bits); + vtd_paging_entry_rsvd_field[4] = VTD_SPTE_PAGE_L4_RSVD_MASK(aw_bits); + vtd_paging_entry_rsvd_field[5] = VTD_SPTE_LPAGE_L1_RSVD_MASK(aw_bits); + vtd_paging_entry_rsvd_field[6] = VTD_SPTE_LPAGE_L2_RSVD_MASK(aw_bits); + vtd_paging_entry_rsvd_field[7] = VTD_SPTE_LPAGE_L3_RSVD_MASK(aw_bits); + vtd_paging_entry_rsvd_field[8] = VTD_SPTE_LPAGE_L4_RSVD_MASK(aw_bits); + if (x86_iommu->intr_supported) { s->ecap |= VTD_ECAP_IR | VTD_ECAP_MHMV; if (s->intr_eim == ON_OFF_AUTO_ON) { diff --git a/hw/i386/intel_iommu_internal.h b/hw/i386/intel_iommu_internal.h index 0e73a65bf2..77e4a9833a 100644 --- a/hw/i386/intel_iommu_internal.h +++ b/hw/i386/intel_iommu_internal.h @@ -172,10 +172,10 @@ /* RTADDR_REG */ #define VTD_RTADDR_RTT (1ULL << 11) -#define VTD_RTADDR_ADDR_MASK (VTD_HAW_MASK ^ 0xfffULL) +#define VTD_RTADDR_ADDR_MASK(aw) (VTD_HAW_MASK(aw) ^ 0xfffULL) /* IRTA_REG */ -#define VTD_IRTA_ADDR_MASK (VTD_HAW_MASK ^ 0xfffULL) +#define VTD_IRTA_ADDR_MASK(aw) (VTD_HAW_MASK(aw) ^ 0xfffULL) #define VTD_IRTA_EIME (1ULL << 11) #define VTD_IRTA_SIZE_MASK (0xfULL) @@ -198,8 +198,8 @@ #define VTD_DOMAIN_ID_MASK ((1UL << VTD_DOMAIN_ID_SHIFT) - 1) #define VTD_CAP_ND (((VTD_DOMAIN_ID_SHIFT - 4) / 2) & 7ULL) #define VTD_MGAW 39 /* Maximum Guest Address Width */ -#define VTD_ADDRESS_SIZE (1ULL << VTD_MGAW) -#define VTD_CAP_MGAW (((VTD_MGAW - 1) & 0x3fULL) << 16) +#define VTD_ADDRESS_SIZE(aw) (1ULL << (aw)) +#define VTD_CAP_MGAW(aw) ((((aw) - 1) & 0x3fULL) << 16) #define VTD_MAMV 18ULL #define VTD_CAP_MAMV (VTD_MAMV << 48) #define VTD_CAP_PSI (1ULL << 39) @@ -219,7 +219,7 @@ #define VTD_IQT_QT(val) (((val) >> 4) & 0x7fffULL) /* IQA_REG */ -#define VTD_IQA_IQA_MASK (VTD_HAW_MASK ^ 0xfffULL) +#define VTD_IQA_IQA_MASK(aw) (VTD_HAW_MASK(aw) ^ 0xfffULL) #define VTD_IQA_QS 0x7ULL /* IQH_REG */ @@ -373,6 +373,24 @@ typedef union VTDInvDesc VTDInvDesc; #define VTD_INV_DESC_DEVICE_IOTLB_RSVD_HI 0xffeULL #define VTD_INV_DESC_DEVICE_IOTLB_RSVD_LO 0xffff0000ffe0fff8 +/* Rsvd field masks for spte */ +#define VTD_SPTE_PAGE_L1_RSVD_MASK(aw) \ + (0x800ULL | ~(VTD_HAW_MASK(aw) | VTD_SL_IGN_COM)) +#define VTD_SPTE_PAGE_L2_RSVD_MASK(aw) \ + (0x800ULL | ~(VTD_HAW_MASK(aw) | VTD_SL_IGN_COM)) +#define VTD_SPTE_PAGE_L3_RSVD_MASK(aw) \ + (0x800ULL | ~(VTD_HAW_MASK(aw) | VTD_SL_IGN_COM)) +#define VTD_SPTE_PAGE_L4_RSVD_MASK(aw) \ + (0x880ULL | ~(VTD_HAW_MASK(aw) | VTD_SL_IGN_COM)) +#define VTD_SPTE_LPAGE_L1_RSVD_MASK(aw) \ + (0x800ULL | ~(VTD_HAW_MASK(aw) | VTD_SL_IGN_COM)) +#define VTD_SPTE_LPAGE_L2_RSVD_MASK(aw) \ + (0x1ff800ULL | ~(VTD_HAW_MASK(aw) | VTD_SL_IGN_COM)) +#define VTD_SPTE_LPAGE_L3_RSVD_MASK(aw) \ + (0x3ffff800ULL | ~(VTD_HAW_MASK(aw) | VTD_SL_IGN_COM)) +#define VTD_SPTE_LPAGE_L4_RSVD_MASK(aw) \ + (0x880ULL | ~(VTD_HAW_MASK(aw) | VTD_SL_IGN_COM)) + /* Information about page-selective IOTLB invalidate */ struct VTDIOTLBPageInvInfo { uint16_t domain_id; @@ -403,7 +421,7 @@ typedef struct VTDRootEntry VTDRootEntry; #define VTD_ROOT_ENTRY_CTP (~0xfffULL) #define VTD_ROOT_ENTRY_NR (VTD_PAGE_SIZE / sizeof(VTDRootEntry)) -#define VTD_ROOT_ENTRY_RSVD (0xffeULL | ~VTD_HAW_MASK) +#define VTD_ROOT_ENTRY_RSVD(aw) (0xffeULL | ~VTD_HAW_MASK(aw)) /* Masks for struct VTDContextEntry */ /* lo */ @@ -415,7 +433,7 @@ typedef struct VTDRootEntry VTDRootEntry; #define VTD_CONTEXT_TT_PASS_THROUGH (2ULL << 2) /* Second Level Page Translation Pointer*/ #define VTD_CONTEXT_ENTRY_SLPTPTR (~0xfffULL) -#define VTD_CONTEXT_ENTRY_RSVD_LO (0xff0ULL | ~VTD_HAW_MASK) +#define VTD_CONTEXT_ENTRY_RSVD_LO(aw) (0xff0ULL | ~VTD_HAW_MASK(aw)) /* hi */ #define VTD_CONTEXT_ENTRY_AW 7ULL /* Adjusted guest-address-width */ #define VTD_CONTEXT_ENTRY_DID(val) (((val) >> 8) & VTD_DOMAIN_ID_MASK) @@ -439,7 +457,7 @@ typedef struct VTDRootEntry VTDRootEntry; #define VTD_SL_RW_MASK 3ULL #define VTD_SL_R 1ULL #define VTD_SL_W (1ULL << 1) -#define VTD_SL_PT_BASE_ADDR_MASK (~(VTD_PAGE_SIZE - 1) & VTD_HAW_MASK) +#define VTD_SL_PT_BASE_ADDR_MASK(aw) (~(VTD_PAGE_SIZE - 1) & VTD_HAW_MASK(aw)) #define VTD_SL_IGN_COM 0xbff0000000000000ULL #endif diff --git a/include/hw/i386/intel_iommu.h b/include/hw/i386/intel_iommu.h index ac15e6be14..372b06df45 100644 --- a/include/hw/i386/intel_iommu.h +++ b/include/hw/i386/intel_iommu.h @@ -46,8 +46,10 @@ #define VTD_SID_TO_DEVFN(sid) ((sid) & 0xff) #define DMAR_REG_SIZE 0x230 -#define VTD_HOST_ADDRESS_WIDTH 39 -#define VTD_HAW_MASK ((1ULL << VTD_HOST_ADDRESS_WIDTH) - 1) +#define VTD_HOST_AW_39BIT 39 +#define VTD_HOST_AW_48BIT 48 +#define VTD_HOST_ADDRESS_WIDTH VTD_HOST_AW_39BIT +#define VTD_HAW_MASK(aw) ((1ULL << (aw)) - 1) #define DMAR_REPORT_F_INTR (1) From patchwork Tue Jun 19 01:42:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 931336 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="l9do17xJ"; 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 418tJW4SHzz9s0W for ; Tue, 19 Jun 2018 13:10:51 +1000 (AEST) Received: from localhost ([::1]:38922 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV72f-0001sA-4n for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 23:10:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47316) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5jx-0003OE-BN for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:47:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5jv-00010M-BH for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:47:25 -0400 Received: from mail-oi0-x243.google.com ([2607:f8b0:4003:c06::243]:37849) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5jv-00010C-3R; Mon, 18 Jun 2018 21:47:23 -0400 Received: by mail-oi0-x243.google.com with SMTP id l22-v6so16719548oib.4; Mon, 18 Jun 2018 18:47:22 -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=UADYDtq7kGIiibYQQ/MB3VdCuAvXraOlrBDx8WGQkY0=; b=l9do17xJYNEg4zoh3L+p6AwohdPlnw1BCWi2cqydj6lj5iIQnGfkrQNROMA7xl21OJ +A5cIahdRO/h/QS9eu1CdjJh6xeOu7YNh+Y9h/afo1cz2r08EVUC9sWuJCvOWpV2wyQe PC9zpAqnF0Tj6wP1irvSLHGcVMwV445IMppRTRcT6NMKkie1KABpIquPCaBOzngg71O9 Bn45kzO3B7/CRHstUPlnOv+fBff4SAumh1+kbS4/ypK5O97vsb1yYiel1qhVtWlGoB2B 77TKFUm+Yw4ECCs2+J9GfFHMi7RdC6rNO5s1hkacB3f9puCCbEcefBf+uHK+DIizwvIM SBWA== 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=UADYDtq7kGIiibYQQ/MB3VdCuAvXraOlrBDx8WGQkY0=; b=bpjyAP6nOhYDwpAEBhdDmeodIaa4bqO0QKfj9fuTdxVHLUdXtXBpvU036FFCoboUFu AT5PRkBw1i+QkFFelq/crzbpMJcTxJNmaViwyD6lxcM+AgBZA6/Funjqi3u1B28GztjR MpYTWLbDmK+LqarNaBWch668irZJWgedhA4t8QsetsJI1b1XAQ3Sg3hF0+WuRBkbha/7 ttbyO4hAde6+nQ+tGpF6zJurcdySQpqtCDpQjbtbbcCSDy3/pEpJY1IvcSGv3qSsAwEZ SxLSkNP9O/hYkgW/9xrqSa8ImUG0IbbOyO5TeHiqp97h/WVlJb+CtcfylNPeKjQxmERs IlgQ== X-Gm-Message-State: APt69E1Irl+2g9jkfeJAebbpQW7yApwdLNsEb/0r66N4F1vBKsz+Ihvb TUdDJZBzLkmbCMJkcTVXWxG4fdOH8HA= X-Google-Smtp-Source: ADUXVKL8W/mktiAfDhmdFzt8kySrmvNsyloSgAm3/6UA5MK3EfE1YZGmrwb1k2+WrN65f/hVAoWoEg== X-Received: by 2002:aca:3845:: with SMTP id f66-v6mr7800795oia.195.1529372841807; Mon, 18 Jun 2018 18:47:21 -0700 (PDT) Received: from localhost ([2600:1700:70:e488:b0ee:9bda:ee6f:91be]) by smtp.gmail.com with ESMTPSA id z96-v6sm7903841ota.28.2018.06.18.18.47.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:47:20 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:53 -0500 Message-Id: <20180619014319.28272-88-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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 087/113] intel-iommu: Extend address width to 48 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: "Michael S . Tsirkin" , qemu-stable@nongnu.org, Prasad Singamsetty , Prasad Singamsetty Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Prasad Singamsetty The current implementation of Intel IOMMU code only supports 39 bits iova address width. This patch provides a new parameter (x-aw-bits) for intel-iommu to extend its address width to 48 bits but keeping the default the same (39 bits). The reason for not changing the default is to avoid potential compatibility problems with live migration of intel-iommu enabled QEMU guest. The only valid values for 'x-aw-bits' parameter are 39 and 48. After enabling larger address width (48), we should be able to map larger iova addresses in the guest. For example, a QEMU guest that is configured with large memory ( >=1TB ). To check whether 48 bits aw is enabled, we can grep in the guest dmesg output with line: "DMAR: Host address width 48". Signed-off-by: Prasad Singamsetty Reviewed-by: Peter Xu Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin (cherry picked from commit 37f51384ae05bd50f83308339dbffa3e78404874) Signed-off-by: Michael Roth --- hw/i386/acpi-build.c | 3 +- hw/i386/intel_iommu.c | 101 ++++++++++++++++++++++++----------------- hw/i386/intel_iommu_internal.h | 9 ++-- include/hw/i386/intel_iommu.h | 1 + 4 files changed, 65 insertions(+), 49 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 73519ab3ac..537957c89a 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -2460,6 +2460,7 @@ build_dmar_q35(GArray *table_data, BIOSLinker *linker) AcpiDmarDeviceScope *scope = NULL; /* Root complex IOAPIC use one path[0] only */ size_t ioapic_scope_size = sizeof(*scope) + sizeof(scope->path[0]); + IntelIOMMUState *intel_iommu = INTEL_IOMMU_DEVICE(iommu); assert(iommu); if (iommu->intr_supported) { @@ -2467,7 +2468,7 @@ build_dmar_q35(GArray *table_data, BIOSLinker *linker) } dmar = acpi_data_push(table_data, sizeof(*dmar)); - dmar->host_address_width = VTD_HOST_ADDRESS_WIDTH - 1; + dmar->host_address_width = intel_iommu->aw_bits - 1; dmar->flags = dmar_flags; /* DMAR Remapping Hardware Unit Definition structure */ diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 53b3bf244d..c2380fdfdc 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -521,9 +521,9 @@ static inline dma_addr_t vtd_ce_get_slpt_base(VTDContextEntry *ce) return ce->lo & VTD_CONTEXT_ENTRY_SLPTPTR; } -static inline uint64_t vtd_get_slpte_addr(uint64_t slpte) +static inline uint64_t vtd_get_slpte_addr(uint64_t slpte, uint8_t aw) { - return slpte & VTD_SL_PT_BASE_ADDR_MASK(VTD_HOST_ADDRESS_WIDTH); + return slpte & VTD_SL_PT_BASE_ADDR_MASK(aw); } /* Whether the pte indicates the address of the page frame */ @@ -608,20 +608,21 @@ static inline bool vtd_ce_type_check(X86IOMMUState *x86_iommu, return true; } -static inline uint64_t vtd_iova_limit(VTDContextEntry *ce) +static inline uint64_t vtd_iova_limit(VTDContextEntry *ce, uint8_t aw) { uint32_t ce_agaw = vtd_ce_get_agaw(ce); - return 1ULL << MIN(ce_agaw, VTD_MGAW); + return 1ULL << MIN(ce_agaw, aw); } /* Return true if IOVA passes range check, otherwise false. */ -static inline bool vtd_iova_range_check(uint64_t iova, VTDContextEntry *ce) +static inline bool vtd_iova_range_check(uint64_t iova, VTDContextEntry *ce, + uint8_t aw) { /* * Check if @iova is above 2^X-1, where X is the minimum of MGAW * in CAP_REG and AW in context-entry. */ - return !(iova & ~(vtd_iova_limit(ce) - 1)); + return !(iova & ~(vtd_iova_limit(ce, aw) - 1)); } /* @@ -669,7 +670,7 @@ static VTDBus *vtd_find_as_from_bus_num(IntelIOMMUState *s, uint8_t bus_num) */ static int vtd_iova_to_slpte(VTDContextEntry *ce, uint64_t iova, bool is_write, uint64_t *slptep, uint32_t *slpte_level, - bool *reads, bool *writes) + bool *reads, bool *writes, uint8_t aw_bits) { dma_addr_t addr = vtd_ce_get_slpt_base(ce); uint32_t level = vtd_ce_get_level(ce); @@ -677,7 +678,7 @@ static int vtd_iova_to_slpte(VTDContextEntry *ce, uint64_t iova, bool is_write, uint64_t slpte; uint64_t access_right_check; - if (!vtd_iova_range_check(iova, ce)) { + if (!vtd_iova_range_check(iova, ce, aw_bits)) { trace_vtd_err_dmar_iova_overflow(iova); return -VTD_FR_ADDR_BEYOND_MGAW; } @@ -714,7 +715,7 @@ static int vtd_iova_to_slpte(VTDContextEntry *ce, uint64_t iova, bool is_write, *slpte_level = level; return 0; } - addr = vtd_get_slpte_addr(slpte); + addr = vtd_get_slpte_addr(slpte, aw_bits); level--; } } @@ -732,11 +733,12 @@ typedef int (*vtd_page_walk_hook)(IOMMUTLBEntry *entry, void *private); * @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 */ 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) + void *private, uint32_t level, bool read, + bool write, bool notify_unmap, uint8_t aw) { bool read_cur, write_cur, entry_valid; uint32_t offset; @@ -783,7 +785,7 @@ static int vtd_page_walk_level(dma_addr_t addr, uint64_t start, 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); + 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) { @@ -803,10 +805,10 @@ 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_level(vtd_get_slpte_addr(slpte), iova, + 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); + notify_unmap, aw); if (ret < 0) { return ret; } @@ -827,25 +829,26 @@ next: * @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 */ static int vtd_page_walk(VTDContextEntry *ce, uint64_t start, uint64_t end, vtd_page_walk_hook hook_fn, void *private, - bool notify_unmap) + bool notify_unmap, uint8_t aw) { 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)) { + if (!vtd_iova_range_check(start, ce, aw)) { return -VTD_FR_ADDR_BEYOND_MGAW; } - if (!vtd_iova_range_check(end, ce)) { + if (!vtd_iova_range_check(end, ce, aw)) { /* Fix end so that it reaches the maximum */ - end = vtd_iova_limit(ce); + end = vtd_iova_limit(ce, aw); } return vtd_page_walk_level(addr, start, end, hook_fn, private, - level, true, true, notify_unmap); + level, true, true, notify_unmap, aw); } /* Map a device to its corresponding domain (context-entry) */ @@ -867,7 +870,7 @@ static int vtd_dev_to_context_entry(IntelIOMMUState *s, uint8_t bus_num, return -VTD_FR_ROOT_ENTRY_P; } - if (re.rsvd || (re.val & VTD_ROOT_ENTRY_RSVD(VTD_HOST_ADDRESS_WIDTH))) { + if (re.rsvd || (re.val & VTD_ROOT_ENTRY_RSVD(s->aw_bits))) { trace_vtd_re_invalid(re.rsvd, re.val); return -VTD_FR_ROOT_ENTRY_RSVD; } @@ -884,7 +887,7 @@ static int vtd_dev_to_context_entry(IntelIOMMUState *s, uint8_t bus_num, } if ((ce->hi & VTD_CONTEXT_ENTRY_RSVD_HI) || - (ce->lo & VTD_CONTEXT_ENTRY_RSVD_LO(VTD_HOST_ADDRESS_WIDTH))) { + (ce->lo & VTD_CONTEXT_ENTRY_RSVD_LO(s->aw_bits))) { trace_vtd_ce_invalid(ce->hi, ce->lo); return -VTD_FR_CONTEXT_ENTRY_RSVD; } @@ -1166,7 +1169,7 @@ static bool vtd_do_iommu_translate(VTDAddressSpace *vtd_as, PCIBus *bus, } ret_fr = vtd_iova_to_slpte(&ce, addr, is_write, &slpte, &level, - &reads, &writes); + &reads, &writes, s->aw_bits); if (ret_fr) { ret_fr = -ret_fr; if (is_fpd_set && vtd_is_qualified_fault(ret_fr)) { @@ -1183,7 +1186,7 @@ static bool vtd_do_iommu_translate(VTDAddressSpace *vtd_as, PCIBus *bus, access_flags, level); out: entry->iova = addr & page_mask; - entry->translated_addr = vtd_get_slpte_addr(slpte) & page_mask; + entry->translated_addr = vtd_get_slpte_addr(slpte, s->aw_bits) & page_mask; entry->addr_mask = ~page_mask; entry->perm = access_flags; return true; @@ -1200,7 +1203,7 @@ static void vtd_root_table_setup(IntelIOMMUState *s) { s->root = vtd_get_quad_raw(s, DMAR_RTADDR_REG); s->root_extended = s->root & VTD_RTADDR_RTT; - s->root &= VTD_RTADDR_ADDR_MASK(VTD_HOST_ADDRESS_WIDTH); + s->root &= VTD_RTADDR_ADDR_MASK(s->aw_bits); trace_vtd_reg_dmar_root(s->root, s->root_extended); } @@ -1216,7 +1219,7 @@ static void vtd_interrupt_remap_table_setup(IntelIOMMUState *s) uint64_t value = 0; value = vtd_get_quad_raw(s, DMAR_IRTA_REG); s->intr_size = 1UL << ((value & VTD_IRTA_SIZE_MASK) + 1); - s->intr_root = value & VTD_IRTA_ADDR_MASK(VTD_HOST_ADDRESS_WIDTH); + s->intr_root = value & VTD_IRTA_ADDR_MASK(s->aw_bits); s->intr_eime = value & VTD_IRTA_EIME; /* Notify global invalidation */ @@ -1392,7 +1395,7 @@ static void vtd_iotlb_page_invalidate_notify(IntelIOMMUState *s, 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); + (void *)&vtd_as->iommu, true, s->aw_bits); } } } @@ -1472,7 +1475,7 @@ static void vtd_handle_gcmd_qie(IntelIOMMUState *s, bool en) trace_vtd_inv_qi_enable(en); if (en) { - s->iq = iqa_val & VTD_IQA_IQA_MASK(VTD_HOST_ADDRESS_WIDTH); + s->iq = iqa_val & VTD_IQA_IQA_MASK(s->aw_bits); /* 2^(x+8) entries */ s->iq_size = 1UL << ((iqa_val & VTD_IQA_QS) + 8); s->qi_enabled = true; @@ -2403,6 +2406,8 @@ static Property vtd_properties[] = { DEFINE_PROP_ON_OFF_AUTO("eim", IntelIOMMUState, intr_eim, ON_OFF_AUTO_AUTO), DEFINE_PROP_BOOL("x-buggy-eim", IntelIOMMUState, buggy_eim, false), + DEFINE_PROP_UINT8("x-aw-bits", IntelIOMMUState, aw_bits, + VTD_HOST_ADDRESS_WIDTH), DEFINE_PROP_BOOL("caching-mode", IntelIOMMUState, caching_mode, FALSE), DEFINE_PROP_END_OF_LIST(), }; @@ -2758,6 +2763,7 @@ static void vtd_address_space_unmap(VTDAddressSpace *as, IOMMUNotifier *n) hwaddr size; hwaddr start = n->start; hwaddr end = n->end; + IntelIOMMUState *s = as->iommu_state; /* * Note: all the codes in this function has a assumption that IOVA @@ -2765,12 +2771,12 @@ static void vtd_address_space_unmap(VTDAddressSpace *as, IOMMUNotifier *n) * VT-d spec), otherwise we need to consider overflow of 64 bits. */ - if (end > VTD_ADDRESS_SIZE(VTD_HOST_ADDRESS_WIDTH)) { + if (end > VTD_ADDRESS_SIZE(s->aw_bits)) { /* * Don't need to unmap regions that is bigger than the whole * VT-d supported address space size */ - end = VTD_ADDRESS_SIZE(VTD_HOST_ADDRESS_WIDTH); + end = VTD_ADDRESS_SIZE(s->aw_bits); } assert(start <= end); @@ -2782,9 +2788,9 @@ static void vtd_address_space_unmap(VTDAddressSpace *as, IOMMUNotifier *n) * suite the minimum available mask. */ int n = 64 - clz64(size); - if (n > VTD_MGAW) { + if (n > s->aw_bits) { /* should not happen, but in case it happens, limit it */ - n = VTD_MGAW; + n = s->aw_bits; } size = 1ULL << n; } @@ -2844,7 +2850,8 @@ 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); + 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)); @@ -2859,7 +2866,6 @@ static void vtd_iommu_replay(IOMMUMemoryRegion *iommu_mr, IOMMUNotifier *n) static void vtd_init(IntelIOMMUState *s) { X86IOMMUState *x86_iommu = X86_IOMMU_DEVICE(s); - uint8_t aw_bits = VTD_HOST_ADDRESS_WIDTH; memset(s->csr, 0, DMAR_REG_SIZE); memset(s->wmask, 0, DMAR_REG_SIZE); @@ -2878,21 +2884,24 @@ static void vtd_init(IntelIOMMUState *s) s->next_frcd_reg = 0; s->cap = VTD_CAP_FRO | VTD_CAP_NFR | VTD_CAP_ND | VTD_CAP_MAMV | VTD_CAP_PSI | VTD_CAP_SLLPS | - VTD_CAP_SAGAW_39bit | VTD_CAP_MGAW(VTD_HOST_ADDRESS_WIDTH); + VTD_CAP_SAGAW_39bit | VTD_CAP_MGAW(s->aw_bits); + if (s->aw_bits == VTD_HOST_AW_48BIT) { + s->cap |= VTD_CAP_SAGAW_48bit; + } s->ecap = VTD_ECAP_QI | VTD_ECAP_IRO; /* * Rsvd field masks for spte */ vtd_paging_entry_rsvd_field[0] = ~0ULL; - vtd_paging_entry_rsvd_field[1] = VTD_SPTE_PAGE_L1_RSVD_MASK(aw_bits); - vtd_paging_entry_rsvd_field[2] = VTD_SPTE_PAGE_L2_RSVD_MASK(aw_bits); - vtd_paging_entry_rsvd_field[3] = VTD_SPTE_PAGE_L3_RSVD_MASK(aw_bits); - vtd_paging_entry_rsvd_field[4] = VTD_SPTE_PAGE_L4_RSVD_MASK(aw_bits); - vtd_paging_entry_rsvd_field[5] = VTD_SPTE_LPAGE_L1_RSVD_MASK(aw_bits); - vtd_paging_entry_rsvd_field[6] = VTD_SPTE_LPAGE_L2_RSVD_MASK(aw_bits); - vtd_paging_entry_rsvd_field[7] = VTD_SPTE_LPAGE_L3_RSVD_MASK(aw_bits); - vtd_paging_entry_rsvd_field[8] = VTD_SPTE_LPAGE_L4_RSVD_MASK(aw_bits); + vtd_paging_entry_rsvd_field[1] = VTD_SPTE_PAGE_L1_RSVD_MASK(s->aw_bits); + vtd_paging_entry_rsvd_field[2] = VTD_SPTE_PAGE_L2_RSVD_MASK(s->aw_bits); + vtd_paging_entry_rsvd_field[3] = VTD_SPTE_PAGE_L3_RSVD_MASK(s->aw_bits); + vtd_paging_entry_rsvd_field[4] = VTD_SPTE_PAGE_L4_RSVD_MASK(s->aw_bits); + vtd_paging_entry_rsvd_field[5] = VTD_SPTE_LPAGE_L1_RSVD_MASK(s->aw_bits); + vtd_paging_entry_rsvd_field[6] = VTD_SPTE_LPAGE_L2_RSVD_MASK(s->aw_bits); + vtd_paging_entry_rsvd_field[7] = VTD_SPTE_LPAGE_L3_RSVD_MASK(s->aw_bits); + vtd_paging_entry_rsvd_field[8] = VTD_SPTE_LPAGE_L4_RSVD_MASK(s->aw_bits); if (x86_iommu->intr_supported) { s->ecap |= VTD_ECAP_IR | VTD_ECAP_MHMV; @@ -3029,6 +3038,14 @@ static bool vtd_decide_config(IntelIOMMUState *s, Error **errp) } } + /* Currently only address widths supported are 39 and 48 bits */ + if ((s->aw_bits != VTD_HOST_AW_39BIT) && + (s->aw_bits != VTD_HOST_AW_48BIT)) { + error_setg(errp, "Supported values for x-aw-bits are: %d, %d", + VTD_HOST_AW_39BIT, VTD_HOST_AW_48BIT); + return false; + } + return true; } diff --git a/hw/i386/intel_iommu_internal.h b/hw/i386/intel_iommu_internal.h index 77e4a9833a..d084099ed9 100644 --- a/hw/i386/intel_iommu_internal.h +++ b/hw/i386/intel_iommu_internal.h @@ -131,7 +131,7 @@ #define VTD_TLB_DID(val) (((val) >> 32) & VTD_DOMAIN_ID_MASK) /* IVA_REG */ -#define VTD_IVA_ADDR(val) ((val) & ~0xfffULL & ((1ULL << VTD_MGAW) - 1)) +#define VTD_IVA_ADDR(val) ((val) & ~0xfffULL) #define VTD_IVA_AM(val) ((val) & 0x3fULL) /* GCMD_REG */ @@ -197,7 +197,6 @@ #define VTD_DOMAIN_ID_SHIFT 16 /* 16-bit domain id for 64K domains */ #define VTD_DOMAIN_ID_MASK ((1UL << VTD_DOMAIN_ID_SHIFT) - 1) #define VTD_CAP_ND (((VTD_DOMAIN_ID_SHIFT - 4) / 2) & 7ULL) -#define VTD_MGAW 39 /* Maximum Guest Address Width */ #define VTD_ADDRESS_SIZE(aw) (1ULL << (aw)) #define VTD_CAP_MGAW(aw) ((((aw) - 1) & 0x3fULL) << 16) #define VTD_MAMV 18ULL @@ -213,7 +212,6 @@ #define VTD_CAP_SAGAW_39bit (0x2ULL << VTD_CAP_SAGAW_SHIFT) /* 48-bit AGAW, 4-level page-table */ #define VTD_CAP_SAGAW_48bit (0x4ULL << VTD_CAP_SAGAW_SHIFT) -#define VTD_CAP_SAGAW VTD_CAP_SAGAW_39bit /* IQT_REG */ #define VTD_IQT_QT(val) (((val) >> 4) & 0x7fffULL) @@ -252,7 +250,7 @@ #define VTD_FRCD_SID_MASK 0xffffULL #define VTD_FRCD_SID(val) ((val) & VTD_FRCD_SID_MASK) /* For the low 64-bit of 128-bit */ -#define VTD_FRCD_FI(val) ((val) & (((1ULL << VTD_MGAW) - 1) ^ 0xfffULL)) +#define VTD_FRCD_FI(val) ((val) & ~0xfffULL) /* DMA Remapping Fault Conditions */ typedef enum VTDFaultReason { @@ -360,8 +358,7 @@ typedef union VTDInvDesc VTDInvDesc; #define VTD_INV_DESC_IOTLB_DOMAIN (2ULL << 4) #define VTD_INV_DESC_IOTLB_PAGE (3ULL << 4) #define VTD_INV_DESC_IOTLB_DID(val) (((val) >> 16) & VTD_DOMAIN_ID_MASK) -#define VTD_INV_DESC_IOTLB_ADDR(val) ((val) & ~0xfffULL & \ - ((1ULL << VTD_MGAW) - 1)) +#define VTD_INV_DESC_IOTLB_ADDR(val) ((val) & ~0xfffULL) #define VTD_INV_DESC_IOTLB_AM(val) ((val) & 0x3fULL) #define VTD_INV_DESC_IOTLB_RSVD_LO 0xffffffff0000ff00ULL #define VTD_INV_DESC_IOTLB_RSVD_HI 0xf80ULL diff --git a/include/hw/i386/intel_iommu.h b/include/hw/i386/intel_iommu.h index 372b06df45..45ec8919b6 100644 --- a/include/hw/i386/intel_iommu.h +++ b/include/hw/i386/intel_iommu.h @@ -304,6 +304,7 @@ struct IntelIOMMUState { bool intr_eime; /* Extended interrupt mode enabled */ 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) */ }; /* Find the VTD Address space associated with the given bus pointer, From patchwork Tue Jun 19 01:42: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: 931346 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="IUPP9Kx6"; 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 418tXC2WSyz9s3C for ; Tue, 19 Jun 2018 13:20:59 +1000 (AEST) Received: from localhost ([::1]:38986 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV7CT-0001lx-1b for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 23:20:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47333) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5jy-0003PD-Hr for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:47:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5jx-00010k-JO for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:47:26 -0400 Received: from mail-oi0-x22b.google.com ([2607:f8b0:4003:c06::22b]:34778) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5jx-00010W-Cq; Mon, 18 Jun 2018 21:47:25 -0400 Received: by mail-oi0-x22b.google.com with SMTP id i205-v6so16714865oib.1; Mon, 18 Jun 2018 18:47: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=h9G3h1FmXwDukYPpBzUZLuobO1OzToK+3o1qqQPr5HY=; b=IUPP9Kx6p1hie5iyLYnfqpiPgKUBzFpjkqYtmxJe6UVKPnsRwKINAnZgtyVg0ilAGg WvviIFPtVdIBrh/t7ZQfjea1UbIwifTXpAXKhstM3yntnTokzgBMF2kSqaqI5bTetNkr QbERwCqKnp97bgMZyR9FwsPUiymmuNbyfUqHwPVE/tZBfFMJxP2wPu9bnzBnEQdXV+Xh +dnettN1+burPqJYQlsA47lSgUOWLj9Dzpy9wPTK1seMuDeYnekMnKaqjzyIIWugMsvY PIqXj5dapsZTRX9E5l6GjnGfL2gjK8gx9eG7Kk4VDtjWh0X32/iCmj7OaL3GWKLXNQTi F1kA== 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=h9G3h1FmXwDukYPpBzUZLuobO1OzToK+3o1qqQPr5HY=; b=VpAaUK6IFES3BjWjFxf08UfHm7IZoWhgsS/QdPgy9jYSekW8O47TYchNvwP9b1nwbX 4j46plXVIJkvVg6aYJBzpQhnDVgtkSHNygY0vyr+gX3pwmzYiCZUfmg/zrBhTdqded60 hU/srjCMzqr1/UjL5Y3umTH9VB8u4e/PtrLvplWM015FKxS26ejAKVX06OreJNsaGsVZ F+e7Sd/m6HxPZ13bRbzlAov93AlWJEY68sF98hi6DTvk7ALMxcOiLMFUDVL/sln+R2RH aPxcWGi0uo1cF4hT6PoYbQJ/Caef0KZRlF+mUTS91+I42PFtna0ghW/Tv2eYe5cD3OUX OcMw== X-Gm-Message-State: APt69E1k2aNDiefeBoyBspyfNnbARiaHlluodHNsPfObEdl/KwvoEgB3 z8yqtWz04T9KPpXagN50xECd9WoMu0k= X-Google-Smtp-Source: ADUXVKIxbxPxQFY5RuMsgkpEIu7Uqm2U1Rk8GpaGApuwn9mrgsscKI0Z0MopKVkQeku1+n0ArukXyw== X-Received: by 2002:aca:7255:: with SMTP id p82-v6mr9011519oic.256.1529372843996; Mon, 18 Jun 2018 18:47:23 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id q23-v6sm10139611otd.25.2018.06.18.18.47.22 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:47:23 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:54 -0500 Message-Id: <20180619014319.28272-89-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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 088/113] 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 c2380fdfdc..a03ae403f8 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 Tue Jun 19 01:42: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: 931350 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="aOjIuHwf"; 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 418tfT1kkmz9s0W for ; Tue, 19 Jun 2018 13:26:25 +1000 (AEST) Received: from localhost ([::1]:39027 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV7Hi-0006Gw-UP for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 23:26:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47365) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5k0-0003RU-T6 for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:47:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5jz-00012T-L3 for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:47:28 -0400 Received: from mail-oi0-x243.google.com ([2607:f8b0:4003:c06::243]:38269) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5jz-00011y-En; Mon, 18 Jun 2018 21:47:27 -0400 Received: by mail-oi0-x243.google.com with SMTP id d5-v6so16700871oib.5; Mon, 18 Jun 2018 18:47:27 -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=BX/en5SQfrTS2Q6D0dB05oj3luSDARbQlqnr9YhSCSM=; b=aOjIuHwfVrJ4N5Fa6RsTdyw6xn4YV5R0Jb8iSmMAgrPuyI2S9m+dwW2JlpHRjsSWXZ Vzln1yHaBydbhZHSJldb5WHzdql+WOOElG8duR/px1bCGjxcWYC7ji9cauembpGsfFsk BDaUs5Rtn07jSXxZ76VcCrr+UQuDRbnru8cJbD1nNm1NYwgt+v4OWZufMgT8RXZzXphP k38dVczjG8IMLX3c/AFaGHxUTH7u4LCJYEYfeFrdzxUvGRZh+HYJcENwf9oFGndEM405 a/UFTH32VUKHTZuQQwMVFuxKVG87YJOIuEsofOXxs0QJFfDmTFHhudYKXXWUYUUTPSI9 2PGQ== 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=BX/en5SQfrTS2Q6D0dB05oj3luSDARbQlqnr9YhSCSM=; b=UTssPoqFp0MzRMURVqqCjyt0NqQtQF0qqBk6DP04LB6sqn9lbn12xEYU2tsNz4hgHX DR63wUHElTfnKKst4uAGcX8s1MCreGPzvSlBRLZBCvsGAjONs7kuNE1WmJoBgdX8A20x DfLQku4ktiAAoMa0ON6ucsa+5W/154ybwAMUqNIkLRE91mCaUXRp+ZBEV8b2sZQfRdaW gFi9UicT5NmwwWedZ0j3IfOmAF5dV2yuc6P97YtT7uLN/eEtSIiFrqRCo/ImXSxfy+J+ OpjjiubUYdm5kNWmmUwFWUXds/C2k4fZBZ/fup8ji9YF8myyX98hmyVmZCvPE7z/TNvV z3mg== X-Gm-Message-State: APt69E2T0yzInu/nAuI6D/aFx9lyFyv4+SrtEBrFxT3SKRqpS17qpHQJ OTX/kfXnK5fHuNZDgiSa8IA4/4Jq6W8= X-Google-Smtp-Source: ADUXVKKwDqn4cfNckULxWr6RZ/EVMx6NqfXblB06VXCItmEw/J6KAPdqXdnl0NXnQkoww8G5UkDp2w== X-Received: by 2002:aca:c445:: with SMTP id u66-v6mr7818534oif.333.1529372846239; Mon, 18 Jun 2018 18:47:26 -0700 (PDT) Received: from localhost ([2600:1700:70:e488:b0ee:9bda:ee6f:91be]) by smtp.gmail.com with ESMTPSA id q45-v6sm8237210otg.56.2018.06.18.18.47.24 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:47:25 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:55 -0500 Message-Id: <20180619014319.28272-90-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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 089/113] 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 a03ae403f8..be2f445758 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)) { @@ -2337,8 +2334,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 cache_mode=1 for intel-iommu to enable " @@ -2347,21 +2342,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); } } @@ -2831,12 +2814,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); } @@ -3090,7 +3071,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 Tue Jun 19 01:42: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: 931349 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="AyDHItWd"; 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 418tbJ0qc8z9s19 for ; Tue, 19 Jun 2018 13:23:40 +1000 (AEST) Received: from localhost ([::1]:39005 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV7F3-0003sw-OW for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 23:23:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47403) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5k3-0003Tx-CA for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:47:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5k1-00014c-QQ for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:47:31 -0400 Received: from mail-ot0-x241.google.com ([2607:f8b0:4003:c0f::241]:34696) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5k1-000147-Jg; Mon, 18 Jun 2018 21:47:29 -0400 Received: by mail-ot0-x241.google.com with SMTP id r18-v6so20785737otk.1; Mon, 18 Jun 2018 18:47:29 -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=wb/TkEmmfEqx+fAb7J2Y8VjV15vjvUEUWE0q9bNizKA=; b=AyDHItWdGDagHlPKlG1VVhm0f3m9MxkFYHZMbdlnF8JEd8/idXfVHxQH2h2ZhM0YhF Cz2pLKgaELrA/4e2Iqmj/W3W8GHp5Ujfujj8jQn2TRUyqj6A5ZWWhOFa5poZ+NPzAIGj f9BFOCSED53iGrQ/Zr5h0jUm7knFMrxs8B4KNiUcrl1qk/WHupc++itWnGNR3a1bVfO/ cUdf7tfUnXIyMaB/jeuh3AO14ovZv9AV9pC6qFZjbLOVW5mV1ANUuMXugXLLEBfAWeEs Ru9kGtAotkOWPAPEYXVj9VerXUhWzqbLtZQCPD0w8HKxdcRd3WSdBAlBv7pT6lQFQXDV S+Ww== 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=wb/TkEmmfEqx+fAb7J2Y8VjV15vjvUEUWE0q9bNizKA=; b=KbhT3Jrh+wuYsRr0vGmaLxm645+ejtNc4j4ogXUKj9IFU766o/qrL6QBE/Ca1WTlLJ 7Ewy1lF1wFeww9SrgDn7SbKqeitA59z6HXU2dxb3NtygHoo8dAXIxvaqs42tZYLSoGk2 z/G+lGfaSq03A7TlFSzx4zaIP5396EcbNxWaKkDHnhGQ8u4y52oyOxz4mnyfg4yOqhxG rwtMfH7eq1Y7Yz5InFrXL5Hqphhy74ReomBvPQV+YraRwHAewShnVwf90cI3DZ2WyjyA OHHVJ25OmjuoeJyxAng6QOI5SpA7DOYkjuLpjyt+cRmP+/P1AsGNy5TvYUFhfj1qMvlT H6rA== X-Gm-Message-State: APt69E1cdek+hri27TBCJhhnosFrRrTAc0eDDW+mAbas1rCvDOhBnj1z NsD9Lw8RZQ3tjK6kAbmDhmetfREaZeY= X-Google-Smtp-Source: ADUXVKJnUpoK6ttPii8IiO/kr8T0jx2tRO5xXl+L6KQWcwyNGKw8i5gzIp+jWd9Ww643p+Z3RC2PjA== X-Received: by 2002:a9d:1f23:: with SMTP id x32-v6mr8757556otd.201.1529372848422; Mon, 18 Jun 2018 18:47:28 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id q23-v6sm10139788otd.25.2018.06.18.18.47.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:47:27 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:56 -0500 Message-Id: <20180619014319.28272-91-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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:c0f::241 Subject: [Qemu-devel] [PATCH 090/113] 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 be2f445758..cfcd1046e7 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); } @@ -2922,8 +2957,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); @@ -3072,6 +3109,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 Tue Jun 19 01:42: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: 931303 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="bWDVsFB6"; 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 418sj635XKz9s47 for ; Tue, 19 Jun 2018 12:43:38 +1000 (AEST) Received: from localhost ([::1]:38721 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6cK-0004TS-0Y for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:43:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47467) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5kA-0003Xc-6e for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:47:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5k6-00017e-0q for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:47:38 -0400 Received: from mail-ot0-x235.google.com ([2607:f8b0:4003:c0f::235]:43694) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5k5-00017X-R8; Mon, 18 Jun 2018 21:47:33 -0400 Received: by mail-ot0-x235.google.com with SMTP id i19-v6so20746778otk.10; Mon, 18 Jun 2018 18:47:33 -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=sp9Sqki9GKa8t8Wt70Tlcg1DoFD1V2Zut69xGlLPTJA=; b=bWDVsFB6v2c5+z97094FyK/BktJRVE20NP+UFPWrqlJhukhPUgdHswwdN6dBeQhiz7 x0djwtwj5VeeA+tUpbQuvrG9bv9tOOnTmfhGMfMH9QXQuPKvQEk6gjy5GlYuc0LSrb1b smlLujtz81ToxGfXYO99bBghGncKMcJxZM0vYFBZZJ/0brOfX4IuFZwTNE5s5YKA+ztE SQdQ2zKOnaZxkDc0wUhfh0UgeqlppcwcoQQDacZy2UQFYa+cTTLvYbnm+pwOFCgJNV8P PKRtNnqhry2u0scyJRrQtuOPzjpT7V3qewnn3cvY1UbJQk6PEu3rpgj8ts3bUG0jhO1h bIBw== 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=sp9Sqki9GKa8t8Wt70Tlcg1DoFD1V2Zut69xGlLPTJA=; b=BwRx5kEfcmaLxHeRv2R/VhBOa3V9NvOwEoY6D3+OPA+XWIdt37iSSZws52PxXmjGo1 jU+Ib201Dw24CDniZzG5vfAvewQvk5SLAr8nIeh0KkAulIrl1gVcbUKUgTWK1yxZ5ef8 oi6PjZcZ2VjrejO9Xtx6YY9rmlyhSUpKyMQzCuvkbCSuOGhdsUscStzTbjKnDffWZcRj uhzn22ZGneq5IN2KJd/bWJrnm+dGpEhMnLo1FemOZ1p/25BRsktFsyL8BJK5vVmoAPp3 13naNP9xn6O5glwrJVYlH5AD1cPqEl221iq4aolsQksST5ebC2xo8NjI6BGG3rLZ84zx P82w== X-Gm-Message-State: APt69E1NIwmOrF9IJdnPiJapI0HiC9updelj58n1EL7awFfjoIX9n6VW dhrECHci57dK1imYRXIATC4LHZzvIGk= X-Google-Smtp-Source: ADUXVKLspbWrt1X/rBaYF88EoCfDGBtEfiLpqRKlSGW+n6gfhe4UZECppTixLvk14RrV0pd7PRRBLg== X-Received: by 2002:a9d:5616:: with SMTP id e22-v6mr10019881oti.192.1529372852615; Mon, 18 Jun 2018 18:47:32 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id f53-v6sm11185801otd.80.2018.06.18.18.47.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:47:31 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:57 -0500 Message-Id: <20180619014319.28272-92-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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:c0f::235 Subject: [Qemu-devel] [PATCH 091/113] 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 cfcd1046e7..3715fa327b 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); + } } } } @@ -2376,6 +2404,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) { @@ -2884,8 +2915,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 Tue Jun 19 01:42: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: 931310 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="NmjdhFWI"; 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 418srj48xSz9s1R for ; Tue, 19 Jun 2018 12:50:13 +1000 (AEST) Received: from localhost ([::1]:38757 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6ih-0001IN-5y for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:50:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47465) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5kA-0003Xa-6N for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:47:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5k8-000184-64 for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:47:38 -0400 Received: from mail-oi0-x22d.google.com ([2607:f8b0:4003:c06::22d]:32792) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5k7-00017x-Vb; Mon, 18 Jun 2018 21:47:36 -0400 Received: by mail-oi0-x22d.google.com with SMTP id c6-v6so16702939oiy.0; Mon, 18 Jun 2018 18:47: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; bh=RW8WUqC+0tSP59/140BG9XPqLyfx4dq5WVNsscSVHSc=; b=NmjdhFWI2DWNVAzOgZaMDJQSUmHMyLhrGVJWMF1s29wNfVnQ17aZolHeWTk8AYbGOL w+itKYtrhPIHDrPRlmys5fyBNRWINDzYswAoA/AsuH2O2iB/hREJdBe++kNIL7l7Jd6C tJVQd4I97w/5woxbs0WwqOPf6PJtx9bSzBScopR3igIEmQ+Dsn/inTP5CCKg4q7DRHdr zR9qqvfv8bXl+HYVcndKgFWExrH9PbzNVDzNZq2FePfILagzW0mIU4CtKTRFMuybmOB2 N8iwpHgwaYju2uP4/uox68RJmN8mS9ZNomB8EUnWtDv+kxA2fLlCFkfvRN3RlQbAMo0I vP8Q== 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=RW8WUqC+0tSP59/140BG9XPqLyfx4dq5WVNsscSVHSc=; b=tUtNXz5DzqU7pHoz1P+d+UVj2RX+PYLnDMCcGfTjL1R7VFQ8SMTT9qRrOb5LBmQuR8 jENoUF7Xgv+P+F6jbTsTUfj3cTDKc/VW91cR/0XalUVH63ae1YZGJ6z2D4QWslTFZH+C OVKWrwIzQIz743iqU8pFVMqTYPxtelaS3N0MVs0Whj+7a10lQey3n3tTUx6qCKoKZkOT hvuUjVQ2rs5979+ODE5ahT3YSqBcblV6JwukMlYaFUu2c6NmDW2yx5JuMatzdvOvxl80 kj2IlSviHRviQSBz7JCRzgoCXI4R2kKYKgjglX5FSXymwMcdWRajmoEJ8vI6JzBpP5f/ VOwg== X-Gm-Message-State: APt69E03tPTelwugkXtqFcPd299bWf+KWpXiw/m9b5aglSy5qXXAi45X 9f6dl0Yx5d70Pkx3OxqVtNMCbx98kkk= X-Google-Smtp-Source: ADUXVKJBmHIwkACoSN7Fhq0/iaT3i7iluKQhq2ENlE+9V9XIyuoBBZ4k62MBTpw35iWMqwsLBgAVTw== X-Received: by 2002:aca:484d:: with SMTP id v74-v6mr7683226oia.354.1529372854729; Mon, 18 Jun 2018 18:47:34 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id w189-v6sm7475895oie.45.2018.06.18.18.47.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:47:33 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:58 -0500 Message-Id: <20180619014319.28272-93-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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 092/113] 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 3715fa327b..e059bfd577 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 @@ -2917,8 +2931,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 Tue Jun 19 01:42:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 931307 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="s0UN3N7y"; 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 418sn41pYRz9s1R for ; Tue, 19 Jun 2018 12:47:02 +1000 (AEST) Received: from localhost ([::1]:38746 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6fX-0007L0-Eq for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:46:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47475) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5kA-0003YL-Ql for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:47:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5kA-00018V-07 for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:47:38 -0400 Received: from mail-ot0-x22e.google.com ([2607:f8b0:4003:c0f::22e]:36941) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5k9-00018P-QI; Mon, 18 Jun 2018 21:47:37 -0400 Received: by mail-ot0-x22e.google.com with SMTP id 101-v6so20787234oth.4; Mon, 18 Jun 2018 18:47: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=CizezXkZkcHJLAIzIzZgJwklWBK12/+8H4jABND3+4o=; b=s0UN3N7ytt1Gv4NCTvm7GvnZEo70b8KxDIxSEyk0fYwIzG5mnqaHVYXMAvbef6nFqr BKnkgzNQkyKidLbLmPkjOSmj2HEEnEyUmkWzGpN43zbCv/VpkN7SaHFBU673MjLJp961 xWGMM7+dWOT4QbZo875z/ScWyHoJK+QM1NG7RWus+vNap1Rt2b3y+rPoHrWvH0hj48P2 iL/WwttO/4pX7fSwLW1FS8c9nkyJZHoVlcUopaYzS6hRAQolrU2LQmb4S53AcNFpIcbG jCswK3XH1bMtQ2LwgndmcM9gxlKgKAVFRxJyCVF+veADDYPlpa1jrsXF5JVxp9ILVrMl dk5A== 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=CizezXkZkcHJLAIzIzZgJwklWBK12/+8H4jABND3+4o=; b=LXpLW9PRSq159B/Tbsk8pf0Ma/iIKzwgN8r0bOxmwpo9YLn7OqOOj9Nfvj7SEm9C+R YYlYl428lP40iYqAItNCnU3gEYF6ZcyTAVWNdkH+FFyYYwXoLsAhAbh4Ium4lj3dqHFR E/rwHFqL0eIFlp9QndcepGOvA6NoShbrZqrpiHWSXok1bPihcGbhL9XboxIbwkXYUa1n MaEe1A8aJ6cQ3vrWTKerTHuvfWvpV0+80rEh8RHQYtr+sNmzJYZoIVIXTAMN0aubSz9G N21tXVyOi7rtoKNmSCi33dm/+JCz55mreSZWcWvG/hi1ZnXeu/R+F2N5NAHlUJ8DMBI+ S28Q== X-Gm-Message-State: APt69E3UDhp/xZGs9Zpd9/xqUgFdSQhareP5Z9e0kQvZ/uNTZiEmMd4H t/05h32RurGeJP2LeLQ9KzFg16/uG84= X-Google-Smtp-Source: ADUXVKJYMBi56uiXj72l0rHxdyrlfa3cZbQ7i8ydKjQo55uatTfxfs8RKCJn50tjadfCuv2m58ZKGw== X-Received: by 2002:a9d:2989:: with SMTP id n9-v6mr9758245otb.152.1529372856675; Mon, 18 Jun 2018 18:47:36 -0700 (PDT) Received: from localhost ([2600:1700:70:e488:b0ee:9bda:ee6f:91be]) by smtp.gmail.com with ESMTPSA id k19-v6sm10513006ote.0.2018.06.18.18.47.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:47:35 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:59 -0500 Message-Id: <20180619014319.28272-94-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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:c0f::22e Subject: [Qemu-devel] [PATCH 093/113] 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 e059bfd577..c7efeb5666 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, }; /* @@ -2936,6 +2939,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 Tue Jun 19 01:43:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 931353 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="EKIWZTFc"; 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 418tlg09XJz9s19 for ; Tue, 19 Jun 2018 13:30:55 +1000 (AEST) Received: from localhost ([::1]:39089 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV7M4-0001Jz-84 for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 23:30:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47531) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5kD-0003b1-Dc for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:47:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5kC-00019V-9n for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:47:41 -0400 Received: from mail-oi0-x231.google.com ([2607:f8b0:4003:c06::231]:36404) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5kC-00019F-3x; Mon, 18 Jun 2018 21:47:40 -0400 Received: by mail-oi0-x231.google.com with SMTP id 14-v6so16694925oie.3; Mon, 18 Jun 2018 18:47: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=ulH00IgjF/WkcM11h/ccQ7Bj0WEZPoW+86alhRkDDFs=; b=EKIWZTFcd2b+A5djaJN3F9/kccnU5G17nHkTHdiiEUtIeJYI57M94F3OnauVQwsmQc xVtxpbnkzdDYjtAkSND6ulvERBq8plxPQw4cH2AJ3oWLqnSO1f9+MGwyWOMjE3RLV3t5 Rrc6YxO4JRif2dqiCtlf2OrMmy1xici9/iRFDQRhyNJ4dbUV0YoJFOrDCTq3+/yV5QsS uX229IckBYpHgby6Nc6kpPdi4hWvRSkGmm3VEL6iW/T/O50beSGVeeUQETm9QqbXmBZ7 XcBrHXT+klpKqJEDFzHbJwmhHxFjyv+b5tVxQdicOaVtggMPwGS9Ph4Zd0Mh7nX+R+Op GF1g== 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=ulH00IgjF/WkcM11h/ccQ7Bj0WEZPoW+86alhRkDDFs=; b=KmLQaFp6wwe+mvLrjXHKRKz8SXySRMGq370cPDZWh8xPzmeoqnvXrtSuq29GSvrpbH 5KaFj+cseTEo5Its5klYFckoboz3Uao8mHEVOM/eFYuGpzEhLcGq3CUb9WOr9OxIfRcP BM7APyjuDQdFCgV7uvXPV78Emb+N0vnubdWL27qusxAhrgMw9l0Kpg7qnLCfoW8mEsaB hVXWGY1ofkxAtoVZwgDrurBl3p0fWGAYlu4v5Q8Iy8P/qoKyljI4KHUKlplTr87jtE3c nBD2bPIdkYOJ44Z4PqC69SuKxy9amvaAP18nuTbYxxnijSQn+qzVTNTv9Dg+uVa40cQl VECg== X-Gm-Message-State: APt69E1ISRGhG07jiYrbh9XboMUX/aeTBl8fBRvcNr/zOybtulcJ431o roYXFrMHfYgh6MEiEy3dh5kbPw3foeU= X-Google-Smtp-Source: ADUXVKKOBZbKfo2K5uWXPAiC0miCTrO2JR28ifUvrHLaRVILgjsPWGKlUj9I7mRZS/FutA66BBJ42w== X-Received: by 2002:aca:c5d4:: with SMTP id v203-v6mr8816280oif.92.1529372858961; Mon, 18 Jun 2018 18:47: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 w189-v6sm7475948oie.45.2018.06.18.18.47.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:47:37 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:43:00 -0500 Message-Id: <20180619014319.28272-95-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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 094/113] 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 c7efeb5666..b692c4aeb8 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, }; /* @@ -2940,6 +2943,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 d43b4b6cd3..2128c89c25 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 Tue Jun 19 01:43:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 931314 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="s34TB+lR"; 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 418sw74kBYz9s1R for ; Tue, 19 Jun 2018 12:53:11 +1000 (AEST) Received: from localhost ([::1]:38776 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6lZ-0003nV-AI for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:53:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47556) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5kF-0003dp-UY for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:47:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5kE-0001Bd-Gl for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:47:43 -0400 Received: from mail-ot0-x241.google.com ([2607:f8b0:4003:c0f::241]:38239) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5kE-0001B5-9F; Mon, 18 Jun 2018 21:47:42 -0400 Received: by mail-ot0-x241.google.com with SMTP id p95-v6so20773392ota.5; Mon, 18 Jun 2018 18:47:42 -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=oHHo0abvwAMM1R0MYp8/GNLu22cBeZ2s7jZGeWcnEXA=; b=s34TB+lR3dOoOffjPhnVSF2KTgsBpxYSD1YGwWRbR5iWyzXqCJAupWGUBl6iVg07l7 xSCnMmMOae+L0KCOk0n8YXeovo/nLFLBpaW0RvJNSnpj6fS9Qt+jxm1aeLyedmotbLOF sXIztRCRBDx34THxuSl73qSdb3Z9aWSs4I5Bs2Lvw0UexPA4TbHk7PnvsdoiZfp8zGXA 91uVCZN6b/YhMKqLNCTR0SophD7pFaQZD5dCKgFOwZtK08OClele50uNAsE/3cwj7z8J aLafLWYM4ZsYKIm8jbqP0/TAf79FKFhLW7C9jjsjdsTmdl3d9ITvu+DvG0fnj8IaiMgZ QgJg== 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=oHHo0abvwAMM1R0MYp8/GNLu22cBeZ2s7jZGeWcnEXA=; b=CN3d9k2Dicg5VdnVcECnL5bs2XrWy4Q+1plcSxQPrwZgVVul9sZKs87V/KZzJ7ox/X txxQkJDnGkyr8H1ffHOrBFtrfTmWj0ZagKLqY65nMU0xKrvqv7oyGUmHpP08zRLskvsV yoQQygRwuwCUcErRZ8mbKmg+O9TLxJ8fEeSn66sQlZ0WkDoTnDnEjSLX54bfbvrEkfOW xwzH/22tNI2FhvdkEO/T9K9Nb6vZRs2BgemVTYoqFY+KNsr+OiQc4MBey9S2nLt0VQiU vFOMCU5pQ8Kh66ppZjvjYctskjZsp6Sh9pSjoNgBAtX1MPwEm2Gg3uZFBgnjEOasLTk/ 58hw== X-Gm-Message-State: APt69E2Wch2+VlsIpMSdfqBnDD21iZZ5Es/os1T2+p3pPDPciRUHzRFA 2NLFCTU0DspQz6teP26GprAVKB88IBI= X-Google-Smtp-Source: ADUXVKIuUlpy+VGtCOUdS6s6GDm0GUCAtIp2oA6kJU+/27R3L5zfyi/NSc3AnsTCX535t7Cc76Y66w== X-Received: by 2002:a9d:7308:: with SMTP id e8-v6mr9690684otk.49.1529372861030; Mon, 18 Jun 2018 18:47:41 -0700 (PDT) Received: from localhost ([2600:1700:70:e488:b0ee:9bda:ee6f:91be]) by smtp.gmail.com with ESMTPSA id 8-v6sm8109834otw.22.2018.06.18.18.47.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:47:40 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:43:01 -0500 Message-Id: <20180619014319.28272-96-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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:c0f::241 Subject: [Qemu-devel] [PATCH 095/113] 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) Conflicts: util/Makefile.objs * drop context dep 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 0255113470..a8e01de523 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1680,6 +1680,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 2973b0a323..5ece5db8ce 100644 --- a/util/Makefile.objs +++ b/util/Makefile.objs @@ -46,3 +46,4 @@ 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 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 Tue Jun 19 01:43: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: 931342 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="U6M8n59c"; 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 418tPx0Kntz9s3C for ; Tue, 19 Jun 2018 13:15:33 +1000 (AEST) Received: from localhost ([::1]:38945 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV77C-0005rn-Lv for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 23:15:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47607) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5kK-0003kR-TP for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:47:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5kG-0001CC-BK for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:47:48 -0400 Received: from mail-ot0-x242.google.com ([2607:f8b0:4003:c0f::242]:36235) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5kG-0001Bw-42; Mon, 18 Jun 2018 21:47:44 -0400 Received: by mail-ot0-x242.google.com with SMTP id c15-v6so20781939otl.3; Mon, 18 Jun 2018 18:47: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=/rm362dUtyRRGb4HIS73XeQMS8kNopknVADu7uoKViY=; b=U6M8n59crbrnD+LhouH+0+8N3AyLUDTtAutLCcZewfuQmJ82NjbXxceRb14NL+mRvD RBolXzdxqzPv9V++T2uiTccvm7ZNhqwjtp4ThaZ6/GHEq9Pq8TdsDlCE5RusRdOMYJXD 0xIKpwXk1xEq7tXGbzGsWJWcls8vz3EovloYxmkWJm+fJ0RyWQIGZgK+N6IKRDhcfMGP ikfuhJhEbWcbBE9dfGC2Rvvd3xD7r0q2TSo9c7B8wX7uIw4I98QCA49Hs6hSQ4bG38JA m9xvyPUCsqY4CzgT4Xz+wYQzwBwFcX4aLy1dVPAcGQAB22kkSELVVJQ3IC4SFfxPURa5 YNIQ== 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=/rm362dUtyRRGb4HIS73XeQMS8kNopknVADu7uoKViY=; b=j5Cg1MYDvB90twOrAlxLh6pn/rUvTUOhOmYWMyslHnFJrgjmOS6qQ5MJIM9BsNq9HU odLTlDA/SXytqX5xj4e7sG3HxFVywA1hdssRO5ulu4Vbg5vkgG4dcVZGXlJP2ZtVMfCW r7dK3GmVCoQvYuIXYLOXm5KpVh1rJN0Q0ouzbH2ynJ2tvup9CI/bLwQR9a1I7HRQf6p4 7MGHyJbNg/2sOuB47eLSZb5/wVUSBYcLO4A+DvFBAYl1VBhLrqSyyIPT3TKhemDl0GYe fAhz7ksa6hhFO6IlpUVNXCQn3ho+CQgQOuT9DA8fYWkRJoOIhFCLy0ysJUFQHdiwUfDZ IUDg== X-Gm-Message-State: APt69E0K0WOwJpnPzuEmT9ZInlgJeEitBfpd4ehsz2LjqOHx7FCkLZs9 KAxSvzwoB477X03aFjYED4SUPbU7Gs0= X-Google-Smtp-Source: ADUXVKJVlR/LWpxAXfyKoz+tdK+un6Ap+viRevvIhSw2wukbExckM0ezDIN2JTbIkVTQ51jfgzUtTg== X-Received: by 2002:a9d:27a6:: with SMTP id c35-v6mr9855564otb.56.1529372862877; Mon, 18 Jun 2018 18:47: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 v8-v6sm16552239oti.35.2018.06.18.18.47.41 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:47:41 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:43:02 -0500 Message-Id: <20180619014319.28272-97-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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:c0f::242 Subject: [Qemu-devel] [PATCH 096/113] 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 b692c4aeb8..8e0c03e35d 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 @@ -2799,6 +2890,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 @@ -2851,6 +2943,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 @@ -2895,6 +2988,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 2128c89c25..9e5dcb6b2b 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 Tue Jun 19 01:43:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 931355 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="V+4X3zya"; 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 418tpT5KCcz9s2t for ; Tue, 19 Jun 2018 13:33:21 +1000 (AEST) Received: from localhost ([::1]:39101 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV7OR-0002pU-Ax for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 23:33:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47583) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5kJ-0003h3-6t for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:47:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5kI-0001DR-GO for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:47:47 -0400 Received: from mail-ot0-x22d.google.com ([2607:f8b0:4003:c0f::22d]:35258) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5kI-0001DL-Av; Mon, 18 Jun 2018 21:47:46 -0400 Received: by mail-ot0-x22d.google.com with SMTP id q17-v6so20781913otg.2; Mon, 18 Jun 2018 18:47: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=aJ0utm+Lg6O32tlfwXWIBbrQLSrjGqfU3gMZFltAUGA=; b=V+4X3zyapwbxLYXBsI05mUOnNLln+3iwqP4t8cLIX0YuuU9yRNgdkPn2qSmo9mpaNo IrD3Mk+JZb65N0PMXanBIWF73bJqbfa5VJqmOVbB1StR5cavWAimBI8JKGO0uzaWB9mL lEhZ7WMCpmFnWcFfnNXcAKQ7hYEiyEcXv8a9O1/NUFbYntopOpYQA3QVF2EiAo66gbWk AYCzr3lrQdq/mgALvkZ8lLNimznljdO3UKEBPf+stAZnfEIUu9hRcWRuutP2D5r8V/f1 d3HxLehClgrJy/a6+aKbEqaQtH6UBxSmf8yGOPV5wjkRqFnamhDU70FmGi6dBAAEwq1e oiRw== 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=aJ0utm+Lg6O32tlfwXWIBbrQLSrjGqfU3gMZFltAUGA=; b=ecMIMZvUj+nynvzPH1Epid/YSHzPX2Ab0b+JkfWiOwtr9/8ElyYL810JqaKO+r48tI jPa9U4f2SB2TRnlWyS9GUA9c8bpDNFMQbVA1P1mg3X+C5hSLIyrYVBHFfPhwk/DNUeBT 34VKBDMEi2/s49pN+tA6cQp2ZJh8IdxM8cT/fDSjvHOfeYWfF8MHTkCRofTR1r7yAkhg mljGjwmzvJw1RfrsP4i+Rmh5Bd4iRQmpq6aoNhXihbOC2wz90FyTL0a6fPlfWD9zYgiw 1OpLlavCO1MyodU6PKMbA2LnyoA1FwHUuyMTwJ0rWoUWGRPQVmcwhXQdlf563lGmhTBz nA/A== X-Gm-Message-State: APt69E2l97oDn5QmJApmuaNpDTj+IHKiK6gAYYbP60xeX6dCRlUW9KZG c86t8krcOXAUPRXHhZBmhzXU+Nv/4bg= X-Google-Smtp-Source: ADUXVKJBvIw8l7gonFHBHj4YoVEQ/+ifsVKXop4SXQcOW+sSZ1aegDFWXXfWHa+RUhKi/3aGFcqDkQ== X-Received: by 2002:a9d:2f91:: with SMTP id r17-v6mr9821041otb.356.1529372865158; Mon, 18 Jun 2018 18:47:45 -0700 (PDT) Received: from localhost ([2600:1700:70:e488:b0ee:9bda:ee6f:91be]) by smtp.gmail.com with ESMTPSA id b203-v6sm9089498oii.48.2018.06.18.18.47.43 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:47:44 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:43:03 -0500 Message-Id: <20180619014319.28272-98-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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:c0f::22d Subject: [Qemu-devel] [PATCH 097/113] 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 481fe5405a..d01deba632 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 Tue Jun 19 01:43: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: 931356 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="kn6X+bJ0"; 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 418trv4r65z9s47 for ; Tue, 19 Jun 2018 13:35:27 +1000 (AEST) Received: from localhost ([::1]:39109 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV7QT-0004Jd-7x for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 23:35:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47619) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5kL-0003lW-VY for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:47:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5kL-0001Fb-0J for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:47:50 -0400 Received: from mail-ot0-x234.google.com ([2607:f8b0:4003:c0f::234]:33934) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5kK-0001F7-RW; Mon, 18 Jun 2018 21:47:48 -0400 Received: by mail-ot0-x234.google.com with SMTP id r18-v6so20786312otk.1; Mon, 18 Jun 2018 18:47: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=p5Cg4ywzQhZG0uqDz1q2Q6mj00yxQCPX3Fq4GAvT4XE=; b=kn6X+bJ0h+1RB04QmIq5BAacL/Q5XAiBmIs0aASl/CtIEtz5M3NQRHCdBJc4+4Sqmt FfpbyL7zoVYTbtzrOfJSazZHMh40Aiu9PMhT31gtiYBV0Y/pLLcx0TSrJmh+wd2KkIsP 8JkJW8ayQHYPWKj/ok5DRLYBh0nnTJvlX3I71hmTDGWqxoZTEgQUmT798GOgW2yl/Vhi AsBhkuWXY0kcMD/pspoIFAu+vHFKfKOJqEExPGlmeARgFYAWNSCDMcS4V3tLhqjUyr9I 0e1vny60NOjxqF3BshtZ+0Y0KiKrlluzIaEZW+UFergPKYQXpAMTYgdCrh02PwDIoOzb VDEw== 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=p5Cg4ywzQhZG0uqDz1q2Q6mj00yxQCPX3Fq4GAvT4XE=; b=io5oFB8iw2jJjiYBE34ZsjCfHRhSj7Bx/thvq8lztc0i8pskIpcC71xjBPz08Bt/a9 R9MtuilG9DJHI+ZqdXA8h9aKP11m/NUrdWRsrJEM5ItUAjVDu5JsfXj+x6uBg1AfYV3U U1+YX1fzoQqugaB3AWKWKBUpIZbK4MLZYKF2sz34QChfPXLBjY1erndCkJiWMnFLrh7i ad/+o92j9iz5iUPn3lwYj9pmxQ0RHhYUkj3HiS3DAYTI+obnfduG2Qa4SUw52AHBG/Gq 3BwQvJseoE+FyEZc4O4He6YvRlmLAP0wd7zbAFebjjhu3XRhLYknLG7dAKc9FKVcMpPw SxBw== X-Gm-Message-State: APt69E1Afe4/lf3CR50orMbTttNwQBTpDoGpWl3DhdaxiuC8m02F0Pqv 4rOfMOWHjWyPQOmt5q9HU4DxrKorHKc= X-Google-Smtp-Source: ADUXVKJ2UfNHW2R6PQ25RgBTGAYgefMSXoX3rRVFK7AqVJnDUZTRqjBfkgCDfIPkpSb0kQRF5/QFcw== X-Received: by 2002:a9d:2b3c:: with SMTP id o57-v6mr9857983otb.312.1529372867567; Mon, 18 Jun 2018 18:47: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 v66-v6sm8217380ota.65.2018.06.18.18.47.46 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:47:46 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:43:04 -0500 Message-Id: <20180619014319.28272-99-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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:c0f::234 Subject: [Qemu-devel] [PATCH 098/113] 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 Tue Jun 19 01:43:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 931237 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="ZUpjGix0"; 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 418rNy0HMTz9s2t for ; Tue, 19 Jun 2018 11:44:32 +1000 (AEST) Received: from localhost ([::1]:38354 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5h4-0008Qr-TM for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 21:44:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44373) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5gQ-0008Op-Uy for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:43:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5gP-0007YX-KU for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:43:47 -0400 Received: from mail-ot0-x22f.google.com ([2607:f8b0:4003:c0f::22f]:36644) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5gP-0007YM-Ec; Mon, 18 Jun 2018 21:43:45 -0400 Received: by mail-ot0-x22f.google.com with SMTP id c15-v6so20774538otl.3; Mon, 18 Jun 2018 18:43: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=h1UmUBfQhjusbBLUXJjy6V+MBfN/TADKerAx9EztFVQ=; b=ZUpjGix0MLNvupxKlErSBbbnVCoTBSfJGtLFSsR3m0trZXFG7YsdjLXRsYoVRCxZv3 aF24pmp3zQmhCiXnZwj1dOP3pndELQMusWmlWMYFMvc7AYrw4cDD/im7NXu4wJaDff34 4SpDUheQUKvXaTbgzDLRWFLZQkZlnV+xtnZs/byhUHFDWzdkanZH53esFLcYoJ3LXDa7 fFegHwQul5Lgl6TOs1OHNF7fM1Qs9cid3XHzI63G/UymmiKpZzr6ovXLTlQcvWqjijQ9 txK4t6JP2LmfY0wu0/ZuEq8Lj0Ky4/J/BbUTnJ1R2j8vV510H+pXpphQZliz/HuOpPDO pW1Q== 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=h1UmUBfQhjusbBLUXJjy6V+MBfN/TADKerAx9EztFVQ=; b=cjpL5/1VEB7ErKfBXE6ISJpKwQWZuyOSg2x6D+BWDvII5+ZF7vPIXtTwxjgeA0jKpv 5lhRVhuShF337KE2TGKEjad/c5D+3DpEqKV8bYOuJ2MZoWrRE/yPtmVM5iTsdtm89RVW jiy9JInevcU0lvMnvb9RY+jLqS5gpBkqMRLu9pzMUvREO4F+4suq5Era9x/nWRN8JvpB aSijNAT9ZPnVQRbB2Zg8ZZiA0URxlPTempkPHDnfxdE2erF+63KvgJWTbHfxC7Y1ktkA j2R05xfWXhqq3LAdw75nGGVJ4IY0jFb9H7jRZhMORxrCNYzhX06CS3nBTBB9l1t3Pj9Q S5eA== X-Gm-Message-State: APt69E327NvTqxATPbWdWs/czJBVxOQ9X53Xlf/Wij0UWWzzusOL13N8 5reb7Tq/2eOvwIfZNGm/165lcbRO X-Google-Smtp-Source: ADUXVKJpF0da6MP4TjGBs73MbiOTXGg2DPWQmQLCNyaJ15WgKEARliT6n3dboSrD2IKm3blr8gr3Eg== X-Received: by 2002:a9d:3171:: with SMTP id v46-v6mr8710346otd.34.1529372623798; Mon, 18 Jun 2018 18:43:43 -0700 (PDT) Received: from localhost ([2600:1700:70:e488:b0ee:9bda:ee6f:91be]) by smtp.gmail.com with ESMTPSA id c71-v6sm10091326oig.44.2018.06.18.18.43.41 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:43:42 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:43:05 -0500 Message-Id: <20180619014319.28272-100-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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:c0f::22f Subject: [Qemu-devel] [PATCH 099/113] 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 373311f91a..0741f3405e 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -533,13 +533,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); } @@ -1426,6 +1419,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 Tue Jun 19 01:43: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: 931242 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="EI2QTHr+"; 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 418rSw5sfVz9s2t for ; Tue, 19 Jun 2018 11:48:00 +1000 (AEST) Received: from localhost ([::1]:38373 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5kU-00033z-Cl for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 21:47:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44391) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5gT-0008Qz-RA for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:43:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5gS-0007ZL-07 for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:43:49 -0400 Received: from mail-oi0-x244.google.com ([2607:f8b0:4003:c06::244]:37837) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5gR-0007ZF-P0; Mon, 18 Jun 2018 21:43:47 -0400 Received: by mail-oi0-x244.google.com with SMTP id l22-v6so16713855oib.4; Mon, 18 Jun 2018 18:43: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=rXr/yGY2pnPp86/r9cC/Rm37xu68xXRWaE2pYQNzmhk=; b=EI2QTHr+lb1Gqy2sFi7wegi7hoXWQR8yAE/yv/rGXrnlHS7QKH3bPO9kFzh+r19D8D JtvMOhPgzhvOZvtwL5oVgD3e8aIXRUtKwouSEbE5zG4NZFV8tNXhc2S9IBYgLLu0QUf9 3ncAU1UTJQJfvMQCTEiKnuiFdav5kIFaPtZ4NrCBOksTT1BfzbQS0htZoHLp0mTcbp3R Xf9BadQgh+O0PMJfgacZ8WiFfT3ubr/an7nu73+qXdWiO0Gpw4BmjBgYOm8Fy37RwNdx OTmhm3m5HTpt2XkdAoTBOc4xErJmAz7t/UxQAko4wqv9jcdq6BmA8hjnvvvhtVyFc1SK Otrg== 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=rXr/yGY2pnPp86/r9cC/Rm37xu68xXRWaE2pYQNzmhk=; b=Lspc76Nlp09+wPduUik2P8k1SW0OlRDS3Sg/BQCoNKroM6co/ds2ZUqXKRpbbq25tV sTrYvqEnC40Ucuyci2DTy2AUdF8T3akhfa+tW7ji7WlM9Fw0+O7FtlHTGaCZvNcuINpd jO5yQo/naFvdZ2h3o8QerqwaDUcA9gi5U3Sos6MujPNrhhroNdKPpH4YYrv3i2tceaRc X0SStPGUrOtqa72N8nqWIvgxJ2aGqfK23Q7ytQzpaRyHF05bDBmb44dlXVoSz3eHod35 bPmYGzkXzgXPaOYa/DeWvV0xEQ29b8FJ9ivdoVkJHxWP3FJ7aTduD1FmToa+4WzkwQi5 XfYw== X-Gm-Message-State: APt69E24bYhkndpyCp34rZHJ4RJ+/I+ixcLFhgFlfbqxxPiZpcxEuKi3 ScO21cBR0NRX9B7m78BWWpQHyCI6 X-Google-Smtp-Source: ADUXVKIf8sGNA//I5/ukRh0S8GvpUjBjZ22yse91w5CD4hY3LsUTmNz18WyDXZdXBJM/toreHO37Wg== X-Received: by 2002:aca:e34b:: with SMTP id a72-v6mr8715447oih.117.1529372626290; Mon, 18 Jun 2018 18:43:46 -0700 (PDT) Received: from localhost ([2600:1700:70:e488:b0ee:9bda:ee6f:91be]) by smtp.gmail.com with ESMTPSA id t15-v6sm8685293ott.6.2018.06.18.18.43.44 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:43:45 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:43:06 -0500 Message-Id: <20180619014319.28272-101-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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 100/113] 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 d01deba632..550fd13525 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 Tue Jun 19 01:43: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: 931238 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="qCgSK4oE"; 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 418rPY3FJWz9s3C for ; Tue, 19 Jun 2018 11:45:05 +1000 (AEST) Received: from localhost ([::1]:38358 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5hf-0000Ov-35 for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 21:45:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44426) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5gZ-0008So-IS for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:43:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5gY-0007d1-M4 for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:43:55 -0400 Received: from mail-oi0-x22c.google.com ([2607:f8b0:4003:c06::22c]:46050) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5gY-0007cm-GF; Mon, 18 Jun 2018 21:43:54 -0400 Received: by mail-oi0-x22c.google.com with SMTP id 188-v6so16657168oid.12; Mon, 18 Jun 2018 18:43: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=h69UsiZQnsE422HEk04j0thL55/eYRX9JPKYC00mlD4=; b=qCgSK4oE4gVcWQuzQGAc4/A+eBsblzFh42SMOjZv0VGBWqKUVpsHAvLS8fDCIyLsOI nOTV8b1ezhynm7ZbLJ2/0s9QKs1Q0MaoOAGH66+qzmNk+4CwzAaTllKpVwzaF7l597LX 1iulqsMzavlVBQEM8QsHv2GJQW4b/Lo/I2XdN6jonkETMyw2P5Pt2dt3qq8THjGYCIPX ynpRRt5Kgt7ZUctevyEyi1oT/l9VEjVt5XUbg1xoRmfeF/gW/Ntnnqz6AOXw/ZxpRX8d JwFteWQOC/aGKjpfmITdPUHjAt37brK6mc/2RLCYRb/gHEuyxV3dMV0VVIImTvfhbO+R APSA== 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=h69UsiZQnsE422HEk04j0thL55/eYRX9JPKYC00mlD4=; b=fM1eh6GlgiDu0vLSDjtGFGr+94gk+lKg6qsqXA4FtJimd/1yjd9J9WWTKcHT3bwFBq Uammn1IWNyld3tJ7xcSLafzT5inJbAbacFu+3Z22HxGKN0Wy/TBl5GmLporoLkFuZ9G3 MinAID22NpJ4n8h5NbohRBIoz0hngAyh2AU24ESnc94r1FktIia/ur/qORC8HoUtxhHB 9lifgdV1WwEVWCTxZW2zTVj6d/nlchU891psduKJ7cYZ/d97chVBZIvzbYFrCieonlxx cx0fg2B3Z2Rvrtv9kKH/A7Tc1CRumy1uQfACkwjYV9SlaedaT0bu4GdqjbdIwob4vOtz Zh/g== X-Gm-Message-State: APt69E1OdbJjyL2ajcDI55Fc9mNBU6vu0KuvZyR+IX2blfPrcRhXSdw0 YhdeoMLsMbyT4rrz+6uAIBBjhGyJ X-Google-Smtp-Source: ADUXVKJJ8wJQadfkVGqDN23ZAYBv7zm/FgutlWZyrenp1I7Izc0ioDOS2oVFVIe2PQyJ6+SZH2It7g== X-Received: by 2002:aca:3f87:: with SMTP id m129-v6mr8786946oia.58.1529372633301; Mon, 18 Jun 2018 18:43: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 r40-v6sm14668917otr.62.2018.06.18.18.43.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:43:52 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:43:07 -0500 Message-Id: <20180619014319.28272-102-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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 101/113] 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 f236431da1..24dd28d51d 100644 --- a/block.c +++ b/block.c @@ -1596,13 +1596,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, @@ -1640,7 +1651,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; @@ -1930,7 +1941,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 c05cac57e5..f9e90beb21 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -437,6 +437,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 Tue Jun 19 01:43: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: 931250 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="Xcbdfpfy"; 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 418rdg32hzz9s0W for ; Tue, 19 Jun 2018 11:55:35 +1000 (AEST) Received: from localhost ([::1]:38414 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5ro-00006s-VS for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 21:55:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44455) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5gb-0008UR-Oj for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:43:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5ga-0007dh-RN for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:43:57 -0400 Received: from mail-ot0-x235.google.com ([2607:f8b0:4003:c0f::235]:40171) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5ga-0007dL-Mt; Mon, 18 Jun 2018 21:43:56 -0400 Received: by mail-ot0-x235.google.com with SMTP id w9-v6so20742821otj.7; Mon, 18 Jun 2018 18:43: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=MQCDZvnxH2X7QhZ3vwsImXz3B2EtO2dWJAp7K5qkKmA=; b=XcbdfpfyOToX+pFYvI7rbAgtKXWkEUJW2odsfeR2sX13cPlgen8z9O2GpdKiFg/MVD mAwhJghusNqscM/O46upABDwbBcx3ViTCfvO5gosL0j1AcI9xyfrc9vBFH1HmGQv86hR uSWH6Q6nDjXQhnB0UObooaZilSfqlBbCSJHAOkCSgSXbqYIHSqpQqJOi6udwQY2nJr5h s7YGS67SKbNUbw3bGjRxoQgQrknrOEaLG/YYW1XDKm9+ZUkvDyi7bBXtpB6ys0nIfvLU c5rWqFf4gPU79WguoXOcwTWXa3ka4RUFBH5C1BykdN51EK51oFFVoWDE8/A7MbuJAhXx MRlQ== 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=MQCDZvnxH2X7QhZ3vwsImXz3B2EtO2dWJAp7K5qkKmA=; b=TDK+QgVLedg41W5oy37rRtYBgTVVQ+b4MAcqg2NXmf2dGj2RdMf1JtPRe/DsBYemuk TCfZG1+SDNFMqRoAvtjI1mddWNHNYj/cpjWYZOm1rSRNn8tJGgJCwIPVZr8LG7CId9tG mGF6HW1BGmHIYi0+X4Fh7gSMGkkHphI6F+TSjlzL/o8WmL9A5r64PRE60y5e9XIw9Yzd g5aFR41Yt1+WttYgZS1ApxCjC9eK/CvUMzfY8QwcvAyJnfXTzoYI1FGZTmFujfXL363t zKyouRsuwEltJvvjJkyhKdTQW3Taax0D0XOjh58+GaDxJdoswMAYnTP8BbtlVtNi2e56 STbA== X-Gm-Message-State: APt69E146CaMUpBpd9WLoR/5WYkLUq0V+9d91eD1zBAltc9sz1mfrXdL 69AhzFhMp2ar28UeFb+BX/+y4SPv X-Google-Smtp-Source: ADUXVKL5kvEv3V3Ksk1GNvs91fU0tAyzXFNsNzocwGs1hPRDZN/3wx04eygfwAN2/AopsDlBEZoG2Q== X-Received: by 2002:a9d:754a:: with SMTP id b10-v6mr8695389otl.73.1529372635521; Mon, 18 Jun 2018 18:43: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 l7-v6sm6622369oii.29.2018.06.18.18.43.54 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:43:54 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:43:08 -0500 Message-Id: <20180619014319.28272-103-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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:c0f::235 Subject: [Qemu-devel] [PATCH 102/113] 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 1914a940e5..28f2d91797 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -4235,7 +4235,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 Tue Jun 19 01:43: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: 931243 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="RlB5PtXI"; 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 418rTj3gqlz9s3C for ; Tue, 19 Jun 2018 11:48:41 +1000 (AEST) Received: from localhost ([::1]:38375 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5l9-0003ka-2F for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 21:48:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44486) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5ge-0008WS-1E for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5gc-0007eO-S5 for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:00 -0400 Received: from mail-oi0-x22f.google.com ([2607:f8b0:4003:c06::22f]:39400) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5gc-0007eI-NL; Mon, 18 Jun 2018 21:43:58 -0400 Received: by mail-oi0-x22f.google.com with SMTP id t22-v6so16698833oih.6; Mon, 18 Jun 2018 18:43: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=E5eInSvwJvucofP+nOxgtRP2Q1cs/4a2DzxwLsk9RJg=; b=RlB5PtXIyukU/Eblh7QQ+aTpTfq4J9uOGA8j9VOfEGj5XaOG4OusRNWMpw11SZQt80 58KeOfXiIHWpew4MGOt5shRjgYoXnybNl0qTtJJzXlH//m+SKYnHehoyIDFGk3IzncD5 NFDqlBsLLOIDi83MB8dVkmr9Rw3twd3AdrxXvYMGHPjteV5JS72vrv6A6iDpslGvOMeg S99C2cSWy70hk4PMLf6AGSaCgunyFCppt82cn2yO8SprnyAj4EECrnedOivQdTJ5BNwD +sB54Ojll0j+vWHeoRfzmfzoy3Cm1/XmTzr+VbJYJxmNaf8tBkmrssLjqcottLNnLkVf JZgA== 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=E5eInSvwJvucofP+nOxgtRP2Q1cs/4a2DzxwLsk9RJg=; b=L7828mwdKvIY8rorXsDq0cYXXm7ME5zRoUlhU0o7i7+itLAfj2shkQUUrPa+1Wmimq UTBBfTJacP5oWvaLzws2l9CQZnQp3WFCocLOBinJjTw3o1RMJImFgyZaRNXPVQ+7bUmK zBn4f0HDBhYnKF3iZsI4I3AZGsiF0+55EkhNBL5Uh4Lk6qVxaVtXjcUWCQmoN2cJ97V7 j/iHvt6FaqH+Y+vPsXnIuZWvLshsXghPMFhd0ZfIqxI9Tdaw5avWNrhVXJ6hyjhP7z06 K2Sf6gPMklqNHZWDGMycidzb+SQa/iRhWABxVNUm+1Wp7bSsrlBcVWNeuGAUlbsTWWWR NifQ== X-Gm-Message-State: APt69E0IR48cYJ2IIn46DC+UJR5FQ2cDcS+/0/RjcGe5aLU+xPWIipVv yoLJqbKFgcPIlL0Fh9Z9OTbSfjfo X-Google-Smtp-Source: ADUXVKLHq7L1ELPucDueziLxr9EgLIKWLj1eileI/fFbmKiZDqOYIpzGA5vku+9Ii3hEGzrm/lhDLw== X-Received: by 2002:aca:c681:: with SMTP id w123-v6mr7847113oif.94.1529372637467; Mon, 18 Jun 2018 18:43: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 a52-v6sm12157422ote.30.2018.06.18.18.43.56 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:43:56 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:43:09 -0500 Message-Id: <20180619014319.28272-104-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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 103/113] 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 14797dd3b0..d6f4e6eb3c 100755 --- a/tests/qemu-iotests/060 +++ b/tests/qemu-iotests/060 @@ -439,6 +439,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 c4cb7c665e..36714ff414 100644 --- a/tests/qemu-iotests/060.out +++ b/tests/qemu-iotests/060.out @@ -411,4 +411,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 Tue Jun 19 01:43: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: 931239 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="gU0+oCef"; 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 418rPp0zz4z9s2t for ; Tue, 19 Jun 2018 11:45:18 +1000 (AEST) Received: from localhost ([::1]:38361 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5hr-0000dK-ML for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 21:45:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44506) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5gf-00007K-W2 for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5ge-0007f3-Oy for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:02 -0400 Received: from mail-ot0-x235.google.com ([2607:f8b0:4003:c0f::235]:33924) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5ge-0007eu-JD; Mon, 18 Jun 2018 21:44:00 -0400 Received: by mail-ot0-x235.google.com with SMTP id r18-v6so20779327otk.1; Mon, 18 Jun 2018 18:44: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; bh=cS6u/NIYryXPvoUb+Zo+tFYzGvs/Tsxq+3j3TvEUaXA=; b=gU0+oCef4/hrqA/xHKakFMAoO8cT/BSuhDD74Oj5/k7PfV7skelSuhuUpf6vir7Rw5 uikBxiJ74sU2SFr3riO0QBJx9G6WEY0lqAieAxo2bht+7+aLD0kcNMBeRjq34MuxsmNt JVjWSzPY/3UszvvZ6AAnkwa8d29ir5ncaWeFtLxfV0cxcr4eapITAfZwHHm3pyGfgoti gZBxMlRyriO3EjeroFLsQ3HFRkJFPm+IFsjutgjYXurOckKYvKQyr5A+gXcnk63H/k9s r1T3OXIKfz43dYW7CPVKQKgURonkLDRKVdz/hclmSJNyqW/eS5TfkqRRuoWU9+mN8UZ8 sPMQ== 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=cS6u/NIYryXPvoUb+Zo+tFYzGvs/Tsxq+3j3TvEUaXA=; b=hsQw1vpa/VXh+GD4qPKMVFouSg8dg0Tw8A5QA0vj9d+Rp+rc5nG1brp/cRJqA/JkD5 jtvfIlfbKuZb5b16Y+kjJ/ptsHVXGwcAGaVrUxFbl1WmJmDgFBGy0p4jnt4iBc0ZQHST J5MIbZ/suAs9C1EKkP85OzO4gHJKFqCyBwiQpPKZo9bT7P97c3exuJGi6JqQ9q17EAAc epHjmp5rGP21U516meO9hEIQFMVm6lyEWIuiXjWDzmxVIGwKNBFH4oT/btwnqg6fHHB6 HNeK5VUUJdHOJ77gKNo/2I3giZ/q6tBPTfydi/rDmLFoh91J5LXx0QtXgvPVCHgxLXP3 CrXA== X-Gm-Message-State: APt69E3LxUIt95YEzYgYlWpX8ixDUAYGclrY85vppgIEfJzgkp0QF+RX Aj2L9czKtZKw2FurVrQ3nBXeZM0y X-Google-Smtp-Source: ADUXVKJ7cr7ImvIIU6mP2tmEkqhk/0HL0ETs7gx5YkG4ttf1irt5wuUBu834mGlL4thTw0jKUCc2lA== X-Received: by 2002:a9d:5190:: with SMTP id y16-v6mr9695618otg.252.1529372639452; Mon, 18 Jun 2018 18:43:59 -0700 (PDT) Received: from localhost ([2600:1700:70:e488:b0ee:9bda:ee6f:91be]) by smtp.gmail.com with ESMTPSA id u13-v6sm6636783oiv.18.2018.06.18.18.43.58 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:43:58 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:43:10 -0500 Message-Id: <20180619014319.28272-105-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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:c0f::235 Subject: [Qemu-devel] [PATCH 104/113] 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 833175ac77..d5903784c0 100644 --- a/block/throttle.c +++ b/block/throttle.c @@ -35,9 +35,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; @@ -62,8 +65,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); @@ -74,6 +76,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); @@ -83,7 +87,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) @@ -159,35 +170,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 Tue Jun 19 01:43: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: 931257 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="Mmydal4b"; 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 418rp01qB6z9s47 for ; Tue, 19 Jun 2018 12:02:48 +1000 (AEST) Received: from localhost ([::1]:38464 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5yn-0005lD-Ui for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:02:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44542) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5gk-0000CC-5V for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5gg-0007fe-Qc for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:06 -0400 Received: from mail-oi0-x232.google.com ([2607:f8b0:4003:c06::232]:37059) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5gg-0007fP-Ku; Mon, 18 Jun 2018 21:44:02 -0400 Received: by mail-oi0-x232.google.com with SMTP id l22-v6so16714274oib.4; Mon, 18 Jun 2018 18:44:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=FNAJLzVeBFdAdy06rJ+dA51LFRCnV3chaO5XsWGO7fg=; b=Mmydal4b70Fs4WbYDpemx0zLj8gcpFbmP1XLzgUReuSDthUvMa4RaAiWpjRD+75XWy A9e5mkkdxFHS967IERgXcQ2gKH8HMri2hpMe+EPeSakDhR4Y5N5FQM+rbPSOAxD6PyU7 52jgMwgJOAgxnQfJK381XDU5c+drG4HhJ3cLP6Xkc1oAGhqxl6zMNo9D6vJaHFK7HTQU J65pEteox3VGm1FcrJRdP0LXZKit5t2d5snLdR+LEOyZCjIP9XcLcL8EVpkdDzlNlV1h E3qm5j4jwqar/OguGLkzLC/sKjkgRpgG6BI5uri8EkdVpOYBhemOP97k8V70huxDYhOn EwfA== 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=FNAJLzVeBFdAdy06rJ+dA51LFRCnV3chaO5XsWGO7fg=; b=NLyRiIOszG/16ylDeZ2g7ftdh6sENCDm96cnCV18GvB1asbbHEYH/yInWknQJweCY3 iKWS035vFnMAlYUNb2YZX7nddnDzVDDMTZPYAWEFndRDo/z2eXKmbh2EInjwd780aBcv EYqiUuhlzFG+OQshUAYzEfCWYs7wmCr6oIfPNGIooH3ZWZIYxCwNrPn1YaNp/DL58XTf VUQ2z/Yl4RcT7HGIHnFgD0jqN2zMvw3zmuiNF3CzFJiixmOuaKB6ELFHPpDr13DZO8HQ Dpk/NZ6WBSILMEFYCQkdRAUjiLuUOZD2QGfjwJlFZtoJVdanuYAwIUpuKRavJCzIQHx2 rksw== X-Gm-Message-State: APt69E2o//SmXF0L7xK41AWcZapxZkaZeBCKsB4bba0A8mOpRkyz8rQP tkb/3tgAJY3CUr+URzSVyoO/e3hJ X-Google-Smtp-Source: ADUXVKJ6bmR3H772WnRGD5/uAGkGIEKLjYwA79vyZp59kWXeoEEeujTpxph+ulA/Wh6vXwJ53qxqjQ== X-Received: by 2002:aca:d854:: with SMTP id p81-v6mr7888070oig.214.1529372641493; Mon, 18 Jun 2018 18:44: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 q23-v6sm10129911otd.25.2018.06.18.18.44.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:44:00 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:43:11 -0500 Message-Id: <20180619014319.28272-106-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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 105/113] vga: fix region calculation 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 Typically the scanline length and the line offset are identical. But in case they are not our calculation for region_end is incorrect. Using line_offset is fine for all scanlines, except the last one where we have to use the actual scanline length. Fixes: CVE-2018-7550 Reported-by: Ross Lagerwall Signed-off-by: Gerd Hoffmann Reviewed-by: Prasad J Pandit Tested-by: Ross Lagerwall Message-id: 20180309143704.13420-1-kraxel@redhat.com (cherry picked from commit 7cdc61becd095b64a786b2625f321624e7111f3d) Signed-off-by: Michael Roth --- hw/display/vga.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/display/vga.c b/hw/display/vga.c index d150a3a3eb..1fa66d597d 100644 --- a/hw/display/vga.c +++ b/hw/display/vga.c @@ -1489,6 +1489,8 @@ static void vga_draw_graphic(VGACommonState *s, int full_update) region_start = (s->start_addr * 4); region_end = region_start + (ram_addr_t)s->line_offset * height; + region_end += width * s->get_bpp(s) / 8; /* scanline length */ + region_end -= s->line_offset; if (region_end > s->vbe_size) { /* wraps around (can happen with cirrus vbe modes) */ region_start = 0; From patchwork Tue Jun 19 01:43:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 931254 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="ZWqXG6RD"; 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 418rk92Hkhz9s2t for ; Tue, 19 Jun 2018 11:59:29 +1000 (AEST) Received: from localhost ([::1]:38438 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5va-0003Df-VA for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 21:59:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44540) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5gj-0000Bv-Ud for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5gj-0007g9-2n for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:06 -0400 Received: from mail-oi0-x22d.google.com ([2607:f8b0:4003:c06::22d]:34771) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5gi-0007g0-Ts; Mon, 18 Jun 2018 21:44:05 -0400 Received: by mail-oi0-x22d.google.com with SMTP id i205-v6so16709457oib.1; Mon, 18 Jun 2018 18:44: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=N4K6Oa+HZwIOiIK41/u0S6M1fyg2xFZtjjeSyVsz8Tc=; b=ZWqXG6RD7TiGX3l48znSsuIC1Y1MjbOmuALwW5LoahOIRIlF2GPuvvMNjlhMWN9G/n eunxeoJQaC+PH0ouRl5K2ZnBeHhLVd8iL49AzBDnVeSXH2EXwx0DkrxOECohg6RHRy+k KESmrp9SS9lcB9L5jB156A1pZ0O816p3bRJC/8yVqJH6+08eXf6pRQAZYtW1y12zLnmN 0HfKUMvZAPn8IaYrPh9M0d4Kk63TEhg9K23gCglBdqGjnk2G4RC4xRT/XRbX1CGXy1b4 kQb2qH9BVig6JjFrMfuEsqN/9Pkh9aTwe4UloCJb0LLTBZQwoxN2ujWCLmWbifudU/Ch Jujg== 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=N4K6Oa+HZwIOiIK41/u0S6M1fyg2xFZtjjeSyVsz8Tc=; b=kRnN+p7FuZ1ncwOA+DLDmoRWtYJhbYcpihpKKWahQTZSPiOn7J1zY8iiHLpcGUExtX Iv3j6x3m6EUYdKktt6L3fFGyVp5Sxv9OpDPjQ2c2id2Lj/claCJAK6atFvHy+yqDKbjj p5TCGXfVDqiA9BbkASRMQfTkhXBQaYokHPNDOLWcgm8dqyj94e4zTKnI2pPqCfEHUwGx Jsk4jQzDREdcitO74NJpTDMeW/S0LYPPfchnWUIHCtKbe/z2v5NfhO+7X16z0ZdgBCb+ 9rq+Ux8BBHzgbV2S9KPRfeoHHrWu4zCQJOe6Jrd8tzjrXsqh0kgZKg5b1Ciqcce4Fnyp WqTw== X-Gm-Message-State: APt69E0VYqyrYM6zft/+BVUizftxfAaJR39mqQ5utmj4V9Rr3H+9yAlh fVlWaW0AOzMrne+xk9bPirfvNimF X-Google-Smtp-Source: ADUXVKLAGwULLoTKhUe6WCOUDc7qJeGmPbx+eRm3ysZj4FW5ykotivnipORflD1jQONpkcDuFftaOA== X-Received: by 2002:aca:e34a:: with SMTP id a71-v6mr7816460oih.283.1529372643719; Mon, 18 Jun 2018 18:44:03 -0700 (PDT) Received: from localhost ([2600:1700:70:e488:b0ee:9bda:ee6f:91be]) by smtp.gmail.com with ESMTPSA id s43-v6sm9291190ots.18.2018.06.18.18.44.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:44:02 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:43:12 -0500 Message-Id: <20180619014319.28272-107-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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 106/113] 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 70c8ae82d5..bc087e95c3 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -459,7 +459,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 f3d0ebb673..422d99d80c 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -644,6 +644,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 CPUID_8000_0008_EBX_IBPB (1U << 12) /* Indirect Branch Prediction Barrier */ From patchwork Tue Jun 19 01:43:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 931240 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="kwMVDHe2"; 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 418rPv6XLhz9s3C for ; Tue, 19 Jun 2018 11:45:23 +1000 (AEST) Received: from localhost ([::1]:38362 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5hx-0000kh-FP for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 21:45:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44591) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5gm-0000EX-Fi for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5gl-0007hM-Ea for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:08 -0400 Received: from mail-oi0-x241.google.com ([2607:f8b0:4003:c06::241]:39682) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5gl-0007gw-7b; Mon, 18 Jun 2018 21:44:07 -0400 Received: by mail-oi0-x241.google.com with SMTP id t22-v6so16699067oih.6; Mon, 18 Jun 2018 18:44: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 :mime-version:content-transfer-encoding; bh=gt4NJLK8hH7MThtbKzUVXfL8kGVBluclj99sXl3Mp6c=; b=kwMVDHe2RfJvchYVZ+NlPMhSdw4qf314ylsNIYy+SMC0Z4VhrI8iFwEelhJADn3TS/ 6WJaJsQwd1QM/j7y4B2UiB0wDNsmR6FgK/h5fgYDExjAGAWFNw5JTHH4PSfsfGtEkd6r ZQQ6eduSco72YPBkfDQudbarPP85HivPNGQPabEYBI5HBDgI8GI9VnpvK8AjT9YnUOa+ c61g4EGo75uYkzyj8IB2MSSIXthYrwVI5xNnRvYEnTqBDsiUPqRbT/R9mUjxGCHG9HKi ppkKJktkr8JMnakBhZccq1+sY2ZltCe3OqPgLvcxoB9ARHmIYocAv5lAMh3RlJjqf7Wp PDyQ== 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=gt4NJLK8hH7MThtbKzUVXfL8kGVBluclj99sXl3Mp6c=; b=DondA1Io4+lOFLqevDf8wr0WC3PA2Nfwdmw099tM4HHwqLTRpcc3yzKIB0/3SnTPvi Ev53ypvd8qFYBRanM8oNEJbx48SspBHDt4lCfJmn/T+lfpUbBdbQcUAWDKi36TEqcFm6 bnnRB3oNvNXye0uVfuT33derQ/qWwXkfYdYnK/l8Lhrs8HMY5l8C1NXLPC6V7AAZLkzi eoSWxtnpgonPi0FhrQBUHCBlDCplwHQ34NWBrL5KqfB4i0TmDRqAqsZC7yQzhZCZdrFy xsKuqlUgUJCDSnGG5WuR4tPD2GMLIMPpuDAkxtU37q7ErPjKmYgHKwBlP5hjQhCZFxgT cdsA== X-Gm-Message-State: APt69E076DaadiQYDzkgZaFYZSHy0rmHe1CLLnnlv89GGnuSIIZytVQO Rjbg9lDFS4krKXPOpj3RUMQ86O6s X-Google-Smtp-Source: ADUXVKJKQCPVk4kNFmW7tOcz5qa8Mdw8ofRXP5O/I5t5pf0ywFtK1pBLvAtOSz3BPqsg6Ey9pyUErA== X-Received: by 2002:aca:f545:: with SMTP id t66-v6mr7735747oih.316.1529372646006; Mon, 18 Jun 2018 18:44:06 -0700 (PDT) Received: from localhost ([2600:1700:70:e488:b0ee:9bda:ee6f:91be]) by smtp.gmail.com with ESMTPSA id f97-v6sm7714056otb.9.2018.06.18.18.44.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:44:04 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:43:13 -0500 Message-Id: <20180619014319.28272-108-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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 107/113] 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) Conflicts: target/i386/kvm.c target/i386/machine.c * drop context dep on b77146e9a 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 422d99d80c..3cc1136535 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -336,6 +336,7 @@ #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) @@ -1089,6 +1090,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 3ac5302bc5..15001beeda 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_architectural_pmu; static uint32_t num_architectural_pmu_counters; @@ -1148,6 +1149,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; } } } @@ -1633,6 +1637,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); @@ -2009,8 +2017,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(); @@ -2361,6 +2370,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; } } diff --git a/target/i386/machine.c b/target/i386/machine.c index 361c05aedf..1c070fb644 100644 --- a/target/i386/machine.c +++ b/target/i386/machine.c @@ -837,6 +837,25 @@ static const VMStateDescription vmstate_spec_ctrl = { } }; +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, @@ -957,6 +976,7 @@ VMStateDescription vmstate_x86_cpu = { #endif &vmstate_spec_ctrl, &vmstate_mcg_ext_ctl, + &vmstate_msr_virt_ssbd, NULL } }; From patchwork Tue Jun 19 01:43: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: 931261 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="TkNm1xru"; 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 418rsx1vGZz9s2t for ; Tue, 19 Jun 2018 12:06:13 +1000 (AEST) Received: from localhost ([::1]:38492 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV626-0008HS-Mc for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:06:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44616) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5go-0000GI-34 for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5gn-0007jP-9Q for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:10 -0400 Received: from mail-ot0-x229.google.com ([2607:f8b0:4003:c0f::229]:39313) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5gn-0007if-3A; Mon, 18 Jun 2018 21:44:09 -0400 Received: by mail-ot0-x229.google.com with SMTP id l15-v6so20759442oth.6; Mon, 18 Jun 2018 18:44: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=gBS3C3HZ3UMQObSI+Q0o50+J3Q5MqXGn5ZxcfFpxVeo=; b=TkNm1xruWsYqNXMh4rLNARndrw7n9oBQPpnNbxLpHNRcCm7V0IKSdshVQuWUOPXhrg vFzNWtTWprzK1seIcE9jjh0xLpA7944UQindiap1s2tZXRTfb6GW0HIgmznNcTnLnML+ QtqZASjS/4JHJ/aFOjNG0IH8YX6pdKJ+BFHsaewnCCoFJsQUORLZe3iB6lYo+q3mC2CG AsTT7L7UubM7ZojMktOpeaBgj2jRj19GRWV9ErWn7OOUeISt9nzVs2unxgTT08i0nJr1 t6AdrO8usByXDA1XR/hOe0hJc9cfG3JWYTY2lRtkhDidnZHaMz0LMesqFkShDiWve7Oe Odrw== 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=gBS3C3HZ3UMQObSI+Q0o50+J3Q5MqXGn5ZxcfFpxVeo=; b=kDspoQj9Hr2oqEYZsR1XWhKQcScXzivh7HaxiD0DA+lvr2LQfzyKKcqIqyQOJva9Gn sKQeZn1X6i1h+bZonPR0p+20wJpnzwG/rb9tXUNWCz3GwUYK3WqFmewmTB1mPMdSHZA8 Xd+0ukV412+TA1D9OVGEXLP7I3GUyVMD3zwSryzwsH9Fj97b/C83/RSQ6JPkvqclwHBo pek643hqxX+7/qcUbFaT/9iL52TR+IA6Aop8XRbXJ/iGSP8r3mJh+NcX1KLgHfdKCAjd dyCyhMELqEqopFCGp7TCNFOHoe75ZI4z9qsxd8YOT2gKHyLg6x/jL0liZFRvfWzylkvh Rmog== X-Gm-Message-State: APt69E1O7iRfchAV+3sjH8R8LtRrkpVbRyKOdNFJyeu+xD5suH/09aPC 7WRAKv8lQjh7Z5W7YwiNYuluqdBi X-Google-Smtp-Source: ADUXVKLpsKGwcYOGPW+0wfp+Lo3whnVMWzXNH7WgqZcOMv5HcLZIbVWJrJ52qg40X11csneY6dp0mQ== X-Received: by 2002:a9d:5220:: with SMTP id e32-v6mr8682533oth.209.1529372647891; Mon, 18 Jun 2018 18:44: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 q45-v6sm8234655otg.56.2018.06.18.18.44.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:44:06 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:43:14 -0500 Message-Id: <20180619014319.28272-109-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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:c0f::229 Subject: [Qemu-devel] [PATCH 108/113] 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 bc087e95c3..1acf300cf8 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -490,7 +490,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 Tue Jun 19 01:43: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: 931244 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="IR/hTIO7"; 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 418rV65X76z9s3C for ; Tue, 19 Jun 2018 11:49:02 +1000 (AEST) Received: from localhost ([::1]:38379 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5lU-0003y8-Ab for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 21:49:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44655) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5gq-0000Il-2j for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5gp-0007l6-6l for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:12 -0400 Received: from mail-ot0-x235.google.com ([2607:f8b0:4003:c0f::235]:36651) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5gp-0007kv-1T; Mon, 18 Jun 2018 21:44:11 -0400 Received: by mail-ot0-x235.google.com with SMTP id c15-v6so20775289otl.3; Mon, 18 Jun 2018 18:44: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=3QsA4ftZLjeFU66rIFLeA5bR2aVAwSXJ5EzD0jMfr0U=; b=IR/hTIO7hqvipVMx0FUak6xv6VArsGjT6ttjRevkl8FdEbd9zTAT8eAV/atPuF4pEg 0ooXU/AijOMmRB8LqRIHd5fbUYlE8C22gvvltvkPa4saEvD7VKBQrdDXOVuR4OszSgr7 F8OanIpjhkYMArk1+o0u7Mifqx6XfaR2zv2Fte4725SboJ4gVVy9pjPeWsiNvHWdOh4v zvHnYKH9G567zaiRvTHEhEMGjgv6DghyBclfQ6Wd+bptW8yHtWhWYeXG7xEjy5ajoVc5 TPU6DeKummbzC3pPy5+vr2f7CR5ma4A3aW93X9ww4TP2sRhkY0vM4uwaJwzxFozwyNR2 x90Q== 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=3QsA4ftZLjeFU66rIFLeA5bR2aVAwSXJ5EzD0jMfr0U=; b=iopnmiCnmcssoBSNMwn092+DCIuX6DdFaH6Ur7vox08775bovdbsiq1UyX8vGmkZG+ cAoKrIhJKIc7sOv00g0TQRvQgOZgfk5Zr71M2cV1Vs2lGCsMpMl+LcPJXPgaHOxeKu0D AT1Nho5PTnR/erap1kfzdom1w/UbftqBavo/SkMW6HlnbM/KVshNwGrQMn8um0gwuCWT 6bE4I2wcfqCL99IKZ1hFwZFIDbQkIoNrzB/VLEoz44YwQDesM1REVoHHrAcn+pWF/3Bh ip/nAF8vKGIMQ4dPeuGOU6L2qzT2nxL8NwDfdVpdZReN10FVeR3vxd+ZTC+BQWDokOqj vugw== X-Gm-Message-State: APt69E0ZetFtSNiTYNvmtUewW2nSDnT93L0166qg6X3WIEikMico9A5P UPPIjO7hYaH290avPqrztaQDGqOB X-Google-Smtp-Source: ADUXVKKFYGr9cijW5may9zxXKHadt4MO77w2+LpJNm7BDiIyxE359TdvhQhd+F7JpjzR+NCXw8WWIw== X-Received: by 2002:a9d:3cb2:: with SMTP id z47-v6mr8376922otc.67.1529372649935; Mon, 18 Jun 2018 18:44: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 f64-v6sm8457072oib.10.2018.06.18.18.44.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:44:08 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:43:15 -0500 Message-Id: <20180619014319.28272-110-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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:c0f::235 Subject: [Qemu-devel] [PATCH 109/113] 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 979e622e60..aefd6edd1e 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" @@ -689,6 +690,7 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer, error_propagate(errp, err); return; } + qemu_set_nonblock(vhostfd); } else { vhostfd = open("/dev/vhost-net", O_RDWR); if (vhostfd < 0) { From patchwork Tue Jun 19 01:43: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: 931247 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="iAmnaNnh"; 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 418rZq31zDz9s3C for ; Tue, 19 Jun 2018 11:53:07 +1000 (AEST) Received: from localhost ([::1]:38401 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5pR-0006mY-1G for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 21:53:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44722) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5gv-0000NL-6P for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5gr-0007mN-Rt for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:17 -0400 Received: from mail-oi0-x236.google.com ([2607:f8b0:4003:c06::236]:32789) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5gr-0007mD-Mw; Mon, 18 Jun 2018 21:44:13 -0400 Received: by mail-oi0-x236.google.com with SMTP id c6-v6so16697455oiy.0; Mon, 18 Jun 2018 18:44: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=EIAT/+j1IAUdid27m8DLYdTKwpr61SdqpbrScpRchms=; b=iAmnaNnh+tKi93naPYflO56dV0G5QOM+DkGnnypCAI2Z62HAsQRPQsgv0mkW0iE4ol OUiYLKCkkTpdFPBmv+s4YuXEq2x5OQc4Y7dw/ZGCnjVqippwZFnzPgmPHk8iUQPknE21 Fj4PPMDeyw1Zp4X41OwLHE7RVYbq3kHrvvvI0KWS/clVFF6xqDdGwm+xg3rnT0OjWfM+ pm5dH7lyiDVGyOQH5ymwO49DfPNYienzn7YT+Cfm1qv9Rn7ONu0lPwt8++ccBaqtBDG6 fGSK/P8jsXcsmF+fjIIdtCzY4R/Wd+rcvQh/7VIEvqLwu7x6aBhYIEBfceS3GhwENmSQ A5lA== 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=EIAT/+j1IAUdid27m8DLYdTKwpr61SdqpbrScpRchms=; b=NY7cZv2hGbnfydn5bQK3L13f+7NbPybypkmZlTkiuQdrlFd+ycmwYUd8gCEXQNJ1k9 IV0DmWyQx6x56ILt2bd7wBG/YoGuDeVmq84wVwRSQ9r6chNY1hEgThBVmpP+Oj1Qzgno AiexmZvBZPtY+2FYE4bGGw+jg1h23IfuEOgTUneh9BUvADGSuKA/HsSWHMjhjTx5fivU XFQzIJR8MsZc2/51ekmuSwu865BLSpomMFbVUTiJw9qVoEMsf52/6PtmGELBA1x9RiZj VtHgqV9zCgd/T0aKuKjtX+9tW3YU+mq8gkRVFzSIEGzgT2PHgMF2WXDj1cdkRyVeCZVa gmbA== X-Gm-Message-State: APt69E1b3rQF3R8/JhQoQGJi3Wlz8l+666WrisgT7GRf8n1cF5fl+Dla w7kqHpT4pCPjTNGMUZmWtkrwld/S X-Google-Smtp-Source: ADUXVKJQlzScApYtsfAVTfhGwsJuMp9tK7vuSpcy3kcIGnJ+bQUYBwcVZ/d+Egsi9iJHub3zK761Sg== X-Received: by 2002:aca:49c4:: with SMTP id w187-v6mr8752199oia.123.1529372652393; Mon, 18 Jun 2018 18:44: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 j196-v6sm8555820oib.14.2018.06.18.18.44.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:44:11 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:43:16 -0500 Message-Id: <20180619014319.28272-111-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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 110/113] 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 c23927c912..d2015e30b6 100644 --- a/net/vhost-user.c +++ b/net/vhost-user.c @@ -296,7 +296,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; } } @@ -306,7 +306,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, @@ -316,6 +316,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 Tue Jun 19 01:43: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: 931264 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="Jt2cJrlg"; 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 418rxX16Szz9s19 for ; Tue, 19 Jun 2018 12:09:20 +1000 (AEST) Received: from localhost ([::1]:38507 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV657-00029Q-Os for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:09:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44765) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5gw-0000P0-NR for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5gv-0007oS-Oj for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:18 -0400 Received: from mail-ot0-x244.google.com ([2607:f8b0:4003:c0f::244]:46074) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5gv-0007oA-JU; Mon, 18 Jun 2018 21:44:17 -0400 Received: by mail-ot0-x244.google.com with SMTP id a5-v6so20748240otf.12; Mon, 18 Jun 2018 18:44: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=5akm9SE4DeR5ga9eSIpkTz5wyTY6TDdn5ScKcOhfyqE=; b=Jt2cJrlgWsMiAu2P8UVNB4KFle4aW/SH6G3GoVOHpzukY4jEWl307HtJXBz9SkXFMF S6o7/+FKAY8DzuE8Kq3gm0zqdaAWE93wxk24Hp0Y13zwwkOFB1fz6QrMqtfLTC5fFsrX dlOPCGChocLxmvauWT7kO78TqoZxAXW2Y689hXJmTE/89QXM5LjtjexaRfmV25DothTs Iz69Dl5F+Q1HUnZWfI6MeI8wL/0933njBiSUNAL+cnzOLrmix8H/XdkpdCw1XJpVxyix I/7XUdatVIgJzTlxp+HLE3Y9juASuquNvYtFxlNKlRqYq78wG8MLxanoInqji3YBOMM5 8mJA== 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=5akm9SE4DeR5ga9eSIpkTz5wyTY6TDdn5ScKcOhfyqE=; b=eF5zi3IyGbdNlX4Tjyt4IOmyLrE0HNqmOZGw4QBi4vFjW1PlbuvX9nxUmay05C0Mew uKZljlPkbWWH9eO57FmF1GrvZtmHpzY3mDgvYOzbDFMN8EmKnbuuAkZzO1g6oyGCRShk B8DF631ElVBFYYw4pPNEUCkiJZpqHwPGuKPckOtxCtQo8gbEa8uFgE0AUt/KS8rDv65v QZ9xt4eTr3eFVoqV174FkhDaIiH+kX4ZAhAooAuNGAPfKXgEXDv3RLy4FcCYNTSroDQG 70+NzHUtIWyWS09ixTRj/gBgEBWN8cp0I1gol4F1Lgggls1rmSHMNzoS3o0XUivgg2/j IvaA== X-Gm-Message-State: APt69E1rYzep85nqDWndx8ga7Q3+ofj1HnVaaqvZeb0hHq4h2Dq9n0xF YjQGMDbYjOT0hwqCnwxIfNtlZ4gG X-Google-Smtp-Source: ADUXVKKrBXDnxLpDN3OcXoQPuSx+x4cPcGBxDTzS5Lg4zsCh+qpgnaLIEpLagK2+oZEQYa8eqzNFWA== X-Received: by 2002:a9d:1a0b:: with SMTP id a11-v6mr8551503ote.205.1529372656304; Mon, 18 Jun 2018 18:44: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 t7-v6sm7580557oth.12.2018.06.18.18.44.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:44:15 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:43:17 -0500 Message-Id: <20180619014319.28272-112-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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:c0f::244 Subject: [Qemu-devel] [PATCH 111/113] 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 86060aab71..bf9de27893 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -2826,7 +2826,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 Tue Jun 19 01:43:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 931255 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="Nagh8KEv"; 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 418rl00rSgz9s3C for ; Tue, 19 Jun 2018 12:00:10 +1000 (AEST) Received: from localhost ([::1]:38443 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5wF-0003pu-Ad for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:00:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44824) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5gy-0000Rl-VZ for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5gx-0007ph-PF for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:21 -0400 Received: from mail-oi0-x242.google.com ([2607:f8b0:4003:c06::242]:33878) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5gx-0007pP-JV; Mon, 18 Jun 2018 21:44:19 -0400 Received: by mail-oi0-x242.google.com with SMTP id i205-v6so16709866oib.1; Mon, 18 Jun 2018 18:44: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=CFPvEc2FPtnSKiImtAxMORd/d6rO0QKUrCg2a7jRC0I=; b=Nagh8KEvW6YuBcMdWKnsEwvh+HAVvsRBT8YDBY328ni0Kdq6fsXQAdlDcNZi9rGkX5 aw5kluKmj9s6+74sOYKJg1RPGerUS4GGq5PBpKmue+EbwIGZ+jMIrFYVIhYQs0czDU/h sIF1KbzWdHx3GpzV5PUmVOaiHpa0SgVywo144Ie4MQRXlf88SaSc3j1FAiIpX7BN6Ea+ dOQPvzw7rLoLX/26ELLyHpUCcmhKINc4D89BPYknG40ossc0b2rQSplo192QBOZBpBy6 bONkfmxiEMfLwmtD+LiuBFsXkLbu4409xTISPf5E8Pyrb3DGI5ExJ8Cs9niLzD4MLRls 9SOg== 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=CFPvEc2FPtnSKiImtAxMORd/d6rO0QKUrCg2a7jRC0I=; b=p811my4JF3+ApgW0nFxrx0ik3HHynSmY0qbJXgSAckk53pZDiNRcNSxGiVZoWI5nG9 8KgP0W21djGx+xS3ocEBjnmRpBXeHyFeLjJY9TdjhnpDZSEDF/kUPO0dZqU5RrtglpNq ZFSRGoGm3xAqdMu4hn+ojrTPpXTGSRKlIuXqP40oRn34mQAaujfGPF8q3jBpQO/hs1ws ffsIo43ob0/G3J/JhGFuc22U04TlTiGR5d3JpnkQY328uIPWfrO++cpghdKLjpc1H9MZ uLOHLKXXTNbopEWnWx6jnUQl1WTDhXyZnIZ1GqbcP/0jnNFp92uIcP9rTg8xyQGiQ/qU hE4Q== X-Gm-Message-State: APt69E0Gpg6AMt163wRkLqhtTUVoHBFpXmSETwrSqvQH60Q/3k7sdTD8 QDmvbATYwujyu0sQWQ5SvQuJ6b+Y X-Google-Smtp-Source: ADUXVKKTZkDLkctn75ejlpWvaYN1lgvQXH9Ec8b9m2WyUXjRyY2mCxLWW1jWd8IvGwWsO2Y9ujQfww== X-Received: by 2002:aca:e142:: with SMTP id y63-v6mr8689732oig.128.1529372658365; Mon, 18 Jun 2018 18:44:18 -0700 (PDT) Received: from localhost ([2600:1700:70:e488:b0ee:9bda:ee6f:91be]) by smtp.gmail.com with ESMTPSA id t10-v6sm8489067ota.23.2018.06.18.18.44.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:44:17 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:43:18 -0500 Message-Id: <20180619014319.28272-113-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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 112/113] 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.11 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 3e688678dd..e6e793c951 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -197,3 +197,4 @@ 197 rw auto quick 198 rw auto 200 rw auto +221 rw auto quick From patchwork Tue Jun 19 01:43: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: 931258 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="SGXlALDf"; 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 418rpy6ftxz9s3C for ; Tue, 19 Jun 2018 12:03:38 +1000 (AEST) Received: from localhost ([::1]:38473 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5zc-0006Mv-Gf for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:03:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44855) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5h0-0000UN-Tv for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5gz-0007qd-Vj for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:22 -0400 Received: from mail-ot0-x22a.google.com ([2607:f8b0:4003:c0f::22a]:40162) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5gz-0007qT-Qu; Mon, 18 Jun 2018 21:44:21 -0400 Received: by mail-ot0-x22a.google.com with SMTP id w9-v6so20743559otj.7; Mon, 18 Jun 2018 18:44: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=kW8B5TzAlLDjHDgPY3ayuMehlo6xTvmuvLr+9s2pQkU=; b=SGXlALDf73iI+tvH2b9qmGhVCi6fsykr6FrmMsD5V+BUXpFrvrwrcmD0NbEs9ewchH 89d8ddbSMTXVDMYro+kl1GsrFpklUQ0h06nmSP7VSldy9JOByORPwkfOQWxUUG0wKcJ1 QFBXUTNO/EhYNjoKl0rzc3VBRbyI1Rz5KMH8+5fC6L8BsdOtrNUW08Cgg79Hd2uvmRxl cV998NxlEE8hbjl4UMWzI9XW4hP4kCrlPKd/Q+tyo0FhT/GGVNadnsp/vvBEugbkLZ+0 tFQa1cw6qOwmLRM/e4Wm2U6fbhO/Zk0QoA47n6f0eUyhCPsNXiBAf7cPCdxOPfRJbaDT yTWQ== 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=kW8B5TzAlLDjHDgPY3ayuMehlo6xTvmuvLr+9s2pQkU=; b=q3qaMB+IIBbVcqF2Uj3IPKNY8RaJ+kTPXBrGuyz2z0hM1FZvPLSitvgEZrn4vg9btE +XhjjbceVWOqG7Za0X0saoq/1QnVwiXtRT1pnAQIs6oPg2reeSV/nCClT0mQ+Kg50Vkl +XAUcBN9Mm/yMTVj/ii4/sgfCuLIv6XfOiy4O5OlLSF4THzjgUKmJzjcri4Tkl8meYrR L61eqr+xkmaHxL6+CfejbtuG4xKSdpd9D9mgCfrzL2egr6Js2ibN9qJ/1sRcPkw5EWpI DujKnkR2DCbN6lcooB+VQ40can8VU98ua6L9/zRtiG05sMthF5JjENXQ/Y1HKar/b2kl ur4Q== X-Gm-Message-State: APt69E0lSOqVTr9XxtcTVdGOnZuY+eOpgKiH11QhUQdDrx6d2dkfqg4w a5HPjua6vX9Slm2DfUVo4WUS3xfw X-Google-Smtp-Source: ADUXVKJVCE1nms/o2eXBQqHcDkCeqJMsSNVnbytHmQWx2vShkoqlMrchO6bt8lFljf5OjvUOO2aHFA== X-Received: by 2002:a9d:577d:: with SMTP id x58-v6mr9824703oti.196.1529372660594; Mon, 18 Jun 2018 18:44:20 -0700 (PDT) Received: from localhost ([2600:1700:70:e488:b0ee:9bda:ee6f:91be]) by smtp.gmail.com with ESMTPSA id k47-v6sm9220860otb.50.2018.06.18.18.44.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:44:19 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:43:19 -0500 Message-Id: <20180619014319.28272-114-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-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:c0f::22a Subject: [Qemu-devel] [PATCH 113/113] 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 550fd13525..3fff4687ee 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);