From patchwork Tue Jun 16 14:14:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 280344 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 10863C433E0 for ; Tue, 16 Jun 2020 14:36:10 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D2E6D20644 for ; Tue, 16 Jun 2020 14:36:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bmZr+fbE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D2E6D20644 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:36002 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlCh7-0007cE-3P for qemu-devel@archiver.kernel.org; Tue, 16 Jun 2020 10:36:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57580) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlCPn-000254-9d; Tue, 16 Jun 2020 10:18:15 -0400 Received: from mail-ot1-x343.google.com ([2607:f8b0:4864:20::343]:47057) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jlCPi-0006fF-KM; Tue, 16 Jun 2020 10:18:11 -0400 Received: by mail-ot1-x343.google.com with SMTP id g7so16013909oti.13; Tue, 16 Jun 2020 07:18:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=MBxm7nuYUhmoYS/sHlImvlcd+nSnILjZSRJjgMLw/0Q=; b=bmZr+fbElDD0JaQE7MsKZ5sTkE3ClXno08gKztNtqB5gYQpDRMG4ZdITcXSSkPGgWq yibchgH84PMzmh/WqhUFb3yT2UiaFfxEcG9109c1CU3RzNarGzab9NODQWq8w+tOZmGJ GeXaAqTJvyYgHHwckHmkHR9xphLFNUP3fw3waM3aqju04jwvc26jdqSF2cDPbIvkJvLa SA1Mk8KFtwiLBhhZRkB+JKJKJ8E6LKCjAzVLLZCpF/9gNfxThnRYoKYIvOjhu1pzVOPv p4otV04dDskOMucWhYlBY3Tgwfe4nceU0pW+CD6hKXDSEXvqRg71c0TneNzPDWXu+GBr rjzQ== 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=MBxm7nuYUhmoYS/sHlImvlcd+nSnILjZSRJjgMLw/0Q=; b=oBlZaoN+8ZycsPoSmQj4zx1/IWq4yLYcluI4+aONt5JJXMYsMHoZfQDMK0J8nlelWk 5G02JXG/zU3NCnLb8WLMD2twjcrYPSh2MizrvhH7Jqj/FQXGflcogr4iVjSJzZfaq1mH 7CIvoLyktZw7F9p7ktvgjUn3JqjNnYx4jz6NMmkylmV+z08o84Xa0yCCmeyQi1zwnEpL pTjxSlXapX17Fg5DXNch2VFl2xe/dim/phpOMVqms7MCtIjf4pmYXNeW+H2aXB1oaeuB O/Pt6QvZnauwYvtkHhpNG9+zEv6KtyhcACfyZyA/oo5DQxofZONDOjr5NufrN8znj9mC LKBg== X-Gm-Message-State: AOAM533VHdx9z3vrKvNyFg933kXmAJtVxeX/kfHLpG7wKq+MA3C4PJ/3 npxvJJ9yZ+3/e7f5afTy+HAr+YUS X-Google-Smtp-Source: ABdhPJz5J7aVsq1RcsYH5jKM/6pSUvaw/Lg4/70DEV1PUTMPYIynh++uEE4/0AcwopEs0g4bR9VmdQ== X-Received: by 2002:a05:6830:1294:: with SMTP id z20mr2452486otp.24.1592317088694; Tue, 16 Jun 2020 07:18:08 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id c23sm4072614otd.7.2020.06.16.07.18.07 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jun 2020 07:18:07 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Subject: [PATCH 02/78] block/nbd: fix memory leak in nbd_open() Date: Tue, 16 Jun 2020 09:14:31 -0500 Message-Id: <20200616141547.24664-3-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> References: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::343; envelope-from=flukshun@gmail.com; helo=mail-ot1-x343.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vladimir Sementsov-Ogievskiy , Pan Nengyuan , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Pan Nengyuan In currently implementation there will be a memory leak when nbd_client_connect() returns error status. Here is an easy way to reproduce: 1. run qemu-iotests as follow and check the result with asan: ./check -raw 143 Following is the asan output backtrack: Direct leak of 40 byte(s) in 1 object(s) allocated from: #0 0x7f629688a560 in calloc (/usr/lib64/libasan.so.3+0xc7560) #1 0x7f6295e7e015 in g_malloc0 (/usr/lib64/libglib-2.0.so.0+0x50015) #2 0x56281dab4642 in qobject_input_start_struct /mnt/sdb/qemu-4.2.0-rc0/qapi/qobject-input-visitor.c:295 #3 0x56281dab1a04 in visit_start_struct /mnt/sdb/qemu-4.2.0-rc0/qapi/qapi-visit-core.c:49 #4 0x56281dad1827 in visit_type_SocketAddress qapi/qapi-visit-sockets.c:386 #5 0x56281da8062f in nbd_config /mnt/sdb/qemu-4.2.0-rc0/block/nbd.c:1716 #6 0x56281da8062f in nbd_process_options /mnt/sdb/qemu-4.2.0-rc0/block/nbd.c:1829 #7 0x56281da8062f in nbd_open /mnt/sdb/qemu-4.2.0-rc0/block/nbd.c:1873 Direct leak of 15 byte(s) in 1 object(s) allocated from: #0 0x7f629688a3a0 in malloc (/usr/lib64/libasan.so.3+0xc73a0) #1 0x7f6295e7dfbd in g_malloc (/usr/lib64/libglib-2.0.so.0+0x4ffbd) #2 0x7f6295e96ace in g_strdup (/usr/lib64/libglib-2.0.so.0+0x68ace) #3 0x56281da804ac in nbd_process_options /mnt/sdb/qemu-4.2.0-rc0/block/nbd.c:1834 #4 0x56281da804ac in nbd_open /mnt/sdb/qemu-4.2.0-rc0/block/nbd.c:1873 Indirect leak of 24 byte(s) in 1 object(s) allocated from: #0 0x7f629688a3a0 in malloc (/usr/lib64/libasan.so.3+0xc73a0) #1 0x7f6295e7dfbd in g_malloc (/usr/lib64/libglib-2.0.so.0+0x4ffbd) #2 0x7f6295e96ace in g_strdup (/usr/lib64/libglib-2.0.so.0+0x68ace) #3 0x56281dab41a3 in qobject_input_type_str_keyval /mnt/sdb/qemu-4.2.0-rc0/qapi/qobject-input-visitor.c:536 #4 0x56281dab2ee9 in visit_type_str /mnt/sdb/qemu-4.2.0-rc0/qapi/qapi-visit-core.c:297 #5 0x56281dad0fa1 in visit_type_UnixSocketAddress_members qapi/qapi-visit-sockets.c:141 #6 0x56281dad17b6 in visit_type_SocketAddress_members qapi/qapi-visit-sockets.c:366 #7 0x56281dad186a in visit_type_SocketAddress qapi/qapi-visit-sockets.c:393 #8 0x56281da8062f in nbd_config /mnt/sdb/qemu-4.2.0-rc0/block/nbd.c:1716 #9 0x56281da8062f in nbd_process_options /mnt/sdb/qemu-4.2.0-rc0/block/nbd.c:1829 #10 0x56281da8062f in nbd_open /mnt/sdb/qemu-4.2.0-rc0/block/nbd.c:1873 Fixes: 8f071c9db506e03ab Reported-by: Euler Robot Signed-off-by: Pan Nengyuan Reviewed-by: Vladimir Sementsov-Ogievskiy Cc: qemu-stable Cc: Vladimir Sementsov-Ogievskiy Message-Id: <1575517528-44312-3-git-send-email-pannengyuan@huawei.com> Reviewed-by: Stefano Garzarella Signed-off-by: Eric Blake (cherry picked from commit 8198cf5ef0ef98118b4176970d1cd998d93ec849) Signed-off-by: Michael Roth --- block/nbd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/block/nbd.c b/block/nbd.c index 6bb6715286..3d369fc8eb 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -1900,6 +1900,7 @@ static int nbd_open(BlockDriverState *bs, QDict *options, int flags, ret = nbd_client_connect(bs, errp); if (ret < 0) { + nbd_clear_bdrvstate(s); return ret; } /* successfully connected */ From patchwork Tue Jun 16 14:14:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 188046 Delivered-To: patch@linaro.org Received: by 2002:a92:cf06:0:0:0:0:0 with SMTP id c6csp3725064ilo; Tue, 16 Jun 2020 07:57:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwGgZJjjJZJJH6Ce6XsNXaVLRFYAGabZUZcnj88hIaDiClcuzahkQxvrcvKy+Qh7w7V7NR7 X-Received: by 2002:a25:d7cc:: with SMTP id o195mr4960195ybg.37.1592319431983; Tue, 16 Jun 2020 07:57:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592319431; cv=none; d=google.com; s=arc-20160816; b=rmJqblBZby+DXzmdnukzjZQExBX0Ni/EcOOpDsLs0FITakwKD6n/AAgEFWWc/KtUaQ 6Jmmt/vwfoyoF/inqAcQzZ6szUTYKAG3wVyWoOBJhHQ4QjeC5aiyxsm4WfBwVXqiGqtT RndHhrmzUAHJrcs8tiyvdFUNtdt+ZHiSscE12qbAXpguka3rY6OkpYJS8ntC0KA4XCW/ UxtY/aektiDKlNhnJGcl78gKqYXyNhi8GNDGETWDl8FGEHOlAtxsbLNIJKVXY+/4D0Bd Y3RNjltH+aZr33S20tL9ctHpN3cHEPEKHlTDweDnOVYESz7IcPB+dfqhlqZgfgv2RCvq DJkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=iy2OuoLC+tcFJT1W5sFxWuwcrtbM/mLRHy96HLFDfHY=; b=dCUSYO6xgCeAbSbCMYiYFqQLcDRfPTlVqVLZfbA3KcEFaLUb7CqXc9r026Y2IVmxph qqId0ZRy6gRuBJZBhGoCKWOBdXZO9iLaWlknkUW/Fl29Wfvb/gBchx8y1/euIxIdMPFI YEmYGfA0QIyVeycHHPX61lTd1pyjXqzXW7OZnX8cjG8cBQ+dnJUb7BRplCAKAG5Ku6Np 8YCcWhZYLuPacRyskAF2LtXyr2g8RhT1cP6uzskmftFB/zj8BiNQ943BthiKzTSptVuC nHGk9kJ27vOEVy7HI5+/c6Oam4LrAE6O1QNy0wW2ByGZZ+QDlVomKKKIFGwC71EThRTd Un9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=nl8qW9tQ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id s7si16440433ybe.226.2020.06.16.07.57.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jun 2020 07:57:11 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=nl8qW9tQ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from localhost ([::1]:43804 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlD1T-0006Ku-Ds for patch@linaro.org; Tue, 16 Jun 2020 10:57:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58148) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlCQl-0003ep-5k; Tue, 16 Jun 2020 10:19:15 -0400 Received: from mail-ot1-x341.google.com ([2607:f8b0:4864:20::341]:39894) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jlCQh-0006yP-VW; Tue, 16 Jun 2020 10:19:14 -0400 Received: by mail-ot1-x341.google.com with SMTP id g5so16044090otg.6; Tue, 16 Jun 2020 07:19: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 :mime-version:content-transfer-encoding; bh=iy2OuoLC+tcFJT1W5sFxWuwcrtbM/mLRHy96HLFDfHY=; b=nl8qW9tQijZMB0AmSCgV2leGmJazbrQr68rNh2j34c9dc8eoVLMZ8py990VIfzQPD9 ZYMm1Cr4yiP6A7ZMtnfkDrK+ZRkgBcUYs5VGRpemjZfhRW258M3dyrgA/E5+KMF6BXTq CUgXVumSAdpKXqvfDe6a14ONlNANaKcZQ4kgXtzsMAggGZGGGVwcre6h79Zd0a6Yv6/w zy2IrIBqp6C182BQeBtoY07hUZGdPKiFqD0bYOYYieSqUM9u2Kmu1pi0IK+nkBx4yIAn /7MdjaYz0ZlFXh3VnxyhZtYc1FP5q/S96JvOFawDGUeuTCs/hyKsE1YbBQCtNUIJljmw /Ssg== 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=iy2OuoLC+tcFJT1W5sFxWuwcrtbM/mLRHy96HLFDfHY=; b=F5QJCa1xV5fwx+U/mSp3gjYkfVVpBoJ5mjCk9LfG0SxK77uKfrAtvfzhaS9E3ERnL9 yKXZ8HHvua+6CW+6AegEJhkW3LWtEBltMiWD6wLnnz6GgFVlFp2lX/jPCTyEB9fb4hyA am0Dz5InQzz0YMIuwWZmslO48s6TkQ33HncbOroruHsm+KNpFhh4tZyWaBE+muylI+mS zDBnJVyDafo3FRdzeSVE9JLGaNhR5lVPnFIvh+bkH9R1qm9+YImfxjMLuLW0hLhkTkQZ ibGLoDI+sZocAa0TgSdzuDevhsUYbSHW266W94c//lzd/ESgZUKfLI44mOm55tn5rp4O h6rA== X-Gm-Message-State: AOAM530m0EOprwgj34aDphffbnFDCQBWt0VXGCFnT+hsFfWHmamWAolz cwkk9IiUxnwDlNYGAUbhd1K7zKbw X-Received: by 2002:a05:6830:1443:: with SMTP id w3mr2512025otp.142.1592317149526; Tue, 16 Jun 2020 07:19:09 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id g24sm4098743otl.8.2020.06.16.07.19.07 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jun 2020 07:19:08 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Subject: [PATCH 05/78] target/arm: ensure we use current exception state after SCR update Date: Tue, 16 Jun 2020 09:14:34 -0500 Message-Id: <20200616141547.24664-6-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> References: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::341; envelope-from=flukshun@gmail.com; helo=mail-ot1-x341.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , =?utf-8?q?Alex_Benn?= =?utf-8?b?w6ll?= , qemu-stable@nongnu.org, Peter Maydell Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Alex Bennée A write to the SCR can change the effective EL by droppping the system from secure to non-secure mode. However if we use a cached current_el from before the change we'll rebuild the flags incorrectly. To fix this we introduce the ARM_CP_NEWEL CP flag to indicate the new EL should be used when recomputing the flags. Signed-off-by: Alex Bennée Tested-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Message-id: 20191212114734.6962-1-alex.bennee@linaro.org Cc: Richard Henderson Message-Id: <20191209143723.6368-1-alex.bennee@linaro.org> Cc: qemu-stable@nongnu.org Signed-off-by: Peter Maydell (cherry picked from commit f80741d107673f162e3b097fc76a1590036cc9d1) Signed-off-by: Michael Roth --- target/arm/cpu.h | 8 ++++++-- target/arm/helper.c | 14 +++++++++++++- target/arm/helper.h | 1 + target/arm/translate.c | 6 +++++- 4 files changed, 25 insertions(+), 4 deletions(-) -- 2.17.1 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 83a809d4ba..c3ab47d896 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -2238,6 +2238,9 @@ static inline uint64_t cpreg_to_kvm_id(uint32_t cpregid) * RAISES_EXC is for when the read or write hook might raise an exception; * the generated code will synchronize the CPU state before calling the hook * so that it is safe for the hook to call raise_exception(). + * NEWEL is for writes to registers that might change the exception + * level - typically on older ARM chips. For those cases we need to + * re-read the new el when recomputing the translation flags. */ #define ARM_CP_SPECIAL 0x0001 #define ARM_CP_CONST 0x0002 @@ -2257,10 +2260,11 @@ static inline uint64_t cpreg_to_kvm_id(uint32_t cpregid) #define ARM_CP_SVE 0x2000 #define ARM_CP_NO_GDB 0x4000 #define ARM_CP_RAISES_EXC 0x8000 +#define ARM_CP_NEWEL 0x10000 /* Used only as a terminator for ARMCPRegInfo lists */ -#define ARM_CP_SENTINEL 0xffff +#define ARM_CP_SENTINEL 0xfffff /* Mask of only the flag bits in a type field */ -#define ARM_CP_FLAG_MASK 0xf0ff +#define ARM_CP_FLAG_MASK 0x1f0ff /* Valid values for ARMCPRegInfo state field, indicating which of * the AArch32 and AArch64 execution states this register is visible in. diff --git a/target/arm/helper.c b/target/arm/helper.c index 0bf8f53d4b..b92ef9d190 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -5096,7 +5096,7 @@ static const ARMCPRegInfo el3_cp_reginfo[] = { .opc0 = 3, .opc1 = 6, .crn = 1, .crm = 1, .opc2 = 0, .access = PL3_RW, .fieldoffset = offsetof(CPUARMState, cp15.scr_el3), .resetvalue = 0, .writefn = scr_write }, - { .name = "SCR", .type = ARM_CP_ALIAS, + { .name = "SCR", .type = ARM_CP_ALIAS | ARM_CP_NEWEL, .cp = 15, .opc1 = 0, .crn = 1, .crm = 1, .opc2 = 0, .access = PL1_RW, .accessfn = access_trap_aa32s_el1, .fieldoffset = offsetoflow32(CPUARMState, cp15.scr_el3), @@ -11332,6 +11332,18 @@ void HELPER(rebuild_hflags_m32)(CPUARMState *env, int el) env->hflags = rebuild_hflags_m32(env, fp_el, mmu_idx); } +/* + * If we have triggered a EL state change we can't rely on the + * translator having passed it too us, we need to recompute. + */ +void HELPER(rebuild_hflags_a32_newel)(CPUARMState *env) +{ + int el = arm_current_el(env); + int fp_el = fp_exception_el(env, el); + ARMMMUIdx mmu_idx = arm_mmu_idx_el(env, el); + env->hflags = rebuild_hflags_a32(env, fp_el, mmu_idx); +} + void HELPER(rebuild_hflags_a32)(CPUARMState *env, int el) { int fp_el = fp_exception_el(env, el); diff --git a/target/arm/helper.h b/target/arm/helper.h index 3d4ec267a2..e345bdb726 100644 --- a/target/arm/helper.h +++ b/target/arm/helper.h @@ -91,6 +91,7 @@ DEF_HELPER_2(get_user_reg, i32, env, i32) DEF_HELPER_3(set_user_reg, void, env, i32, i32) DEF_HELPER_FLAGS_2(rebuild_hflags_m32, TCG_CALL_NO_RWG, void, env, int) +DEF_HELPER_FLAGS_1(rebuild_hflags_a32_newel, TCG_CALL_NO_RWG, void, env) DEF_HELPER_FLAGS_2(rebuild_hflags_a32, TCG_CALL_NO_RWG, void, env, int) DEF_HELPER_FLAGS_2(rebuild_hflags_a64, TCG_CALL_NO_RWG, void, env, int) diff --git a/target/arm/translate.c b/target/arm/translate.c index 4d5d4bd888..83aa331b1e 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -7083,7 +7083,11 @@ static int disas_coproc_insn(DisasContext *s, uint32_t insn) if (arm_dc_feature(s, ARM_FEATURE_M)) { gen_helper_rebuild_hflags_m32(cpu_env, tcg_el); } else { - gen_helper_rebuild_hflags_a32(cpu_env, tcg_el); + if (ri->type & ARM_CP_NEWEL) { + gen_helper_rebuild_hflags_a32_newel(cpu_env); + } else { + gen_helper_rebuild_hflags_a32(cpu_env, tcg_el); + } } tcg_temp_free_i32(tcg_el); /* From patchwork Tue Jun 16 14:14:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 280357 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0362BC433DF for ; Tue, 16 Jun 2020 14:20:03 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C23AD20707 for ; Tue, 16 Jun 2020 14:20:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XFL9dDk2" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C23AD20707 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:55634 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlCRV-0004oX-Us for qemu-devel@archiver.kernel.org; Tue, 16 Jun 2020 10:20:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57138) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlCPB-00010V-2A; Tue, 16 Jun 2020 10:17:37 -0400 Received: from mail-ot1-x336.google.com ([2607:f8b0:4864:20::336]:37383) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jlCP9-0006WQ-4R; Tue, 16 Jun 2020 10:17:36 -0400 Received: by mail-ot1-x336.google.com with SMTP id v13so16026841otp.4; Tue, 16 Jun 2020 07:17: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=2om/n6j/KN2TdtxPEqFhJaW70WBM2nI5WC5aQncvJV0=; b=XFL9dDk2CaS4A3U39+X98CzI2K3xIGEETWv1IbKp7ztJWxXUsQ/RIpQjMQnnqFeOn+ tqTX12tWh7WhH+p0zPogEcqOliWPUQsfWah0ddiupmmKFoHxYh+zGkqa75El+fkI8Rj9 LMGVjx/RwvMQb0exilEhBnFugjuzDvL99iu12PK3ho5cWK1LUS1sz+f9Uh5AZ6zMeA8X 2+lWmzUNOZbVVM2YeQ9F4f5rP8WM2ftmfFOM0B3XdTYKPJ4p7WXGyV7K2rE7673gsXnV 14Cf9GKtBoAagrOJUas8p4Hqy3Rzik2tAloRp2Hs6PkCHuyLa+haqQ7JZThG/5uKqDw+ 3FSQ== 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=2om/n6j/KN2TdtxPEqFhJaW70WBM2nI5WC5aQncvJV0=; b=R19yEkyx+YoAUnwrGQcMFvVVX48vimZa3fi/WoTe+X3KSlqBIHbVodyY/N9s92rvBo AtJfGzGMsh3MBB+bVS7Da3k04aodcgN5gMLDR2dLvpLG7BBeojKyk679CyC4uD5gBcOO UhxRGk/NxsSdlQHreMMc6nrNR3dsf+mubMgQFar7ws4Y45fLJQGvnqlqXQ22+ZqKmdUo iyC0/eygSi4N/tdICzgc1qHqevLYsq4i+jzhPrvJ2FMJJMUC23hfNg0FHxyitQXaQI5o bhXPt1UPnevDafA7Z+sHFD9ATqif7s0Ue7BBZRWXQVIiNZ4Gwx90L8px8FOa8Wd638qq CPJA== X-Gm-Message-State: AOAM533rrthXP1mIeC/fLwiRwhG62pZxrySKUDNps6XbPViaE7Jydrtk tWohFliLJL5aw5B1KuzQlwv1JtUM X-Google-Smtp-Source: ABdhPJzNerOYN9Do4YP5TfJx+zNt7p5YI/XAgAnO0IYKLeweCtQb6UJoF073i+1uCbVazmIC869ghQ== X-Received: by 2002:a9d:3a24:: with SMTP id j33mr2505701otc.271.1592317052511; Tue, 16 Jun 2020 07:17: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 g10sm4072699otn.34.2020.06.16.07.17.31 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jun 2020 07:17:31 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Subject: [PATCH 09/78] numa: properly check if numa is supported Date: Tue, 16 Jun 2020 09:14:38 -0500 Message-Id: <20200616141547.24664-10-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> References: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::336; envelope-from=flukshun@gmail.com; helo=mail-ot1-x336.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Igor Mammedov , qemu-stable@nongnu.org, Eduardo Habkost Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Igor Mammedov Commit aa57020774b, by mistake used MachineClass::numa_mem_supported to check if NUMA is supported by machine and also as unrelated change set it to true for sbsa-ref board. Luckily change didn't break machines that support NUMA, as the field is set to true for them. But the field is not intended for checking if NUMA is supported and will be flipped to false within this release for new machine types. Fix it: - by using previously used condition !mc->cpu_index_to_instance_props || !mc->get_default_cpu_node_id the first time and then use MachineState::numa_state down the road to check if NUMA is supported - dropping stray sbsa-ref chunk Fixes: aa57020774b690a22be72453b8e91c9b5a68c516 Signed-off-by: Igor Mammedov Message-Id: <1576154936-178362-3-git-send-email-imammedo@redhat.com> Signed-off-by: Eduardo Habkost (cherry picked from commit fcd3f2cc124600385dba46c69a80626985c15b50) Signed-off-by: Michael Roth --- hw/arm/sbsa-ref.c | 1 - hw/core/machine.c | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c index 27046cc284..c6261d44a4 100644 --- a/hw/arm/sbsa-ref.c +++ b/hw/arm/sbsa-ref.c @@ -791,7 +791,6 @@ static void sbsa_ref_class_init(ObjectClass *oc, void *data) mc->possible_cpu_arch_ids = sbsa_ref_possible_cpu_arch_ids; mc->cpu_index_to_instance_props = sbsa_ref_cpu_index_to_props; mc->get_default_cpu_node_id = sbsa_ref_get_default_cpu_node_id; - mc->numa_mem_supported = true; } static const TypeInfo sbsa_ref_info = { diff --git a/hw/core/machine.c b/hw/core/machine.c index 1689ad3bf8..aa63231f31 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -958,7 +958,7 @@ static void machine_initfn(Object *obj) NULL); } - if (mc->numa_mem_supported) { + if (mc->cpu_index_to_instance_props && mc->get_default_cpu_node_id) { ms->numa_state = g_new0(NumaState, 1); } @@ -1102,7 +1102,7 @@ void machine_run_board_init(MachineState *machine) { MachineClass *machine_class = MACHINE_GET_CLASS(machine); - if (machine_class->numa_mem_supported) { + if (machine->numa_state) { numa_complete_configuration(machine); if (machine->numa_state->num_nodes) { machine_numa_finish_cpu_init(machine); From patchwork Tue Jun 16 14:14:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 280358 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8B2AFC433E0 for ; Tue, 16 Jun 2020 14:19:48 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 52CFF20707 for ; Tue, 16 Jun 2020 14:19:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="pPKBkcN9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 52CFF20707 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:54376 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlCRH-0004D1-Ci for qemu-devel@archiver.kernel.org; Tue, 16 Jun 2020 10:19:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57192) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlCPE-00016p-5N; Tue, 16 Jun 2020 10:17:40 -0400 Received: from mail-oi1-x243.google.com ([2607:f8b0:4864:20::243]:46973) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jlCPC-0006XE-4E; Tue, 16 Jun 2020 10:17:39 -0400 Received: by mail-oi1-x243.google.com with SMTP id 25so19331761oiy.13; Tue, 16 Jun 2020 07:17: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=Oa9V802o+PKNgGwDm+Qufd06GDhvGLD8PaFrQvvJnXo=; b=pPKBkcN9VXNTxdWjT62sbbWXk3bR/ijQ7bpqv36i5g+tQaT3dF6iysnzpw3h3tTAGc WerjyMVdKhjB1ILkOo/RR8Zuq4OPdu+fPjYflJMnJCcs+nv9sTeSi8UBtOYHayV6menC ZQ/Ma1ipzKeAkiVZmHbYZII+8SR6ZN8NRUQ70H0xzQ5lmXUy+i6KqdNiVOj40ed0AtfM DPUj+5uTHympnhH5cPr/+NdNw4Pq5v3PmEBeGu/O3vhgC6Q2HXPpCWdo7SyErxh6kk9N HkbpLySXH15EWrbOpceFRCBAb81vx4ZtRzUvtWKUlSxmtQ4DPm9yN1MsHA7JbU5TNhbO GRnA== 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=Oa9V802o+PKNgGwDm+Qufd06GDhvGLD8PaFrQvvJnXo=; b=ehfl2s14+WNxaUOHAdz2o0xOgHeTzjsQCHqojCT/1Hf84u9a3B88pOZiW7rAirUrP7 bhW6lVWHr9QYk/Ip2nEanXfKkcEG7pCEktUPDTx+qbLDby83zAQZlRm8r/fWkaFO08S9 CFdszIHhSoMVs7uX9O0ZxFuKHtcqAnaslyku2kkE5OgI3TCRamSn7g63XGTnwEIHlJAi HGr3mzE0WrUtDjlxvUMrMPoke/cBn4UhkmtUImhxE4BOmxLzhGMlEJE2RY+CJ8nOzWN/ 71Ub2qzNsZMXqxFqZnAm1kwDKVm7Qz2ftLTIE2UiHlVoR/BBJI/xl3kOYKSEwIyAiOXA p4+w== X-Gm-Message-State: AOAM532IQuWOFDZnsXZPnwzd/wA4QRe2CexnpFZve/j23g9ghA7nWCI2 8H/Grig70zwQRdGeh3AStIeCIyj4 X-Google-Smtp-Source: ABdhPJx0bxk2406g7lFlhHW5g5/MKrysHiVPGT7MC6cu+nFQv3oCGGBGtcmwqBr81Qm8k6ahKblNEQ== X-Received: by 2002:aca:f0d:: with SMTP id 13mr3343149oip.90.1592317056370; Tue, 16 Jun 2020 07:17:36 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id w10sm4086944otp.44.2020.06.16.07.17.35 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jun 2020 07:17:35 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Subject: [PATCH 11/78] arm/arm-powerctl: set NSACR.{CP11, CP10} bits in arm_set_cpu_on() Date: Tue, 16 Jun 2020 09:14:40 -0500 Message-Id: <20200616141547.24664-12-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> References: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::243; envelope-from=flukshun@gmail.com; helo=mail-oi1-x243.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Niek Linnenbank , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Niek Linnenbank This change ensures that the FPU can be accessed in Non-Secure mode when the CPU core is reset using the arm_set_cpu_on() function call. The NSACR.{CP11,CP10} bits define the exception level required to access the FPU in Non-Secure mode. Without these bits set, the CPU will give an undefined exception trap on the first FPU access for the secondary cores under Linux. This is necessary because in this power-control codepath QEMU is effectively emulating a bit of EL3 firmware, and has to set the CPU up as the EL3 firmware would. Fixes: fc1120a7f5 Cc: qemu-stable@nongnu.org Signed-off-by: Niek Linnenbank [PMM: added clarifying para to commit message] Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell (cherry picked from commit 0c7f8c43daf6556078e51de98aa13f069e505985) Signed-off-by: Michael Roth --- target/arm/arm-powerctl.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/target/arm/arm-powerctl.c b/target/arm/arm-powerctl.c index f77a950db6..b064513d44 100644 --- a/target/arm/arm-powerctl.c +++ b/target/arm/arm-powerctl.c @@ -104,6 +104,9 @@ static void arm_set_cpu_on_async_work(CPUState *target_cpu_state, /* Processor is not in secure mode */ target_cpu->env.cp15.scr_el3 |= SCR_NS; + /* Set NSACR.{CP11,CP10} so NS can access the FPU */ + target_cpu->env.cp15.nsacr |= 3 << 10; + /* * If QEMU is providing the equivalent of EL3 firmware, then we need * to make sure a CPU targeting EL2 comes out of reset with a From patchwork Tue Jun 16 14:14:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 280356 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3E4BBC433DF for ; Tue, 16 Jun 2020 14:22:31 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1374620882 for ; Tue, 16 Jun 2020 14:22:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="s2Wyi+Wn" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1374620882 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:35908 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlCTu-0000VU-AM for qemu-devel@archiver.kernel.org; Tue, 16 Jun 2020 10:22:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57230) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlCPG-0001Dn-Hk; Tue, 16 Jun 2020 10:17:42 -0400 Received: from mail-oi1-x244.google.com ([2607:f8b0:4864:20::244]:38664) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jlCPF-0006Xl-1F; Tue, 16 Jun 2020 10:17:42 -0400 Received: by mail-oi1-x244.google.com with SMTP id c194so19393110oig.5; Tue, 16 Jun 2020 07:17: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=KqhqPuFMDL4mUgpQ50K5I58H+FHgkQzqbUQkl0uEKsM=; b=s2Wyi+WnL/7Lyhbv3mTGD6zBu+dEySqCGJvwWviwomJswetrt6plaqOqz94rV6k9jS gLMmT/07jJP5wdhrqFH9xadtqxWWIDl38xfLgYwfYfSaKSLQ6Ab5eQjH9nIhd1mYoZgm bNWqhqNJY2cZJhATU6W0iCYWfGruxjt9HwcWF6qGwr8oI/3ljANm4AHoz6uvo7APhb5c rC3sAVJ05n+xHlGwuE7mOxoCeG9/N0Wa33+fQI55Qwt3muhEZuxyWNnK/+wm2VXXwNnW AqMJN9Nivjq122YF6KfMpufuAT4214qqMxwTkQu2FXVTrc2gqAbf/ibWsBFwQ6/HBMT/ cXNQ== 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=KqhqPuFMDL4mUgpQ50K5I58H+FHgkQzqbUQkl0uEKsM=; b=bwc+EntRkiTkLKQyeTipThU/Ha4jt1xfNLp3/EJdPZJiI6Jywos/V3oVfE/EQXlnlr oXA2CpcD1bnZjhtaQwEQDXh6HJrQP/lcakqvRA+l2CP4AUwsCRJ9R4/Q3nclvjgsxlbW LPkCrW7z+Zk93IgwRIVD616JHHs0YZgiEUR5mPIjKyeaN/e+QBtVXz2pQfsddW8uKN7w tTGWLsdialFtbWSeeaALYPjWcJdAoBZmq0O0xW9bpa52B0sFmmX4d70+D4vtii2xAB1y qloH8zfaAON53H48JCqP4aWjombvfG8+F3ryZqzbsfw57zDvuOv3znU4CCwcEGMwt2KO dwdg== X-Gm-Message-State: AOAM531s/yyaBzmhcG/pBMv6IwA6o8ZDDNJDwkdfBiJ3mYBcbnGVQkdf AKlZMhHgbcmdSn1hs5hs+UHo/EDz X-Google-Smtp-Source: ABdhPJzWhPNIoYIBM3YwltT0TTfJLR/Y4BcCwdIi5LGieQum7sOfEV0iTaj/S1nzhllClS+RGZmLYQ== X-Received: by 2002:aca:2b0d:: with SMTP id i13mr3665510oik.39.1592317059203; Tue, 16 Jun 2020 07:17:39 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id m20sm4061387ots.13.2020.06.16.07.17.38 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jun 2020 07:17:38 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Subject: [PATCH 13/78] hw/i386/pc: fix regression in parsing vga cmdline parameter Date: Tue, 16 Jun 2020 09:14:42 -0500 Message-Id: <20200616141547.24664-14-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> References: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::244; envelope-from=flukshun@gmail.com; helo=mail-oi1-x244.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , qemu-stable@nongnu.org, Sergio Lopez , Peter Wu Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Peter Wu When the 'vga=' parameter is succeeded by another parameter, QEMU 4.2.0 would refuse to start with a rather cryptic message: $ qemu-system-x86_64 -kernel /boot/vmlinuz-linux -append 'vga=792 quiet' qemu: can't parse 'vga' parameter: Invalid argument It was not clear whether this applied to the '-vga std' parameter or the '-append' one. Fix the parsing regression and clarify the error. Fixes: 133ef074bd ("hw/i386/pc: replace use of strtol with qemu_strtoui in x86_load_linux()") Cc: Sergio Lopez Signed-off-by: Peter Wu Message-Id: <20191221162124.1159291-1-peter@lekensteyn.nl> Cc: qemu-stable@nongnu.org Signed-off-by: Paolo Bonzini (cherry picked from commit a88c40f02ace88f09b2a85a64831b277b2ebc88c) Signed-off-by: Michael Roth --- hw/i386/x86.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/i386/x86.c b/hw/i386/x86.c index 394edc2f72..121650ae51 100644 --- a/hw/i386/x86.c +++ b/hw/i386/x86.c @@ -508,6 +508,7 @@ void x86_load_linux(X86MachineState *x86ms, vmode = strstr(kernel_cmdline, "vga="); if (vmode) { unsigned int video_mode; + const char *end; int ret; /* skip "vga=" */ vmode += 4; @@ -518,10 +519,9 @@ void x86_load_linux(X86MachineState *x86ms, } else if (!strncmp(vmode, "ask", 3)) { video_mode = 0xfffd; } else { - ret = qemu_strtoui(vmode, NULL, 0, &video_mode); - if (ret != 0) { - fprintf(stderr, "qemu: can't parse 'vga' parameter: %s\n", - strerror(-ret)); + ret = qemu_strtoui(vmode, &end, 0, &video_mode); + if (ret != 0 || (*end && *end != ' ')) { + fprintf(stderr, "qemu: invalid 'vga=' kernel parameter.\n"); exit(1); } } From patchwork Tue Jun 16 14:14:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 280354 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 55780C433E0 for ; Tue, 16 Jun 2020 14:24:56 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1C644208B3 for ; Tue, 16 Jun 2020 14:24:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dPrqy5cm" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1C644208B3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:44524 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlCWF-0004PG-84 for qemu-devel@archiver.kernel.org; Tue, 16 Jun 2020 10:24:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57258) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlCPK-0001OE-H6; Tue, 16 Jun 2020 10:17:46 -0400 Received: from mail-ot1-x344.google.com ([2607:f8b0:4864:20::344]:42852) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jlCPJ-0006Yf-04; Tue, 16 Jun 2020 10:17:46 -0400 Received: by mail-ot1-x344.google.com with SMTP id t6so16019270otk.9; Tue, 16 Jun 2020 07:17: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=dMAfRKU6ZrmfHJJ6NFU2O1ZIHPVnAPeYIVisRHhIKSo=; b=dPrqy5cmgqkFGiQG0KkGp8VfQFtMmmSou/XG7IiWa4JQbqi3uTD8uDdCE+rCNSfZkW My6FhS3rAKb95Xv/R+6lp1ZVNc3hHF3EHLGtB8eHOQ+Nx5YQ29ETDcNdX73B8iVhSm99 vkoxrmEfKXpYE6MZLP4XjtC7ni96aq8xzUNtz62e9LU5g+AgIhUDv98b9Q9h5PK2tGVg 0s2A78Y/MCXdh2oHdZFRmK5+GfRBenT6UQ9D5eZ3jsip+vYJlqKfnToJqTrv9BpHczhW +dsLf+c573RiNKKVydqb1iHYxvz4qYvVXincLdRUatQLqXAW+9g3plM2L7b82B3ryyKQ YIHQ== 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=dMAfRKU6ZrmfHJJ6NFU2O1ZIHPVnAPeYIVisRHhIKSo=; b=lEOzOfZt0abx18cAZWl6GbXpwpeRJyNUIa5glmSJ0rT6v38wZMu1tmHq9TnCBQofxN IHAZjb84UpE97OvPp3eJmjnVItdbGW2zTXraWC4dyLHDzMum4VxvrhdwjVdm1zC7CLGd yKTHcqt2XvSjWScOzS8mg3UhDK7twGyMGKTdjYgh4rHkY71gVGFp0KSsAfY4/HnFuPJp T6sK71dpQ0vPg5nn9RmylP9RgGnwy67T4TgstjSjBbY+ToHwFagVbN5C7CwRHqhZaa1s +/XMO3+tKYCPfNURXu/ywHmMzIFcgqPPbsJPG8ixwhZjnhJs9rIzkTY4w/TFbKcFZeOD QWew== X-Gm-Message-State: AOAM533PrKigZqSZz+wzI6BrdOuSTDgL1hLpPygiiAKEYLOKaCm7ok2o Sctniw/p2zkyxHfihuC/xCiEb1si X-Google-Smtp-Source: ABdhPJw2DgVkrr9fUCpm1xZeHfL7DxNaacR+wGpHeBreNnujfPlxmexowp4agB1Erij1vp5A+lUGsw== X-Received: by 2002:a05:6830:1001:: with SMTP id a1mr2665125otp.94.1592317063048; Tue, 16 Jun 2020 07:17: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 r10sm3649071ooh.20.2020.06.16.07.17.41 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jun 2020 07:17:41 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Subject: [PATCH 15/78] ide: Fix incorrect handling of some PRDTs in ide_dma_cb() Date: Tue, 16 Jun 2020 09:14:44 -0500 Message-Id: <20200616141547.24664-16-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> References: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::344; envelope-from=flukshun@gmail.com; helo=mail-ot1-x344.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Snow , qemu-stable@nongnu.org, Alexander Popov Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Alexander Popov The commit a718978ed58a from July 2015 introduced the assertion which implies that the size of successful DMA transfers handled in ide_dma_cb() should be multiple of 512 (the size of a sector). But guest systems can initiate DMA transfers that don't fit this requirement. For fixing that let's check the number of bytes prepared for the transfer by the prepare_buf() handler. The code in ide_dma_cb() must behave according to the Programming Interface for Bus Master IDE Controller (Revision 1.0 5/16/94): 1. If PRDs specified a smaller size than the IDE transfer size, then the Interrupt and Active bits in the Controller status register are not set (Error Condition). 2. If the size of the physical memory regions was equal to the IDE device transfer size, the Interrupt bit in the Controller status register is set to 1, Active bit is set to 0. 3. If PRDs specified a larger size than the IDE transfer size, the Interrupt and Active bits in the Controller status register are both set to 1. Signed-off-by: Alexander Popov Reviewed-by: Kevin Wolf Message-id: 20191223175117.508990-2-alex.popov@linux.com Signed-off-by: John Snow (cherry picked from commit ed78352a59ea7acf7520d4d47a96b9911bae7fc3) Signed-off-by: Michael Roth --- hw/ide/core.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/hw/ide/core.c b/hw/ide/core.c index 754ff4dc34..80000eb766 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -849,6 +849,7 @@ static void ide_dma_cb(void *opaque, int ret) int64_t sector_num; uint64_t offset; bool stay_active = false; + int32_t prep_size = 0; if (ret == -EINVAL) { ide_dma_error(s); @@ -863,13 +864,15 @@ static void ide_dma_cb(void *opaque, int ret) } } - n = s->io_buffer_size >> 9; - if (n > s->nsector) { - /* The PRDs were longer than needed for this request. Shorten them so - * we don't get a negative remainder. The Active bit must remain set - * after the request completes. */ + if (s->io_buffer_size > s->nsector * 512) { + /* + * The PRDs were longer than needed for this request. + * The Active bit must remain set after the request completes. + */ n = s->nsector; stay_active = true; + } else { + n = s->io_buffer_size >> 9; } sector_num = ide_get_sector(s); @@ -892,9 +895,20 @@ static void ide_dma_cb(void *opaque, int ret) n = s->nsector; s->io_buffer_index = 0; s->io_buffer_size = n * 512; - if (s->bus->dma->ops->prepare_buf(s->bus->dma, s->io_buffer_size) < 512) { - /* The PRDs were too short. Reset the Active bit, but don't raise an - * interrupt. */ + prep_size = s->bus->dma->ops->prepare_buf(s->bus->dma, s->io_buffer_size); + /* prepare_buf() must succeed and respect the limit */ + assert(prep_size >= 0 && prep_size <= n * 512); + + /* + * Now prep_size stores the number of bytes in the sglist, and + * s->io_buffer_size stores the number of bytes described by the PRDs. + */ + + if (prep_size < n * 512) { + /* + * The PRDs are too short for this request. Error condition! + * Reset the Active bit and don't raise the interrupt. + */ s->status = READY_STAT | SEEK_STAT; dma_buf_commit(s, 0); goto eot; From patchwork Tue Jun 16 14:14:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 188042 Delivered-To: patch@linaro.org Received: by 2002:a92:cf06:0:0:0:0:0 with SMTP id c6csp3700914ilo; Tue, 16 Jun 2020 07:26:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxgTYNkF9cc1z/w/1+A4K9tjMFHda1R1ajZnU863iY0aUATiqGgH2YGqcJicUxyJ91D+9Oc X-Received: by 2002:a25:3055:: with SMTP id w82mr4806043ybw.21.1592317573297; Tue, 16 Jun 2020 07:26:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592317573; cv=none; d=google.com; s=arc-20160816; b=Gc1DhtjqUxS8lCdKe9yciS1HP5EXk4y+HUI0cTB1/llY0IoIY3RxUpogcex6l3syra lHY2W7QhBj5rJOa6Bg5uOZw4eALmAxqVWCwmEZp6OTVxjp8EOpTZ7AIA9busvai5tah/ +jOO9H23uV4nppBVBRUXbxH4V+3M29NEAo73kQCFhZUR9kwOHQ22L0hE97MXwUFhaOGT jn0c/Q5F+On7Xx2IpnnkDXgJeBX7D/7SzZXRsJDHObqRg3gvZ70d2zcwJ0gWAXV1r3Wi Ixo+sRfRnjUDDeEHkWpFzFVDx4Gczt2XiIX0Ua0pdJE1BIAw4odU5VVWs4VgPqhWRUe7 7kPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:references:in-reply-to :message-id:date:subject:to:from:dkim-signature; bh=bFiVQnw2jG4LqsuDKjNy6cYrD1dF4NUODorK7JaUXfs=; b=hTXTEm5h4XCoCOcEjp0eNz1bNKTTcwGmBq/ei12b3b70QVDEOTo72ttfnd45uI1zUm t1d8qXzjYfWiPj/mLzoEA9oPUZufi43sqg//dH+Zrz6BmVU5uMk7yZPhGcc+oo8zDvOq TtF/GgN2myfagRP18NEtvk2wiRXW5Dv9EHWkqgWlD/CHW9RkcEjMTC+UoNqsIzIeP8eQ pQ/3yCttsju9fAS8VLh0My3KTPPB4d4M9jmhusNHvZarzSa+hKVWUTJfpbW8urTu9sRc J+YuykMwq0CxR22pR6ycvobLQIhg+vNMjp8c7hQOjtslmOOeH/xQH0ohPk6AUUAchXae r1Gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=YC68vXMa; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id o18si16645058yba.318.2020.06.16.07.26.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jun 2020 07:26:13 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=YC68vXMa; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from localhost ([::1]:47294 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlCXU-0005YT-Jr for patch@linaro.org; Tue, 16 Jun 2020 10:26:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57274) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlCPM-0001Sg-8b; Tue, 16 Jun 2020 10:17:48 -0400 Received: from mail-oi1-x243.google.com ([2607:f8b0:4864:20::243]:38664) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jlCPK-0006Yr-MF; Tue, 16 Jun 2020 10:17:47 -0400 Received: by mail-oi1-x243.google.com with SMTP id c194so19393377oig.5; Tue, 16 Jun 2020 07:17:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=bFiVQnw2jG4LqsuDKjNy6cYrD1dF4NUODorK7JaUXfs=; b=YC68vXMa940Bx/AMnFsl6CsrC69kIKc3PjyW3Uuqz4nRg2ApKFY1kCxAL3J+CXiDx0 ZjWwzKMSWsRLfkuLhHrV7mHa5KHAwQeHaZtWGIlVuO8VxO4mC5AUJy8Oxkd5ttdvRvti 4MrLtMEoR01V6LZ1ESiAyKz5cTSemwvE4pcOj/7W8ovEjSMK0mFnvloErhdDmoKQ8Cng rwbTuON8ugWO6NNQM+48b7Xpx+MlzCKrmtsoAZUkWbazLzt3WeJbyvLIhQQt4T5Fgy8b gXAvnEdx5Q0GjI7Y1vTHY3QZf1khGkVpqtZJHj8WgDK4E6fpkcMtz0hUsf/QkW29x7n7 rr8g== 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=bFiVQnw2jG4LqsuDKjNy6cYrD1dF4NUODorK7JaUXfs=; b=KZDRCcq8m3OyLPggNf55gejCDVI7exlhMBhT4a+l9OJ+xWl/3SPtSlyTXZ+W/CWK5D k8Vs5TX4kBiWQ15yD6T9L6+l0jrax6DbfqHiyQIOAWI+8PlIAcshfi8i6tcikmUx3Qtf iRMKuuHmSL30PFRErt83x7kbPRar1pN6zs4M80HFMk495weSrHj2ffFjVxtS1cm86uCk mVoB1YRO9nVsfHKwDq5vjgU4sFLRb55GwO4DTF26Rwwu6fAjNnYKcZWZ6EkFSg6pn3uZ /ARNRvw9oWhTKiNooy66cBiyaCaGqImtpSe87zCdbvxadt6lPmxQWUVFaNwfXOp02jwT QV+Q== X-Gm-Message-State: AOAM533WqPDlDnGBJGjfWn1t3tslcn4aiI+CA8tYhxEpF1QsgWoCg9I9 Q8RQfL9pC+ZWf4FOG8wkLJ8VBgAX X-Received: by 2002:aca:d956:: with SMTP id q83mr3400237oig.78.1592317064963; Tue, 16 Jun 2020 07:17: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 v14sm4171856oie.20.2020.06.16.07.17.43 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jun 2020 07:17:43 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Subject: [PATCH 16/78] target/arm: Set ISSIs16Bit in make_issinfo Date: Tue, 16 Jun 2020 09:14:45 -0500 Message-Id: <20200616141547.24664-17-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> References: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::243; envelope-from=flukshun@gmail.com; helo=mail-oi1-x243.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson During the conversion to decodetree, the setting of ISSIs16Bit got lost. This causes the guest os to incorrectly adjust trapping memory operations. Cc: qemu-stable@nongnu.org Fixes: 46beb58efbb8a2a32 ("target/arm: Convert T16, load (literal)") Reported-by: Jeff Kubascik Signed-off-by: Richard Henderson Message-id: 20200117004618.2742-3-richard.henderson@linaro.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell (cherry picked from commit 1a1fbc6cbb34c26d43d8360c66c1d21681af14a9) Signed-off-by: Michael Roth --- target/arm/translate.c | 3 +++ 1 file changed, 3 insertions(+) -- 2.17.1 diff --git a/target/arm/translate.c b/target/arm/translate.c index 83aa331b1e..ad052a2abd 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -8556,6 +8556,9 @@ static ISSInfo make_issinfo(DisasContext *s, int rd, bool p, bool w) /* ISS not valid if writeback */ if (p && !w) { ret = rd; + if (s->base.pc_next - s->pc_curr == 2) { + ret |= ISSIs16Bit; + } } else { ret = ISSInvalid; } From patchwork Tue Jun 16 14:14:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 280352 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 76327C433DF for ; Tue, 16 Jun 2020 14:27:23 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4529A20786 for ; Tue, 16 Jun 2020 14:27:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kBLc7qb9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4529A20786 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:53094 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlCYc-0007ww-Ds for qemu-devel@archiver.kernel.org; Tue, 16 Jun 2020 10:27:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57304) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlCPN-0001YN-Sm; Tue, 16 Jun 2020 10:17:49 -0400 Received: from mail-ot1-x341.google.com ([2607:f8b0:4864:20::341]:38304) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jlCPM-0006ZD-Cc; Tue, 16 Jun 2020 10:17:49 -0400 Received: by mail-ot1-x341.google.com with SMTP id n70so16043119ota.5; Tue, 16 Jun 2020 07:17: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=R9xeBRc60+ORME3XWT914n4d4tIF833r1AL2yrH3GfE=; b=kBLc7qb9Bf8gIGE0trLD7hJLK+x7YDhzlNVA7Lmv8zVHGLZ3ui/0EyNPlSos6psLSE jD/S955GOvKyahhdk9L4WM7DG5FF8wWoZhy7FWLp1RFG9Hv2iHmJpqdBIUchwRLaFqIU hcyc+Lrd5gVo7q+Sggv2O6g65Z8pUUvZNOfpEKIpLvfkNnN5HoKAFe1JzNlGFEGEHGUM QrhwSSrtV3GCPyBDgVeHw3zAj4XK1KqY1FHIIDx0ghSsP6BKvBe+uX9HV/1NTXuhQ5Jz 9NNEnJEVH1ELIFM7p6M2oe5hgdkEG0kqJZZ0+AJtpL83mpFf0mMTMuFHZ95g0Qm6SbEk 01ig== 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=R9xeBRc60+ORME3XWT914n4d4tIF833r1AL2yrH3GfE=; b=gm/01BDP4fDF+s6kvQWEkbVz9Aec6Nt+dCHd0aPEg12ZbV7rUeJXujoOcVN6H1eVJV ebrfuyIp8wzSOq1zBBTIR5LwnwMVX4Mfmcat+JBV32wad5StYWaZk1+1Rk8bnTllPXah b6W4GC54WtlCsTJyTWBrvRDtrBW/o8yQCL41wKWjIJU5vXLWk+h8HYe00HaZbP06ugg3 DLfjXVavmnefdmpK8qorZIQUHku9wolmBJljyle7USsBABXWn/c9UwzWV8e8+QZW2paN hGgr93SaYbUOawZil9gomThgz9dFAZYoKOmHrLPRp3o8EB88YQfcWf6Gyx9+c2WrWbMG Tefg== X-Gm-Message-State: AOAM533kWydafIqEBCAPDYI5eFf8uL6wbSHK2CgsUirMgcihgg3KuIYE hP/L46mTAWvpQ9Gged3rsspumOgV X-Google-Smtp-Source: ABdhPJzawZm3yjs02HwVJxdnwrJ2S0f/Awx260571nMpMwTONpYUbauMbYQrMLmX6vYrM1MKt/Culg== X-Received: by 2002:a9d:7457:: with SMTP id p23mr2518680otk.138.1592317066502; Tue, 16 Jun 2020 07:17:46 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id a9sm2827543oon.38.2020.06.16.07.17.45 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jun 2020 07:17:45 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Subject: [PATCH 17/78] virtio: update queue size on guest write Date: Tue, 16 Jun 2020 09:14:46 -0500 Message-Id: <20200616141547.24664-18-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> References: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::341; envelope-from=flukshun@gmail.com; helo=mail-ot1-x341.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-stable@nongnu.org, "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: "Michael S. Tsirkin" Some guests read back queue size after writing it. Update the size immediatly upon write otherwise they get confused. In particular this is the case for seabios. Reported-by: Roman Kagan Suggested-by: Denis Plotnikov Cc: qemu-stable@nongnu.org Signed-off-by: Michael S. Tsirkin (cherry picked from commit d0c5f643383b9e84316f148affff368ac33d75b9) Signed-off-by: Michael Roth --- hw/virtio/virtio-pci.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index c6b47a9c73..e5c759e19e 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1256,6 +1256,8 @@ static void virtio_pci_common_write(void *opaque, hwaddr addr, break; case VIRTIO_PCI_COMMON_Q_SIZE: proxy->vqs[vdev->queue_sel].num = val; + virtio_queue_set_num(vdev, vdev->queue_sel, + proxy->vqs[vdev->queue_sel].num); break; case VIRTIO_PCI_COMMON_Q_MSIX: msix_vector_unuse(&proxy->pci_dev, From patchwork Tue Jun 16 14:14:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 280351 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C525AC433E0 for ; Tue, 16 Jun 2020 14:28:47 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9971C20786 for ; Tue, 16 Jun 2020 14:28:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="digWy/xa" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9971C20786 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:32934 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlCZy-00037h-R7 for qemu-devel@archiver.kernel.org; Tue, 16 Jun 2020 10:28:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57348) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlCPR-0001hN-1E; Tue, 16 Jun 2020 10:17:53 -0400 Received: from mail-ot1-x341.google.com ([2607:f8b0:4864:20::341]:43053) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jlCPP-0006aE-GZ; Tue, 16 Jun 2020 10:17:52 -0400 Received: by mail-ot1-x341.google.com with SMTP id u23so16054958otq.10; Tue, 16 Jun 2020 07:17:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=EO7pUhlzm0oZLNOP4SxgQUagDG4s3W5EaxNKZcENM6A=; b=digWy/xaSI0RgYIlNNAZE0ngwT+2nfXgaL3nZ7q4aeVdjht7KXJvDw3SNYK/ZzF2y4 ScbQ73N0AT4P5es9J/D7Kk6qZtZ5VObzlHuh54mXMvqKqcEZMTGlXmcxWKw40ct4K6M7 emmGFQyR02a4D+RQvYm2ikEutwtu40f8HlLwSgDHJk90EFLPwvSqSUhUsSzuUg2iDE5/ C+ueAnd0BuMn+uI0FkXlFW8m5KemFIgxumB0Avw309hLGRJXggJVtryxt25yHt+8+AeL s5OnQ6lqinEhFS+VE35CxB+aUbAdPZU9d3fiykeHpIQSmMlCqCmVrGNPhaLb16VLjaxf 0jtw== 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=EO7pUhlzm0oZLNOP4SxgQUagDG4s3W5EaxNKZcENM6A=; b=udHXXNLdxrY5FG869nOBHtXGxUGtCBcdqwXx9An3KdLle51gtOHmNu2PN+m0n0znG1 /ntZ09EtHzLgsQh4JdxDt7Q6O8svC9EQNDo52kF5HqSwaIOvg0OtsobyfSRJ9s52ks43 COPZ4AyMLdwLk30cech/ZKVvdJ+uPATs9B54hq82+5Nxp/QS6lQTUV/FXUfqW8ELLrCb rjHiwai4nf4Htxp/3EYAm+5pb8M6nOiFqwOuMQXg1SWgSRrhd4HXxHZbLau+wOaTq+6X Hn92TNv1HXXcktowRC4ARDb2/itMyQRSJYzeefOg/K5VDZG43tmvl0vEg9YeUjTW4oZm 0tOA== X-Gm-Message-State: AOAM531jVeVLbfwuMWJY85cacN6h1sfC3JtrX3aBQ2s6a6+AMIu45eWr 6WZ40LBdRTPMi2iGbIia8uZ+fKRR X-Google-Smtp-Source: ABdhPJzoo/1kBILNkuoqEbECjuO83AGa8gq6fOuZLgHBNAXMBpVNtYaBAiPtRI7qkYad6/VTwAeLtw== X-Received: by 2002:a9d:730c:: with SMTP id e12mr2599634otk.8.1592317069709; Tue, 16 Jun 2020 07:17:49 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id x1sm1535173oop.44.2020.06.16.07.17.48 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jun 2020 07:17:48 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Subject: [PATCH 19/78] virtio: add ability to delete vq through a pointer Date: Tue, 16 Jun 2020 09:14:48 -0500 Message-Id: <20200616141547.24664-20-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> References: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::341; envelope-from=flukshun@gmail.com; helo=mail-ot1-x341.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-stable@nongnu.org, "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: "Michael S. Tsirkin" Devices tend to maintain vq pointers, allow deleting them trough a vq pointer. Signed-off-by: Michael S. Tsirkin Reviewed-by: David Hildenbrand Reviewed-by: David Hildenbrand (cherry picked from commit 722f8c51d8af223751dfb1d02de40043e8ba067e) *prereq for 421afd2fe8 Signed-off-by: Michael Roth --- hw/virtio/virtio.c | 15 ++++++++++----- include/hw/virtio/virtio.h | 2 ++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 04716b5f6c..31dd140990 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -2330,17 +2330,22 @@ VirtQueue *virtio_add_queue(VirtIODevice *vdev, int queue_size, return &vdev->vq[i]; } +void virtio_delete_queue(VirtQueue *vq) +{ + vq->vring.num = 0; + vq->vring.num_default = 0; + vq->handle_output = NULL; + vq->handle_aio_output = NULL; + g_free(vq->used_elems); +} + void virtio_del_queue(VirtIODevice *vdev, int n) { if (n < 0 || n >= VIRTIO_QUEUE_MAX) { abort(); } - vdev->vq[n].vring.num = 0; - vdev->vq[n].vring.num_default = 0; - vdev->vq[n].handle_output = NULL; - vdev->vq[n].handle_aio_output = NULL; - g_free(vdev->vq[n].used_elems); + virtio_delete_queue(&vdev->vq[n]); } static void virtio_set_isr(VirtIODevice *vdev, int value) diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index c32a815303..e18756d50d 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -183,6 +183,8 @@ VirtQueue *virtio_add_queue(VirtIODevice *vdev, int queue_size, void virtio_del_queue(VirtIODevice *vdev, int n); +void virtio_delete_queue(VirtQueue *vq); + void virtqueue_push(VirtQueue *vq, const VirtQueueElement *elem, unsigned int len); void virtqueue_flush(VirtQueue *vq, unsigned int count); From patchwork Tue Jun 16 14:14:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 280349 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 416E7C433DF for ; Tue, 16 Jun 2020 14:30:50 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0C6F420786 for ; Tue, 16 Jun 2020 14:30:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hV+qhLYV" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0C6F420786 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:41606 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlCbx-0006jH-5i for qemu-devel@archiver.kernel.org; Tue, 16 Jun 2020 10:30:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57420) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlCPW-0001vP-3L; Tue, 16 Jun 2020 10:17:58 -0400 Received: from mail-oi1-x236.google.com ([2607:f8b0:4864:20::236]:39414) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jlCPU-0006bN-9v; Tue, 16 Jun 2020 10:17:57 -0400 Received: by mail-oi1-x236.google.com with SMTP id d67so19349711oig.6; Tue, 16 Jun 2020 07:17: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=Q95hS3J40RCSoOEE5dlvFtYnyG3elf6x2RtaTUYv91A=; b=hV+qhLYVCwxGxaUe+OPMnAAyjIuQ19Rc9GGTZj7um2ONSqRRZ3eOt4hZd2XjmoXBCW PyLw6f1Zqm6RgJvb3O1cMwZ4hoM0oYdNGweD30hsEoosRHpxZIBoXS29eO/xrO+1qCIW PK7waDd0GnhMGhJ6B1gca9tI+u9vu0aFtxt83mWM8C05KJ1bZHWPWfmOexdZgHULBP+S NbpeRpJT+U1UaN4LzdcuPYX63GqSxBAkCFnYJVBoqha5s/3n0brQNnnIyNx50XxNfJNI ObkKQshNz8+uDXEg962KwnM4KEtaa4darxkiTqMRDIzPNxPpy/ohnCeaOZhWinwVKX7z U0Vg== 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=Q95hS3J40RCSoOEE5dlvFtYnyG3elf6x2RtaTUYv91A=; b=PiXY8Z9gRUkQeN8f5CpbN/nZE2liZjeSDjxIlLLMQPxeHqty2ysACGNY/Eciz6LXaN +/3r4Ll5GTUr7dRxbcSpn0mIT5Uf4qXnmwuokW7P3e/7C04oSlw6dPfqa2ifDJ0SpeVu fyGQ8iFXSPWMWmQKLqYEla4TE/Sx3KLaL1GGkePD1dfBxTz/sBJsJQDxT4Yc6j0KICxz rNoupncxMNEgEDnUeQVbQpZAuE3Db540PP7pmUg1ZxZpmfuBbSLAzCkMTLVaWCFjDrEj No/Zc4PEthQhsC313Sg4I0KcewmFcwJaXhLhKswN3K8R81LBfi8N2SzVu3BmSduNr5cJ MEGg== X-Gm-Message-State: AOAM5321IcGNznS7MqxbxMhhxtyhPiUXAx1+fZObL+X++lykAsk/ZXlG JgaLESkeb9BKEbZeb41KRAceqs3b X-Google-Smtp-Source: ABdhPJyN7T3b11wfLV+3qdP/dNuteuyTMH9TXoHEvXc4mgKL7zoWrgUUNsEVn9Ezq52NieeWicQpfw== X-Received: by 2002:aca:df04:: with SMTP id w4mr3458946oig.27.1592317074303; Tue, 16 Jun 2020 07:17: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 e188sm4349186oib.18.2020.06.16.07.17.52 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jun 2020 07:17:53 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Subject: [PATCH 21/78] virtio: reset region cache when on queue deletion Date: Tue, 16 Jun 2020 09:14:50 -0500 Message-Id: <20200616141547.24664-22-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> References: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::236; envelope-from=flukshun@gmail.com; helo=mail-oi1-x236.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yuri Benditovich , qemu-stable@nongnu.org, "Michael S . Tsirkin" Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Yuri Benditovich https://bugzilla.redhat.com/show_bug.cgi?id=1708480 Fix leak of region reference that prevents complete device deletion on hot unplug. Cc: qemu-stable@nongnu.org Signed-off-by: Yuri Benditovich Message-Id: <20191226043649.14481-2-yuri.benditovich@daynix.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin (cherry picked from commit 421afd2fe8dd4603216cbf36081877c391f5a2a4) Signed-off-by: Michael Roth --- hw/virtio/virtio.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 6de3cfdc2c..344d817644 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -2338,6 +2338,7 @@ void virtio_delete_queue(VirtQueue *vq) vq->handle_aio_output = NULL; g_free(vq->used_elems); vq->used_elems = NULL; + virtio_virtqueue_reset_region_cache(vq); } void virtio_del_queue(VirtIODevice *vdev, int n) From patchwork Tue Jun 16 14:14:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 280353 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 919A3C433DF for ; Tue, 16 Jun 2020 14:26:10 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 57D1D20786 for ; Tue, 16 Jun 2020 14:26:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="sPA1VA0h" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 57D1D20786 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:49266 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlCXR-0006Nv-Il for qemu-devel@archiver.kernel.org; Tue, 16 Jun 2020 10:26:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57444) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlCPX-00020L-PJ; Tue, 16 Jun 2020 10:17:59 -0400 Received: from mail-oo1-xc44.google.com ([2607:f8b0:4864:20::c44]:43353) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jlCPW-0006cp-6E; Tue, 16 Jun 2020 10:17:59 -0400 Received: by mail-oo1-xc44.google.com with SMTP id i4so1364902ooj.10; Tue, 16 Jun 2020 07:17: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=+5a+vrjSxlfmXcIjNg9VjuuOpfEW7OK8MY8Z5fA99eo=; b=sPA1VA0hWfjbJh5OVahjWiOFCpBsweGKurk81lYML8fTMG9EqEQeKfjt5BRwaSxdGy 4+Ftv2gG7nEOuQi3G/QwVQAwJIQ5OIZ+WJjw+35dIe3DmOwsrGpB+igA++7HlSNRb7ve o4eqZ/hTlChvboKFmV0loYhu+eOEuFiW/8DMkLPzamCNHCIasWky1zCWINSInOj9p0Bg OJ3T3Sc2CfZuaidczMh/sg03BzTeYIYYzoCCZx1NHTr4uz7RUwKwMChSlLU4J2sV6agx Zwek1irSjFj1hicMR70fnOHf90w2IxP0yHPg+Sf7A2399AtvAHBRaddPbO+iN4aehGqB zG1Q== 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=+5a+vrjSxlfmXcIjNg9VjuuOpfEW7OK8MY8Z5fA99eo=; b=Wsq4MTAQa9FqyQL7kkb3IcJKdp2WFbFgAXmzcUMUFmVp6ix5pl1oI50ht8WZqxyejk 1tCWDexwu1jja7X/CoUWZ22Pc9nW0WB3NskUTOjtUb8dUny5xb8iZnX4ItQkCFQu+cCI HUfAB9tNG5xBH6u2DuAEeZKH+YWyTt1HMXux6OkCHFNNoEiGDA7KjEH8micBKAlg5f3M cLaIOqphXnpacBdLBvqWXGqZ1jqmFUP2hna6LSAcf6WQYWsjVlQQj5612KJs9rQtOgyp e807omMi6N5bn2Kp5FR/QvsjCW9oMjHYfIXCatsUyt+u7SHwByxFGN1Ilh+sn2R7OLe2 MNEg== X-Gm-Message-State: AOAM530c3a2D0/G5l+20mUvRJtvBrAcJLkO+mDwW2Ie853bV9CaOGXVb 7aUHjj08AIXIO5WaORzdnmjYZmFy X-Google-Smtp-Source: ABdhPJxCKOJd4jeIeoNJCAOFoEMCjZpomM33u7iDdmXSk6iF42Tt8V7yVHwtIlZKhNVKFmERcGWBng== X-Received: by 2002:a4a:5585:: with SMTP id e127mr2467360oob.47.1592317075859; Tue, 16 Jun 2020 07:17: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 n10sm4134197oib.49.2020.06.16.07.17.54 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jun 2020 07:17:55 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Subject: [PATCH 22/78] virtio-net: delete also control queue when TX/RX deleted Date: Tue, 16 Jun 2020 09:14:51 -0500 Message-Id: <20200616141547.24664-23-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> References: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::c44; envelope-from=flukshun@gmail.com; helo=mail-oo1-xc44.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yuri Benditovich , qemu-stable@nongnu.org, "Michael S . Tsirkin" Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Yuri Benditovich https://bugzilla.redhat.com/show_bug.cgi?id=1708480 If the control queue is not deleted together with TX/RX, it later will be ignored in freeing cache resources and hot unplug will not be completed. Cc: qemu-stable@nongnu.org Signed-off-by: Yuri Benditovich Message-Id: <20191226043649.14481-3-yuri.benditovich@daynix.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin (cherry picked from commit d945d9f1731244ef341f74ede93120fc9de35913) Signed-off-by: Michael Roth --- hw/net/virtio-net.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index db3d7c38e6..f325440d01 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3101,7 +3101,8 @@ static void virtio_net_device_unrealize(DeviceState *dev, Error **errp) for (i = 0; i < max_queues; i++) { virtio_net_del_queue(n, i); } - + /* delete also control vq */ + virtio_del_queue(vdev, max_queues * 2); qemu_announce_timer_del(&n->announce_timer, false); g_free(n->vqs); qemu_del_nic(n->nic); From patchwork Tue Jun 16 14:14:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 280350 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 21F17C433DF for ; Tue, 16 Jun 2020 14:29:42 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EB40420786 for ; Tue, 16 Jun 2020 14:29:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Fa65ZW/H" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EB40420786 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:37382 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlCar-0004w9-5N for qemu-devel@archiver.kernel.org; Tue, 16 Jun 2020 10:29:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57446) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlCPY-00020e-2j; Tue, 16 Jun 2020 10:18:01 -0400 Received: from mail-oi1-x242.google.com ([2607:f8b0:4864:20::242]:39699) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jlCPW-0006ct-Jc; Tue, 16 Jun 2020 10:17:59 -0400 Received: by mail-oi1-x242.google.com with SMTP id d67so19349814oig.6; Tue, 16 Jun 2020 07:17: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=mm6Vzeu6v4Wn/c8RqfvMPXPL7u7lWwdQ4IQrVXI00+I=; b=Fa65ZW/HIlqMjjHRO84ugLMbA76D7/zKO5Bom9gEvwMOSfD+Je57sdDMPZs3BJyd7u LKlIBHqAQZ/GbX5Ug56KQu1F/pnhNvZmg+DNqpm5Z5NioN/vaRcZzPjCC54t9qixuYXF DC3EeXlzfRQg1yfiyuNu0gvMc/3yJU353AB8g659McpF/u6Xj9HiwwLF6lLDxLK2N1E9 nLdE5U6DPo6StI710iRX5BbRifLCCrSY0us23fSW2rrp0aTgoCFUnMGPZxpZAsTOVyS8 Hg4Kbm27xJ2GSoiP/jsXXcdXqbt/bFS1qrXFxRcsjN/U35VPAOCYQl1t9sRn1XjzIjPI c8Pw== 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=mm6Vzeu6v4Wn/c8RqfvMPXPL7u7lWwdQ4IQrVXI00+I=; b=YjqT7QBSJLc4dj6bw5+xJDGMRj6/Gx0QylChMEnERqhSSvvXcmyYQMywHEnAH9x9Ut 1jnzPHs3arM1A9w57eq9SMVT2DK0ubrVJDrrs1miGG/ZwpwdPnVwjXNCoEAIgLWOF9T1 HQp6fxI+fyvr7oh4/8Z/fg1ZQzQ9TSme2h+q6wYHlub9Ts7UXMA3Vg3HD5Eh7lC2rh5Z ezfU4fKpmKN0dTPWI91nK1N1XchGARqAFE3drBTjHvch1uBGh+g+IOFR2n6aTDNVizki t3ZrAFsPHZJV15uE+G8jj1nX2uX9Nbq5x/envwi9sTP2Dyjsk5xRzApYylNeQyVqVCh6 fGUA== X-Gm-Message-State: AOAM530w2hzEzaIOVJHjUOCWSeB7DtUDGlNLyrI/D+wtAF5d9eG62kli bwkrkdFu4nCaIlRCAQB3OWnYhptm X-Google-Smtp-Source: ABdhPJymWhxwiBRQHRpVsZqSB3GBhki+JIzheCMvbmzjKIPTLeVNCghC+7AuTKU8R0zfI2LfizfEeg== X-Received: by 2002:aca:4e0c:: with SMTP id c12mr3482764oib.145.1592317076892; Tue, 16 Jun 2020 07:17: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 g51sm4041470otg.17.2020.06.16.07.17.56 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jun 2020 07:17:56 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Subject: [PATCH 23/78] intel_iommu: a fix to vtd_find_as_from_bus_num() Date: Tue, 16 Jun 2020 09:14:52 -0500 Message-Id: <20200616141547.24664-24-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> References: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::242; envelope-from=flukshun@gmail.com; helo=mail-oi1-x242.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Tian , Jacob Pan , Yi Sun , "Michael S . Tsirkin" , qemu-stable@nongnu.org, Peter Xu , Liu Yi L Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Liu Yi L Ensure the return value of vtd_find_as_from_bus_num() is NULL by enforcing vtd_bus=NULL. This would help caller of vtd_find_as_from_bus_num() to decide if any further operation on the returned vtd_bus. Cc: qemu-stable@nongnu.org Cc: Kevin Tian Cc: Jacob Pan Cc: Peter Xu Cc: Yi Sun Signed-off-by: Liu Yi L Signed-off-by: Yi Sun Message-Id: <1578058086-4288-2-git-send-email-yi.l.liu@intel.com> Reviewed-by: Peter Xu Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin (cherry picked from commit a2e1cd41ccfe796529abfd1b6aeb1dd4393762a2) Signed-off-by: Michael Roth --- hw/i386/intel_iommu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 43c94b993b..00ebae4863 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -948,6 +948,7 @@ static VTDBus *vtd_find_as_from_bus_num(IntelIOMMUState *s, uint8_t bus_num) return vtd_bus; } } + vtd_bus = NULL; } return vtd_bus; } From patchwork Tue Jun 16 14:14:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 280348 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2284DC433DF for ; Tue, 16 Jun 2020 14:32:09 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E9E06208D5 for ; Tue, 16 Jun 2020 14:32:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="u5aeK+Pm" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E9E06208D5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:45966 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlCdE-0008VF-5U for qemu-devel@archiver.kernel.org; Tue, 16 Jun 2020 10:32:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57476) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlCPb-00021m-7V; Tue, 16 Jun 2020 10:18:04 -0400 Received: from mail-ot1-x32b.google.com ([2607:f8b0:4864:20::32b]:40778) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jlCPY-0006d8-0K; Tue, 16 Jun 2020 10:18:02 -0400 Received: by mail-ot1-x32b.google.com with SMTP id s13so16031640otd.7; Tue, 16 Jun 2020 07:17: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=MMeIQIaUT9cFLFVfOZAfkWHwj7aINzLWQ4+zAStdY7k=; b=u5aeK+PmjI9Gh6dreGsRPcHI3c5ubwISbKAmqwykBXANPcUkOun2bcjWcOet6y8M6V 8iSsqC63b1wKEZmX3AA1SwinCY70Miv6tUsFPDpDqPVFYPfU2ax88gpUuIjqG6gtuWTY YFRXWVdm/HYMxI/c9kmD+MpuLtz+WMkTPA5lxO6zwkO3hZghXMXTCTpufe5A21lIsQJC i1577QENYx1OTzlImWQsn7NoWPY65SZQR568o3pBHnJyI+t3+E3L0Qs7x755afFDWyOy 1G+VGGNyFFFEkqJ7VComtmF9i+WUixvwQmk+fXH84EAWofaRW9zhlqKaivZK4Q55VHzU hogQ== 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=MMeIQIaUT9cFLFVfOZAfkWHwj7aINzLWQ4+zAStdY7k=; b=jVx734r/qMw0KL4ybeHSbJDdFM+w8zzJDdZFzvHFOp0Y6ymICTaqDP/nYxWQ9Nzo1E OolnfM8ycUCiRVPvN5l60QQsS1C/WrZZhMHGdZK5shhtBe14Lv/GJZiHsa9LohzPEpCe 7O3M5+IvzO9iPn4k3bnXus/eQkpgaYYhS8AGAifQNS44Lx2dwrqhqOzLeYth6EqQbBns 2jVmTtyJkfvfOnBAHowAjZx40LaJmZMlEvjnep8Bv5iXckGfG1DnTHwKh5rOofaJ5eT6 LSgOe73X4zHVUKBMPeAmCScbo1lccYwvWzR7Q3oGfAGm08p2a+tI+IDYsUKcOJd4emGk Gh2w== X-Gm-Message-State: AOAM531wAQwOS9BsCFYGjXZRCLbv5CjDj8eGjieu3paWWEMvksqTx6Bt pR69oKTFVoZ7Ho6znvQb00+GwB9a X-Google-Smtp-Source: ABdhPJyFoyihSpa1xCN5LGq4WjvgfluazLwKf9W0ZySOJyJld+CoB05Y/z2P3ApLNKd8qK6MGHtLDg== X-Received: by 2002:a9d:4602:: with SMTP id y2mr2629775ote.199.1592317078117; Tue, 16 Jun 2020 07:17: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 s67sm4060121oif.0.2020.06.16.07.17.57 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jun 2020 07:17:57 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Subject: [PATCH 24/78] intel_iommu: add present bit check for pasid table entries Date: Tue, 16 Jun 2020 09:14:53 -0500 Message-Id: <20200616141547.24664-25-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> References: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::32b; envelope-from=flukshun@gmail.com; helo=mail-ot1-x32b.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Tian , Jacob Pan , Yi Sun , "Michael S . Tsirkin" , qemu-stable@nongnu.org, Peter Xu , Liu Yi L Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Liu Yi L The present bit check for pasid entry (pe) and pasid directory entry (pdire) were missed in previous commits as fpd bit check doesn't require present bit as "Set". This patch adds the present bit check for callers which wants to get a valid pe/pdire. Cc: qemu-stable@nongnu.org Cc: Kevin Tian Cc: Jacob Pan Cc: Peter Xu Cc: Yi Sun Reviewed-by: Peter Xu Signed-off-by: Liu Yi L Message-Id: <1578058086-4288-3-git-send-email-yi.l.liu@intel.com> Reviewed-by: Peter Xu Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin (cherry picked from commit 56fc1e6ac6bde95bc0369d358587f2234d4dddad) Signed-off-by: Michael Roth --- hw/i386/intel_iommu.c | 92 +++++++++++++++++++++++++++------- hw/i386/intel_iommu_internal.h | 1 + 2 files changed, 74 insertions(+), 19 deletions(-) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 00ebae4863..bfe8edb0ce 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -686,9 +686,18 @@ static inline bool vtd_pe_type_check(X86IOMMUState *x86_iommu, return true; } -static int vtd_get_pasid_dire(dma_addr_t pasid_dir_base, - uint32_t pasid, - VTDPASIDDirEntry *pdire) +static inline bool vtd_pdire_present(VTDPASIDDirEntry *pdire) +{ + return pdire->val & 1; +} + +/** + * Caller of this function should check present bit if wants + * to use pdir entry for futher usage except for fpd bit check. + */ +static int vtd_get_pdire_from_pdir_table(dma_addr_t pasid_dir_base, + uint32_t pasid, + VTDPASIDDirEntry *pdire) { uint32_t index; dma_addr_t addr, entry_size; @@ -703,18 +712,22 @@ static int vtd_get_pasid_dire(dma_addr_t pasid_dir_base, return 0; } -static int vtd_get_pasid_entry(IntelIOMMUState *s, - uint32_t pasid, - VTDPASIDDirEntry *pdire, - VTDPASIDEntry *pe) +static inline bool vtd_pe_present(VTDPASIDEntry *pe) +{ + return pe->val[0] & VTD_PASID_ENTRY_P; +} + +static int vtd_get_pe_in_pasid_leaf_table(IntelIOMMUState *s, + uint32_t pasid, + dma_addr_t addr, + VTDPASIDEntry *pe) { uint32_t index; - dma_addr_t addr, entry_size; + dma_addr_t entry_size; X86IOMMUState *x86_iommu = X86_IOMMU_DEVICE(s); index = VTD_PASID_TABLE_INDEX(pasid); entry_size = VTD_PASID_ENTRY_SIZE; - addr = pdire->val & VTD_PASID_TABLE_BASE_ADDR_MASK; addr = addr + index * entry_size; if (dma_memory_read(&address_space_memory, addr, pe, entry_size)) { return -VTD_FR_PASID_TABLE_INV; @@ -732,25 +745,54 @@ static int vtd_get_pasid_entry(IntelIOMMUState *s, return 0; } -static int vtd_get_pasid_entry_from_pasid(IntelIOMMUState *s, - dma_addr_t pasid_dir_base, - uint32_t pasid, - VTDPASIDEntry *pe) +/** + * Caller of this function should check present bit if wants + * to use pasid entry for futher usage except for fpd bit check. + */ +static int vtd_get_pe_from_pdire(IntelIOMMUState *s, + uint32_t pasid, + VTDPASIDDirEntry *pdire, + VTDPASIDEntry *pe) +{ + dma_addr_t addr = pdire->val & VTD_PASID_TABLE_BASE_ADDR_MASK; + + return vtd_get_pe_in_pasid_leaf_table(s, pasid, addr, pe); +} + +/** + * This function gets a pasid entry from a specified pasid + * table (includes dir and leaf table) with a specified pasid. + * Sanity check should be done to ensure return a present + * pasid entry to caller. + */ +static int vtd_get_pe_from_pasid_table(IntelIOMMUState *s, + dma_addr_t pasid_dir_base, + uint32_t pasid, + VTDPASIDEntry *pe) { int ret; VTDPASIDDirEntry pdire; - ret = vtd_get_pasid_dire(pasid_dir_base, pasid, &pdire); + ret = vtd_get_pdire_from_pdir_table(pasid_dir_base, + pasid, &pdire); if (ret) { return ret; } - ret = vtd_get_pasid_entry(s, pasid, &pdire, pe); + if (!vtd_pdire_present(&pdire)) { + return -VTD_FR_PASID_TABLE_INV; + } + + ret = vtd_get_pe_from_pdire(s, pasid, &pdire, pe); if (ret) { return ret; } - return ret; + if (!vtd_pe_present(pe)) { + return -VTD_FR_PASID_TABLE_INV; + } + + return 0; } static int vtd_ce_get_rid2pasid_entry(IntelIOMMUState *s, @@ -763,7 +805,7 @@ static int vtd_ce_get_rid2pasid_entry(IntelIOMMUState *s, pasid = VTD_CE_GET_RID2PASID(ce); pasid_dir_base = VTD_CE_GET_PASID_DIR_TABLE(ce); - ret = vtd_get_pasid_entry_from_pasid(s, pasid_dir_base, pasid, pe); + ret = vtd_get_pe_from_pasid_table(s, pasid_dir_base, pasid, pe); return ret; } @@ -781,7 +823,11 @@ static int vtd_ce_get_pasid_fpd(IntelIOMMUState *s, pasid = VTD_CE_GET_RID2PASID(ce); pasid_dir_base = VTD_CE_GET_PASID_DIR_TABLE(ce); - ret = vtd_get_pasid_dire(pasid_dir_base, pasid, &pdire); + /* + * No present bit check since fpd is meaningful even + * if the present bit is clear. + */ + ret = vtd_get_pdire_from_pdir_table(pasid_dir_base, pasid, &pdire); if (ret) { return ret; } @@ -791,7 +837,15 @@ static int vtd_ce_get_pasid_fpd(IntelIOMMUState *s, return 0; } - ret = vtd_get_pasid_entry(s, pasid, &pdire, &pe); + if (!vtd_pdire_present(&pdire)) { + return -VTD_FR_PASID_TABLE_INV; + } + + /* + * No present bit check since fpd is meaningful even + * if the present bit is clear. + */ + ret = vtd_get_pe_from_pdire(s, pasid, &pdire, &pe); if (ret) { return ret; } diff --git a/hw/i386/intel_iommu_internal.h b/hw/i386/intel_iommu_internal.h index edcf9fc9bb..862033ebe6 100644 --- a/hw/i386/intel_iommu_internal.h +++ b/hw/i386/intel_iommu_internal.h @@ -479,6 +479,7 @@ typedef struct VTDRootEntry VTDRootEntry; #define VTD_PASID_ENTRY_FPD (1ULL << 1) /* Fault Processing Disable */ /* PASID Granular Translation Type Mask */ +#define VTD_PASID_ENTRY_P 1ULL #define VTD_SM_PASID_ENTRY_PGTT (7ULL << 6) #define VTD_SM_PASID_ENTRY_FLT (1ULL << 6) #define VTD_SM_PASID_ENTRY_SLT (2ULL << 6) From patchwork Tue Jun 16 14:14:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 280347 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9CD80C433DF for ; Tue, 16 Jun 2020 14:33:06 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 68D832080D for ; Tue, 16 Jun 2020 14:33:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Jv1c5gsV" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 68D832080D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:50172 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlCe9-0001pB-Im for qemu-devel@archiver.kernel.org; Tue, 16 Jun 2020 10:33:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57524) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlCPe-00022B-L7; Tue, 16 Jun 2020 10:18:07 -0400 Received: from mail-oo1-xc41.google.com ([2607:f8b0:4864:20::c41]:36739) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jlCPc-0006dv-Le; Tue, 16 Jun 2020 10:18:06 -0400 Received: by mail-oo1-xc41.google.com with SMTP id 18so4114476ooy.3; Tue, 16 Jun 2020 07:18: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=vyfdFEZo9wjCtOzFIY4Rui8H5p83Ort5DNNjf/+2Umc=; b=Jv1c5gsVp22bBuHlahsGlVrPfcszZxv6m5FdLoLldeQOMYGfsr0zRMy0ZUpC2H3vro EGy+q6a0TMu8nZa6vXfH4ygN3kiUQ1pSWHYeW8GVCuMfXsjCdWgr9/buzzHQjgRyojUY VN/yssP1wdbIFe5VwdVPovFS/HdUL/twXpnYg+ndkpa8x/KsRdHYV+mEqbNBizPhp+JF ELq923flVnhS5CbNrNkINM/LWFQJqBveWu2YZE9BSK2YjcWzHsgOgInG0qLHMRQ04UlM geIo+sRpxXvdktW/ILIxh/EouvStk8au5GWl+ofT5WdhQeiGn/FfOxCZfwzMpX2Z4JEZ aCNg== 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=vyfdFEZo9wjCtOzFIY4Rui8H5p83Ort5DNNjf/+2Umc=; b=G12TyICBfoV58o4gYbPiGzPLqDl6bEJUg8En1TGCHAMUDTjqEmoIhkMJZL9O5sN40B r0Tfr4q2qE78tuxw6gr8K9uaRiOKgcHGc8xYA5yLrNQaKgh9j5yYa2dQ5v3dWwtg3JlQ Y1sF3na2tSCWunBqP5rwMKeFPGwvqnhSoP6NWZdXygLn0Qs6gKWj/6Ub6I82Uuuh3dMQ AHxXOk8TW8P+VGytLu1ebaqa2enTbKJ9wKg9D1BJ6Zpt1YEMlR7cpRo5/5IgWMykQXym k5K2R6KYb3d/RWUAVQKEAAV/yWgwBauXChhYERS8jZ+KueUe3nhEpr36bdnwecGXWlg8 SIiQ== X-Gm-Message-State: AOAM532v6GyAImg7sbBXksHC4BlsPe4Jg0ss9futbBw7l9RzYad1AAB5 67EijEU1nWmaEy2n5cloEbsx5coG X-Google-Smtp-Source: ABdhPJyLWoo5hI5bJXmSp8BD0YLcRxZUGZk9VEXEmvcLDPG1sOHNF5ML6WOMb7rio72DozCVqo5vmg== X-Received: by 2002:a4a:8143:: with SMTP id p3mr2462712oog.49.1592317082522; Tue, 16 Jun 2020 07:18: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 h27sm2128482otg.23.2020.06.16.07.18.01 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jun 2020 07:18:01 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Subject: [PATCH 27/78] dp8393x: Mask EOL bit from descriptor addresses Date: Tue, 16 Jun 2020 09:14:56 -0500 Message-Id: <20200616141547.24664-28-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> References: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::c41; envelope-from=flukshun@gmail.com; helo=mail-oo1-xc41.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jason Wang , qemu-stable@nongnu.org, Finn Thain Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Finn Thain The Least Significant bit of a descriptor address register is used as an EOL flag. It has to be masked when the register value is to be used as an actual address for copying memory around. But when the registers are to be updated the EOL bit should not be masked. Signed-off-by: Finn Thain Tested-by: Laurent Vivier Signed-off-by: Jason Wang (cherry picked from commit 88f632fbb1b3d31d5b6978d28f8735a6ed18b8f5) Conflicts: hw/net/dp8393x.c *drop context dep. on 19f70347731 Signed-off-by: Michael Roth --- hw/net/dp8393x.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/hw/net/dp8393x.c b/hw/net/dp8393x.c index 3d991af163..7ca6a6dd46 100644 --- a/hw/net/dp8393x.c +++ b/hw/net/dp8393x.c @@ -145,6 +145,9 @@ do { printf("sonic ERROR: %s: " fmt, __func__ , ## __VA_ARGS__); } while (0) #define SONIC_ISR_PINT 0x0800 #define SONIC_ISR_LCD 0x1000 +#define SONIC_DESC_EOL 0x0001 +#define SONIC_DESC_ADDR 0xFFFE + #define TYPE_DP8393X "dp8393x" #define DP8393X(obj) OBJECT_CHECK(dp8393xState, (obj), TYPE_DP8393X) @@ -197,7 +200,8 @@ static uint32_t dp8393x_crba(dp8393xState *s) static uint32_t dp8393x_crda(dp8393xState *s) { - return (s->regs[SONIC_URDA] << 16) | s->regs[SONIC_CRDA]; + return (s->regs[SONIC_URDA] << 16) | + (s->regs[SONIC_CRDA] & SONIC_DESC_ADDR); } static uint32_t dp8393x_rbwc(dp8393xState *s) @@ -217,7 +221,8 @@ static uint32_t dp8393x_tsa(dp8393xState *s) static uint32_t dp8393x_ttda(dp8393xState *s) { - return (s->regs[SONIC_UTDA] << 16) | s->regs[SONIC_TTDA]; + return (s->regs[SONIC_UTDA] << 16) | + (s->regs[SONIC_TTDA] & SONIC_DESC_ADDR); } static uint32_t dp8393x_wt(dp8393xState *s) @@ -507,7 +512,7 @@ static void dp8393x_do_transmit_packets(dp8393xState *s) (4 + 3 * s->regs[SONIC_TFC]) * width, MEMTXATTRS_UNSPECIFIED, (uint8_t *)s->data, size, 0); s->regs[SONIC_CTDA] = dp8393x_get(s, width, 0) & ~0x1; - if (dp8393x_get(s, width, 0) & 0x1) { + if (dp8393x_get(s, width, 0) & SONIC_DESC_EOL) { /* EOL detected */ break; } @@ -763,13 +768,13 @@ static ssize_t dp8393x_receive(NetClientState *nc, const uint8_t * buf, /* XXX: Check byte ordering */ /* Check for EOL */ - if (s->regs[SONIC_LLFA] & 0x1) { + if (s->regs[SONIC_LLFA] & SONIC_DESC_EOL) { /* Are we still in resource exhaustion? */ size = sizeof(uint16_t) * 1 * width; address = dp8393x_crda(s) + sizeof(uint16_t) * 5 * width; address_space_rw(&s->as, address, MEMTXATTRS_UNSPECIFIED, (uint8_t *)s->data, size, 0); - if (dp8393x_get(s, width, 0) & 0x1) { + if (dp8393x_get(s, width, 0) & SONIC_DESC_EOL) { /* Still EOL ; stop reception */ return -1; } else { @@ -827,7 +832,7 @@ static ssize_t dp8393x_receive(NetClientState *nc, const uint8_t * buf, address_space_rw(&s->as, dp8393x_crda(s) + sizeof(uint16_t) * 5 * width, MEMTXATTRS_UNSPECIFIED, (uint8_t *)s->data, size, 0); s->regs[SONIC_LLFA] = dp8393x_get(s, width, 0); - if (s->regs[SONIC_LLFA] & 0x1) { + if (s->regs[SONIC_LLFA] & SONIC_DESC_EOL) { /* EOL detected */ s->regs[SONIC_ISR] |= SONIC_ISR_RDE; } else { From patchwork Tue Jun 16 14:14:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 280346 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E74A7C433DF for ; Tue, 16 Jun 2020 14:34:11 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B4EF12080D for ; Tue, 16 Jun 2020 14:34:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kycbMPE1" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B4EF12080D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:55742 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlCfC-00043s-VW for qemu-devel@archiver.kernel.org; Tue, 16 Jun 2020 10:34:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57552) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlCPh-00023E-Cx; Tue, 16 Jun 2020 10:18:09 -0400 Received: from mail-ot1-x342.google.com ([2607:f8b0:4864:20::342]:37436) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jlCPf-0006eO-Sn; Tue, 16 Jun 2020 10:18:09 -0400 Received: by mail-ot1-x342.google.com with SMTP id v13so16028366otp.4; Tue, 16 Jun 2020 07:18: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=8ZFVEmVYSWBDs8wC8TE3sSuzczpmCQe4KbuCRBmtqzI=; b=kycbMPE1ue+qVRKGS+ClDnHRvZPxLhY1FtmjGQmrBo/4oN6af+kGcE+srdZYvzyVpM q8zAlGls0vGi61aBZfhq5qmcjL6hCJ6O1Z6aWX0hEENVldQzVOqIzcNbGh1ARl0Yi8iz 1hI9QPEPV6XHXmZK4IUXusUU1m1LBujxfGJJbQEFcAu1EJxhRns0LgRmA0dfkIJktrEf /xGPaN8dyhLXq9jVnOnyG05GK0C39XH7WrpYeBOn2WnxCOVFeC1sWPYlLn/TFsE15U97 hkll7ov8rwVe7f8jLlhXG5q5pRIBVVL6fRlaKYdKgGDjgfY2yErxRsk+X8vXnlqOSiQB KFpQ== 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=8ZFVEmVYSWBDs8wC8TE3sSuzczpmCQe4KbuCRBmtqzI=; b=f6buWVo4XjvC7Xm8ak8JVa7oLV43E2ZJWbd/5HgH8kwY0R0Bbgz8kFnKZPs2XFnFUu p13vtOiUc2zBJkXM26OGZFdDOEavIA5+qgavFhF9w0T9A/n+EaigPrNd9v48+JTiEc+p eHcPWJ8sWG6W1G4+BTULQzvBZfQX7AyQ05nv5Ify7/yjsL3KGKMYcwQLUDrGyZHWMMrS V3MVqhdusGANZ9GjEDg4I1/HVRp0Zy2w1CT4J+7p0aroGbz6AhEgzzWsBgZLww6WeoOg VOvMN9AAjFAo/nGBfJrZOgqJK42u7teALk9buWBHagRB22oECl003+BqVSVaLoCg+Qff LpxQ== X-Gm-Message-State: AOAM533tvi9PiRdvNjXO8rafflEvYmW7XDzbpT+k7Q0DqCX8B1SAhk4x 6t9TkDPbiEu5Yihjxt9p1Vu691zz X-Google-Smtp-Source: ABdhPJweTg1fM1X+ePN3WI4LGW+YjxGrI7lSPOB0Ux1yCk366Z8h54xYQoOKul0W4fhebjIbyBknug== X-Received: by 2002:a9d:6103:: with SMTP id i3mr2494415otj.354.1592317085563; Tue, 16 Jun 2020 07:18: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 c196sm4149776oib.34.2020.06.16.07.18.04 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jun 2020 07:18:04 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Subject: [PATCH 29/78] dp8393x: Clean up endianness hacks Date: Tue, 16 Jun 2020 09:14:58 -0500 Message-Id: <20200616141547.24664-30-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> References: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::342; envelope-from=flukshun@gmail.com; helo=mail-ot1-x342.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jason Wang , qemu-stable@nongnu.org, Finn Thain Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Finn Thain According to the datasheet, section 3.4.4, "in 32-bit mode ... the SONIC always writes long words". Therefore, use the same technique for the 'in_use' field that is used everywhere else, and write the full long word. Signed-off-by: Finn Thain Tested-by: Laurent Vivier Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Jason Wang (cherry picked from commit 46ffee9ad43185cbee4182c208bbd534814086ca) Conflicts: hw/net/dp8393x.c *roll in local dependencies on b7cbebf2b9d *drop functional dep. on 19f70347731 Signed-off-by: Michael Roth --- hw/net/dp8393x.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/hw/net/dp8393x.c b/hw/net/dp8393x.c index 49c304ee20..f89f4c7ba3 100644 --- a/hw/net/dp8393x.c +++ b/hw/net/dp8393x.c @@ -776,8 +776,6 @@ static ssize_t dp8393x_receive(NetClientState *nc, const uint8_t * buf, return -1; } - /* XXX: Check byte ordering */ - /* Check for EOL */ if (s->regs[SONIC_LLFA] & SONIC_DESC_EOL) { /* Are we still in resource exhaustion? */ @@ -847,15 +845,12 @@ static ssize_t dp8393x_receive(NetClientState *nc, const uint8_t * buf, /* EOL detected */ s->regs[SONIC_ISR] |= SONIC_ISR_RDE; } else { - /* Clear in_use, but it is always 16bit wide */ - int offset = dp8393x_crda(s) + sizeof(uint16_t) * 6 * width; - if (s->big_endian && width == 2) { - /* we need to adjust the offset of the 16bit field */ - offset += sizeof(uint16_t); - } - s->data[0] = 0; - address_space_rw(&s->as, offset, MEMTXATTRS_UNSPECIFIED, - (uint8_t *)s->data, sizeof(uint16_t), 1); + /* Clear in_use */ + size = sizeof(uint16_t) * width; + address = dp8393x_crda(s) + sizeof(uint16_t) * 6 * width; + dp8393x_put(s, width, 0, 0); + address_space_rw(&s->as, address, MEMTXATTRS_UNSPECIFIED, + (uint8_t *)s->data, size, true); s->regs[SONIC_CRDA] = s->regs[SONIC_LLFA]; s->regs[SONIC_ISR] |= SONIC_ISR_PKTRX; s->regs[SONIC_RSC] = (s->regs[SONIC_RSC] & 0xff00) | (((s->regs[SONIC_RSC] & 0x00ff) + 1) & 0x00ff); From patchwork Tue Jun 16 14:15:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 280341 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 872B9C433E0 for ; Tue, 16 Jun 2020 14:39:59 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5568E20882 for ; Tue, 16 Jun 2020 14:39:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GRar0dNL" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5568E20882 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:52546 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlCko-0006J5-G4 for qemu-devel@archiver.kernel.org; Tue, 16 Jun 2020 10:39:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57606) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlCPp-0002BH-3I; Tue, 16 Jun 2020 10:18:17 -0400 Received: from mail-ot1-x342.google.com ([2607:f8b0:4864:20::342]:38307) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jlCPn-0006fk-Ai; Tue, 16 Jun 2020 10:18:16 -0400 Received: by mail-ot1-x342.google.com with SMTP id n70so16044260ota.5; Tue, 16 Jun 2020 07:18: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 :mime-version:content-transfer-encoding; bh=wJrYjqEEa3ZXREtHH6UNEd/DSW1JqxV2SjbmLwmSWHM=; b=GRar0dNLDEOV6q5B8UlO4NwB3uVEo5W8/HYWua50zwAO/EQdA+hvZZz3l21XgThdQD d6eSXCRrRlMWq+O7vD0nUoBKQM0gxdCajI1ZURAbEP0J+YWzVc31b+bJ0KMryYARBJoA WS3hggoUqkjDuWedNCX9J4GGbiED5vmxfWbzaaANn2KrARXLAiZmKB2/HJFDkYpCZ0dQ zjsD5eCyAHdDXoP4eLHjVaY9ZBLgcWywrw1c3UqjIoy1ShyJA3KzJZZH0yYGQNvaBgeD 3vV9pkJOarzeWbSVW4u8K5VYR75he8BVeR8pyo5PsRnJ5wfQtIo3JHLguW0JNxc2iAn0 b+XQ== 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=wJrYjqEEa3ZXREtHH6UNEd/DSW1JqxV2SjbmLwmSWHM=; b=H+x5sf3yMM/bLkhPrTXKNIT7L9rA8tNjog1cJxS+uZ56NX3Nei+bF1zIBNCDNUC8XM mPYdME6v0ej7QlYbT/rQrSqWYHi8YJ70T7wNC6KoFCmvaNtkIRIJxJCk8/cdjUbaI7gw 4Q2TvGWKfvs34rKeQcI5Ow7siF/b1mlr9c3fLY8ghmcs0jP0qC/pikNe8gfkmwmZVF5Q 5BVSMdzSAALtzURtsKtvlU1XNzfPVwEjU0P/vrCIr6B58foSvTRs9KBzzV+/Ky7fiDRq TtbFwpwDxCN2V4bhXwrorwpvpbQbjrX8rHzm/QoFAD0cU6HdxVXvcLUWX240VoCJR3Vw 2ywQ== X-Gm-Message-State: AOAM532S75UX6aJlSrC5tTXBV2xdMM9rMrAYanwj2aiCXBGmdoqRl6Y2 FrvIbGTzkITkO/fTYnu+PGxgv9n7 X-Google-Smtp-Source: ABdhPJyUx2T6lAvHCczqd5gUjLQ7mxx5XK3473upZ15KI5BS2KBzQQCAmlgX35YVjgOgqQFCGqFTEw== X-Received: by 2002:a9d:204f:: with SMTP id n73mr2514196ota.342.1592317090711; Tue, 16 Jun 2020 07:18:10 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id c23sm4072625otd.7.2020.06.16.07.18.09 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jun 2020 07:18:09 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Subject: [PATCH 31/78] dp8393x: Update LLFA and CRDA registers from rx descriptor Date: Tue, 16 Jun 2020 09:15:00 -0500 Message-Id: <20200616141547.24664-32-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> References: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::342; envelope-from=flukshun@gmail.com; helo=mail-ot1-x342.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jason Wang , qemu-stable@nongnu.org, Finn Thain Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Finn Thain Follow the algorithm given in the National Semiconductor DP83932C datasheet in section 3.4.7: At the next reception, the SONIC re-reads the last RXpkt.link field, and updates its CRDA register to point to the next descriptor. The chip is designed to allow the host to provide a new list of descriptors in this way. Signed-off-by: Finn Thain Tested-by: Laurent Vivier Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Jason Wang (cherry picked from commit 5b0c98fcb7ac006bd8efe0e0fecba52c43a9d028) *drop context dep on 19f70347731 Signed-off-by: Michael Roth --- hw/net/dp8393x.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/hw/net/dp8393x.c b/hw/net/dp8393x.c index a696485a55..8dd6bf032c 100644 --- a/hw/net/dp8393x.c +++ b/hw/net/dp8393x.c @@ -784,12 +784,13 @@ static ssize_t dp8393x_receive(NetClientState *nc, const uint8_t * buf, address = dp8393x_crda(s) + sizeof(uint16_t) * 5 * width; address_space_rw(&s->as, address, MEMTXATTRS_UNSPECIFIED, (uint8_t *)s->data, size, 0); - if (dp8393x_get(s, width, 0) & SONIC_DESC_EOL) { + s->regs[SONIC_LLFA] = dp8393x_get(s, width, 0); + if (s->regs[SONIC_LLFA] & SONIC_DESC_EOL) { /* Still EOL ; stop reception */ return -1; - } else { - s->regs[SONIC_CRDA] = s->regs[SONIC_LLFA]; } + /* Link has been updated by host */ + s->regs[SONIC_CRDA] = s->regs[SONIC_LLFA]; } /* Save current position */ @@ -837,7 +838,7 @@ static ssize_t dp8393x_receive(NetClientState *nc, const uint8_t * buf, address_space_rw(&s->as, dp8393x_crda(s), MEMTXATTRS_UNSPECIFIED, (uint8_t *)s->data, size, 1); - /* Move to next descriptor */ + /* Check link field */ size = sizeof(uint16_t) * width; address_space_rw(&s->as, dp8393x_crda(s) + sizeof(uint16_t) * 5 * width, MEMTXATTRS_UNSPECIFIED, (uint8_t *)s->data, size, 0); @@ -852,6 +853,8 @@ static ssize_t dp8393x_receive(NetClientState *nc, const uint8_t * buf, dp8393x_put(s, width, 0, 0); address_space_rw(&s->as, address, MEMTXATTRS_UNSPECIFIED, (uint8_t *)s->data, size, true); + + /* Move to next descriptor */ s->regs[SONIC_CRDA] = s->regs[SONIC_LLFA]; s->regs[SONIC_ISR] |= SONIC_ISR_PKTRX; s->regs[SONIC_RSC] = (s->regs[SONIC_RSC] & 0xff00) | (((s->regs[SONIC_RSC] & 0x00ff) + 1) & 0x00ff); From patchwork Tue Jun 16 14:15:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 280342 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ACC4EC433DF for ; Tue, 16 Jun 2020 14:38:09 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 73E8320644 for ; Tue, 16 Jun 2020 14:38:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QYBtQb3q" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 73E8320644 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:44218 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlCj2-0002kQ-Jp for qemu-devel@archiver.kernel.org; Tue, 16 Jun 2020 10:38:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57604) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlCPo-0002Ar-VJ; Tue, 16 Jun 2020 10:18:16 -0400 Received: from mail-oi1-x243.google.com ([2607:f8b0:4864:20::243]:34890) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jlCPn-0006ga-Al; Tue, 16 Jun 2020 10:18:16 -0400 Received: by mail-oi1-x243.google.com with SMTP id k4so19384129oik.2; Tue, 16 Jun 2020 07:18: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=j5JadjYITwuc3PbQFYYnCy+d7Me2080KB/yC+x/1sXg=; b=QYBtQb3qv5JrOYveG1CHpjtIi8E4eGda2+ymh+28Pe4Jslu6mvGNzqskv4eEQCPA8n 8BR1q7abwCfSm7+y/Nf71JA6VUlMDs70/uxS7l0eqQYtRVaJKidcy23GTuzmnee3Lqa2 z2GMH73UHlwmQp6RhHWRx1ZdDS3fti8CZlsjnpuGpdkAGr+b1+ChTQEYk8M/9klFKu6Y zUAHPmuxwWP3ll3yvabAnnlv064sNmJe+W+ywecxmfMux1eOlTHpBZx8drqdB4DR1GWY jGgzQgxKQTEizIh10eT2Hama9GNje+NcTWlJ/yY5/3UWTJ1n5uoikwwqcrtji2byM74F R8bA== 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=j5JadjYITwuc3PbQFYYnCy+d7Me2080KB/yC+x/1sXg=; b=ihVsnRbwK1jFN4AcpklyhyDU+i+ur6GamUNJv6F9c1I6lVUW+XIcbpVmswcg7kbakw viue7mofRHqcX2q79Cj3E0rU0mgxS+NrjpxywCO5VvhW5xCnlfdhSbaTEowhW5RlGf3a 4cWtnLlW/VFuISw0rjkTIuU549VtIpSb5DSYnNUUDVOT/BKR6+RkH6A8InMUh/qgYOV6 jbAudAlS+O8+PcjVkFoijPewDfDOqWqSAZJesC7Bz9hpX2yA7hTFUEmJujkipIx3AKk2 gAgD3sIRzaqM2TI4wMFNWfhDBN5Scw02yofCAmIyE/zeT1dUdhArjAfYFbcxb12RSpUZ YQfA== X-Gm-Message-State: AOAM5323v6A3VI25TgW7TRWV+7wkEO6lEd8SVBXHG78OaVQBoJi6Y57/ 1zvEN9iDWEN+mRnHvI5UzV96yqU2 X-Google-Smtp-Source: ABdhPJwZZUyt2mPpDUaiuo9qZigT3HqodRbWAqEJHNDjrz9SFLzeJIRgjXMzTuIQenvtbna1E1jwtw== X-Received: by 2002:aca:ec4d:: with SMTP id k74mr3364583oih.160.1592317092226; Tue, 16 Jun 2020 07:18: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 s20sm4078575otd.62.2020.06.16.07.18.11 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jun 2020 07:18:11 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Subject: [PATCH 32/78] dp8393x: Clear RRRA command register bit only when appropriate Date: Tue, 16 Jun 2020 09:15:01 -0500 Message-Id: <20200616141547.24664-33-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> References: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::243; envelope-from=flukshun@gmail.com; helo=mail-oi1-x243.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jason Wang , qemu-stable@nongnu.org, Finn Thain Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Finn Thain It doesn't make sense to clear the command register bit unless the command was actually issued. Signed-off-by: Finn Thain Reviewed-by: Philippe Mathieu-Daudé Tested-by: Laurent Vivier Signed-off-by: Jason Wang (cherry picked from commit a3cce2825a0b12bb717a5106daaca245557cc9ae) Signed-off-by: Michael Roth --- hw/net/dp8393x.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/hw/net/dp8393x.c b/hw/net/dp8393x.c index 8dd6bf032c..04f58ee4e1 100644 --- a/hw/net/dp8393x.c +++ b/hw/net/dp8393x.c @@ -352,9 +352,6 @@ static void dp8393x_do_read_rra(dp8393xState *s) s->regs[SONIC_ISR] |= SONIC_ISR_RBE; dp8393x_update_irq(s); } - - /* Done */ - s->regs[SONIC_CR] &= ~SONIC_CR_RRRA; } static void dp8393x_do_software_reset(dp8393xState *s) @@ -563,8 +560,10 @@ static void dp8393x_do_command(dp8393xState *s, uint16_t command) dp8393x_do_start_timer(s); if (command & SONIC_CR_RST) dp8393x_do_software_reset(s); - if (command & SONIC_CR_RRRA) + if (command & SONIC_CR_RRRA) { dp8393x_do_read_rra(s); + s->regs[SONIC_CR] &= ~SONIC_CR_RRRA; + } if (command & SONIC_CR_LCAM) dp8393x_do_load_cam(s); } From patchwork Tue Jun 16 14:15:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 280345 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CEBB4C433E1 for ; Tue, 16 Jun 2020 14:35:31 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A330D20776 for ; Tue, 16 Jun 2020 14:35:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Q3L+sAVN" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A330D20776 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:33340 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlCgU-0006QQ-Nl for qemu-devel@archiver.kernel.org; Tue, 16 Jun 2020 10:35:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57652) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlCPu-0002PV-9V; Tue, 16 Jun 2020 10:18:22 -0400 Received: from mail-ot1-x343.google.com ([2607:f8b0:4864:20::343]:41880) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jlCPs-0006ir-LR; Tue, 16 Jun 2020 10:18:21 -0400 Received: by mail-ot1-x343.google.com with SMTP id k15so16042591otp.8; Tue, 16 Jun 2020 07:18:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4eY61f4yjJnpy1o5y9J5QRfvOfW6Yv9szrM/jozGATU=; b=Q3L+sAVN7rB8isPHP471ZTgUlBPifOiFj9HBkCUn32lPupNgCaTHjb3Ycb9ug7RBza WtPOsWYxNXGU3V3/w84+Z19oTZ+n7yyFDnfJ0nGaTeSl5sDVlvtQHf+STW9oSEKfxoad H3+pzOy1BXUv+63u5PT3fbX/pmQIHQSytBp3B6SZ2Xgc2xsyGKGq1We+7fhoUgIoPzDu eE0QiJvbbzjIcDt4FPL/LGJAlrnS3YSqTvlFkO86RNpr1qPpBGPRLsgFzf61/kZbMGPw 2HhdEXZ7D7qsG7OzKYsM+4JQI6GWs7BFxzrCzks8gRwjnYtB7RmIKUTnZ3s/kq0SwgTK Fk5g== 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=4eY61f4yjJnpy1o5y9J5QRfvOfW6Yv9szrM/jozGATU=; b=TNztWQRlRc0mgCNAztNogs8KrG58x7w4fPjnIiVs/Pu8PaOPcNqHytWQsisN7l1i62 WWi+Z4v0yaqGgvfbZhDHfRxfcSTteGjOdJpWNkiH8UwdOkD+hl5O3FGYPwd9BJmEz6Do KjrpGPPGTpe2mR1xl5B1EjwnpYBOUlF/1oS4IHnrhatVdegFpg7u1cTrl3vCd0KjIYQD RRFv7Xl6b9J3VdcwZMuxt8Gu0vRRNTwWQIYxc+37mqC6WLDfuoLG3rVHszA6o6+UOMx4 PAYGNI4MTzlDUnfZtfdpyRqJchU9c7EeHxZpG+hgvQAqSWftHRCgKBTlNn11aH64uToW HhLQ== X-Gm-Message-State: AOAM533OocN+5xXq06Px2/EmcwrWHU8bHYwVLu0DVFhUiMoWDi7i+XLp geu5sLIm4e08NV9J7drtxjSBbyPj X-Google-Smtp-Source: ABdhPJwU8N677Qc/swHP829IaFWmlbZ5qBeR6H1XdJP4PSFxSOfp4PUYhxz12rxgRC/e1CZKSG0Bgw== X-Received: by 2002:a9d:2965:: with SMTP id d92mr2585153otb.350.1592317098333; Tue, 16 Jun 2020 07:18:18 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id g4sm4077411otp.5.2020.06.16.07.18.16 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jun 2020 07:18:17 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Subject: [PATCH 35/78] dp8393x: Use long-word-aligned RRA pointers in 32-bit mode Date: Tue, 16 Jun 2020 09:15:04 -0500 Message-Id: <20200616141547.24664-36-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> References: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::343; envelope-from=flukshun@gmail.com; helo=mail-ot1-x343.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jason Wang , qemu-stable@nongnu.org, Finn Thain Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Finn Thain Section 3.4.1 of the datasheet says, The alignment of the RRA is confined to either word or long word boundaries, depending upon the data width mode. In 16-bit mode, the RRA must be aligned to a word boundary (A0 is always zero) and in 32-bit mode, the RRA is aligned to a long word boundary (A0 and A1 are always zero). This constraint has been implemented for 16-bit mode; implement it for 32-bit mode too. Signed-off-by: Finn Thain Tested-by: Laurent Vivier Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Jason Wang (cherry picked from commit ea2270279bc2e1635cb6e909e22e17e630198773) Signed-off-by: Michael Roth --- hw/net/dp8393x.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hw/net/dp8393x.c b/hw/net/dp8393x.c index 315b4ad844..40e3a029b6 100644 --- a/hw/net/dp8393x.c +++ b/hw/net/dp8393x.c @@ -663,12 +663,16 @@ static void dp8393x_write(void *opaque, hwaddr addr, uint64_t data, qemu_flush_queued_packets(qemu_get_queue(s->nic)); } break; - /* Ignore least significant bit */ + /* The guest is required to store aligned pointers here */ case SONIC_RSA: case SONIC_REA: case SONIC_RRP: case SONIC_RWP: - s->regs[reg] = val & 0xfffe; + if (s->regs[SONIC_DCR] & SONIC_DCR_DW) { + s->regs[reg] = val & 0xfffc; + } else { + s->regs[reg] = val & 0xfffe; + } break; /* Invert written value for some registers */ case SONIC_CRCT: From patchwork Tue Jun 16 14:15:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 280338 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AEEBEC433E2 for ; Tue, 16 Jun 2020 14:42:40 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 84C02208B8 for ; Tue, 16 Jun 2020 14:42:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="g7FNTgPF" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 84C02208B8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:36042 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlCnP-0004Tr-Np for qemu-devel@archiver.kernel.org; Tue, 16 Jun 2020 10:42:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57664) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlCPv-0002UU-TW; Tue, 16 Jun 2020 10:18:23 -0400 Received: from mail-ot1-x343.google.com ([2607:f8b0:4864:20::343]:39890) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jlCPu-0006j9-Av; Tue, 16 Jun 2020 10:18:23 -0400 Received: by mail-ot1-x343.google.com with SMTP id g5so16041684otg.6; Tue, 16 Jun 2020 07:18:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2PAYIiO9sA4fG4g3Wu3Wl38xdQ9Zdsb+MLvf0b3D2Wo=; b=g7FNTgPFv4/Y5UcicqvAI+fAkUZwdEIukRE3Mw0maZKBjcEpV8HSjhTmR8EOzsuD1N FvgntdECt95W9F90X2+2oK1zg55kW17cIzqeR10BMHtwEVXVgG9nohSh7V/1qbsUDHEB nSqduJqHGKVjziNbGCj6tpQw2vNL5rfo2UMEI+OXsOTZFw6ug08qChxYtGkc7Vc/906u Wqp8w6IcHzVcUHH9rSxNKLKseRpj/hbqYU4yEAvVc0SN93HoNZltf7VaGu1IuQyAx3Pb ABBloVEwJ83394tnUtAwvN6tR1/lYQ0HiRiaJ03FRvingizsgox190O1DqwBiqzlmIVB wB/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:mime-version:content-transfer-encoding; bh=2PAYIiO9sA4fG4g3Wu3Wl38xdQ9Zdsb+MLvf0b3D2Wo=; b=aF+CFkTMy3O37ngIO8jXJF0QrhgiYa4XohVM0pr5xPFnJSkOgNMr2o/SSh+yGoF5ED 6Hcsu5R8M9il0BpNxAV3hGoiB6P8VU7bCrqmNW1mtp90PvaOtczRha7tLAXky9zHuaRD i6K2HGeDkzHqlrKd4e92YUIhBGmzsflIzFI0wHOctq7rr+Xp9m7qID9yzHwxjyBatSu8 miXHmQ6+q2+kc1p5+srPqxTINksi4J01VzJ+Ei4uIyN9F2iePhn7uyNUKF5cY03esh35 gf7UnnN895t4419DrGar+VogGkYWkyvWvGceOTf/cmtP8TtO9OjhuPV8aSrJxL5XxJyF pykw== X-Gm-Message-State: AOAM533oG/QNwlAtK6wmCtGHn9uLZepXYLhJsYHQhBjqW8LbIdxinaun wgdXPOC7zg2vW2mSKmpBC+QItu7o X-Google-Smtp-Source: ABdhPJwYSh11X0vLxrhUFIdVYhsAfxeWEuoto5UrLkPdRy8UgB8xEJ9RAN+s2dWwxX/f0bMJSYGQTw== X-Received: by 2002:a9d:6c03:: with SMTP id f3mr2511324otq.291.1592317100308; Tue, 16 Jun 2020 07:18:20 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id l24sm4073415otf.79.2020.06.16.07.18.18 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jun 2020 07:18:19 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Subject: [PATCH 36/78] dp8393x: Pad frames to word or long word boundary Date: Tue, 16 Jun 2020 09:15:05 -0500 Message-Id: <20200616141547.24664-37-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> References: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::343; envelope-from=flukshun@gmail.com; helo=mail-ot1-x343.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jason Wang , qemu-stable@nongnu.org, Finn Thain Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Finn Thain The existing code has a bug where the Remaining Buffer Word Count (RBWC) is calculated with a truncating division, which gives the wrong result for odd-sized packets. Section 1.4.1 of the datasheet says, Once the end of the packet has been reached, the serializer will fill out the last word (16-bit mode) or long word (32-bit mode) if the last byte did not end on a word or long word boundary respectively. The fill byte will be 0FFh. Implement buffer padding so that buffer limits are correctly enforced. Signed-off-by: Finn Thain Tested-by: Laurent Vivier Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Jason Wang (cherry picked from commit 350e7d9a77d3b9ac74d240e4b232db1ebe5c05bc) *drop context dependencies from b7cbebf2b9d, 1ccda935d4f, and 19f70347731 Signed-off-by: Michael Roth --- hw/net/dp8393x.c | 39 ++++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/hw/net/dp8393x.c b/hw/net/dp8393x.c index 40e3a029b6..0e9061d831 100644 --- a/hw/net/dp8393x.c +++ b/hw/net/dp8393x.c @@ -766,16 +766,23 @@ static ssize_t dp8393x_receive(NetClientState *nc, const uint8_t * buf, dp8393xState *s = qemu_get_nic_opaque(nc); int packet_type; uint32_t available, address; - int width, rx_len = pkt_size; + int width, rx_len, padded_len; uint32_t checksum; int size; - width = (s->regs[SONIC_DCR] & SONIC_DCR_DW) ? 2 : 1; - s->regs[SONIC_RCR] &= ~(SONIC_RCR_PRX | SONIC_RCR_LBK | SONIC_RCR_FAER | SONIC_RCR_CRCR | SONIC_RCR_LPKT | SONIC_RCR_BC | SONIC_RCR_MC); - if (pkt_size + 4 > dp8393x_rbwc(s) * 2) { + rx_len = pkt_size + sizeof(checksum); + if (s->regs[SONIC_DCR] & SONIC_DCR_DW) { + width = 2; + padded_len = ((rx_len - 1) | 3) + 1; + } else { + width = 1; + padded_len = ((rx_len - 1) | 1) + 1; + } + + if (padded_len > dp8393x_rbwc(s) * 2) { DPRINTF("oversize packet, pkt_size is %d\n", pkt_size); s->regs[SONIC_ISR] |= SONIC_ISR_RBAE; dp8393x_update_irq(s); @@ -810,22 +817,32 @@ static ssize_t dp8393x_receive(NetClientState *nc, const uint8_t * buf, s->regs[SONIC_TRBA0] = s->regs[SONIC_CRBA0]; /* Calculate the ethernet checksum */ - checksum = cpu_to_le32(crc32(0, buf, rx_len)); + checksum = cpu_to_le32(crc32(0, buf, pkt_size)); /* Put packet into RBA */ DPRINTF("Receive packet at %08x\n", dp8393x_crba(s)); address = dp8393x_crba(s); address_space_rw(&s->as, address, - MEMTXATTRS_UNSPECIFIED, (uint8_t *)buf, rx_len, 1); - address += rx_len; + MEMTXATTRS_UNSPECIFIED, (uint8_t *)buf, pkt_size, 1); + address += pkt_size; + + /* Put frame checksum into RBA */ address_space_rw(&s->as, address, - MEMTXATTRS_UNSPECIFIED, (uint8_t *)&checksum, 4, 1); - address += 4; - rx_len += 4; + MEMTXATTRS_UNSPECIFIED, (uint8_t *)&checksum, sizeof(checksum), 1); + address += sizeof(checksum); + + /* Pad short packets to keep pointers aligned */ + if (rx_len < padded_len) { + size = padded_len - rx_len; + address_space_rw(&s->as, address, MEMTXATTRS_UNSPECIFIED, + (uint8_t *)"\xFF\xFF\xFF", size, 1); + address += size; + } + s->regs[SONIC_CRBA1] = address >> 16; s->regs[SONIC_CRBA0] = address & 0xffff; available = dp8393x_rbwc(s); - available -= rx_len / 2; + available -= padded_len >> 1; s->regs[SONIC_RBWC1] = available >> 16; s->regs[SONIC_RBWC0] = available & 0xffff; From patchwork Tue Jun 16 14:15:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 280336 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 58CA9C433E0 for ; Tue, 16 Jun 2020 14:44:58 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 27611208B8 for ; Tue, 16 Jun 2020 14:44:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ewy2ofI3" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 27611208B8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:48252 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlCpd-0001c8-By for qemu-devel@archiver.kernel.org; Tue, 16 Jun 2020 10:44:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57734) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlCQ0-0002hK-GX; Tue, 16 Jun 2020 10:18:28 -0400 Received: from mail-ot1-x342.google.com ([2607:f8b0:4864:20::342]:32773) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jlCPz-0006kY-0B; Tue, 16 Jun 2020 10:18:28 -0400 Received: by mail-ot1-x342.google.com with SMTP id n6so16067011otl.0; Tue, 16 Jun 2020 07:18: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 :mime-version:content-transfer-encoding; bh=E99qbF+LJ1aftYVGDxQKrqzQk4RtFRFY8oKglRjiv8Y=; b=ewy2ofI37a46bVvM2kL+9RY5vvIf7EDMBMlrcQCC2eSWpgTgob9xIBXtYuu2Lsszv/ n+ISRKq4neXbVi1BG9zdGdlLRUkUieYWrBtRIhhoO3SJD886ilQVtbnqbLbaj/P2KjKe YXRqAB/n5v01O/kcw5uPgCvQ/AocrYrOcZVtidxKvQdRGJ0eeVVQTiOPXy3LFXkfYTtM tuLUi5yPodDpCDq8Rhd/ahuZ2yOpEGoR6Z7O25G+OigM+owaGXZDRFW37119s7WQ3TbH OBKe2rU9QmstPXlOp65LLkwPpZA8RgTDRh0IVOgHvZiTfTuGkUU4+vY6ype7KuVK0opH fiTQ== 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=E99qbF+LJ1aftYVGDxQKrqzQk4RtFRFY8oKglRjiv8Y=; b=BQk0s8V+CkyKTQEEm3nnZlxhEi2KIqjbWLiNFwlOQ5aNLs08mUDVGKjoo/UX3sz3Oe Ito2hpQIjCbMj/d3b78A9a9T7EkF1cpFsNkS00pgTRvxN8iXfbGb3rD3K77Ss1gy3FFM Pg9kuX5qxywJgq7XesDmeUTEr3TRAxJLnsDXQdng8pCOERkt72nc+WL3CDW9ND4WXEyD 12tj7QD8bJc8Ax5+LNBsvz8888yQ4nBHVynKMjrDr1iTqJnEgCpv+3FLw2EIdBrwZcMZ AnjcUcFG1yalb7WYEileo+tRz0zDn3aH6KGqh2Llp0SBRoEko9x6/LiI21xYMmMD+GyO V8kQ== X-Gm-Message-State: AOAM530VEOSqThutRg+4NUJffLZPf7rr3+4mQoX1z1AfoLI1R70xWVSm Tc9fI9cQ8XbOhFSFvn4v0k+8bwdG X-Google-Smtp-Source: ABdhPJzpBUsOqb2YGelkjbzuILfuLOkjDTvWUSI/P0QPVxFz64Z5j9nPULx/OACaIrNyD9rKxyKtVQ== X-Received: by 2002:a9d:7458:: with SMTP id p24mr2341757otk.330.1592317105284; Tue, 16 Jun 2020 07:18:25 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id k2sm3090455oib.10.2020.06.16.07.18.24 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jun 2020 07:18:24 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Subject: [PATCH 39/78] dp8393x: Don't reset Silicon Revision register Date: Tue, 16 Jun 2020 09:15:08 -0500 Message-Id: <20200616141547.24664-40-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> References: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::342; envelope-from=flukshun@gmail.com; helo=mail-ot1-x342.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jason Wang , qemu-stable@nongnu.org, Finn Thain Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Finn Thain The jazzsonic driver in Linux uses the Silicon Revision register value to probe the chip. The driver fails unless the SR register contains 4. Unfortunately, reading this register in QEMU usually returns 0 because the s->regs[] array gets wiped after a software reset. Fixes: bd8f1ebce4 ("net/dp8393x: fix hardware reset") Suggested-by: Philippe Mathieu-Daudé Signed-off-by: Finn Thain Signed-off-by: Jason Wang (cherry picked from commit 083e21bbdde7dbd326baf29d21f49fc3f5614496) Signed-off-by: Michael Roth --- hw/net/dp8393x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/net/dp8393x.c b/hw/net/dp8393x.c index aa7bd785f3..d33f21bd0b 100644 --- a/hw/net/dp8393x.c +++ b/hw/net/dp8393x.c @@ -919,6 +919,7 @@ static void dp8393x_reset(DeviceState *dev) timer_del(s->watchdog); memset(s->regs, 0, sizeof(s->regs)); + s->regs[SONIC_SR] = 0x0004; /* only revision recognized by Linux/mips */ s->regs[SONIC_CR] = SONIC_CR_RST | SONIC_CR_STP | SONIC_CR_RXDIS; s->regs[SONIC_DCR] &= ~(SONIC_DCR_EXBUS | SONIC_DCR_LBR); s->regs[SONIC_RCR] &= ~(SONIC_RCR_LB0 | SONIC_RCR_LB1 | SONIC_RCR_BRD | SONIC_RCR_RNT); @@ -971,7 +972,6 @@ static void dp8393x_realize(DeviceState *dev, Error **errp) qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a); s->watchdog = timer_new_ns(QEMU_CLOCK_VIRTUAL, dp8393x_watchdog, s); - s->regs[SONIC_SR] = 0x0004; /* only revision recognized by Linux */ memory_region_init_ram(&s->prom, OBJECT(dev), "dp8393x-prom", SONIC_PROM_SIZE, &local_err); From patchwork Tue Jun 16 14:15:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 280343 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5CBACC433E0 for ; Tue, 16 Jun 2020 14:37:25 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2D7F820644 for ; Tue, 16 Jun 2020 14:37:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="egvrO6sx" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2D7F820644 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:41548 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlCiK-0001Za-CT for qemu-devel@archiver.kernel.org; Tue, 16 Jun 2020 10:37:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57776) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlCQ7-0002mX-Gf; Tue, 16 Jun 2020 10:18:35 -0400 Received: from mail-oi1-x242.google.com ([2607:f8b0:4864:20::242]:42117) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jlCQ5-0006o5-W5; Tue, 16 Jun 2020 10:18:35 -0400 Received: by mail-oi1-x242.google.com with SMTP id s21so19368963oic.9; Tue, 16 Jun 2020 07:18: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=S1Y8wTl2wCcrU0k1huUV064vToavb00IavIF6/ytSuo=; b=egvrO6sxPb+D0QMA9T0goti0IZLSwGLO6qtgnHooIPaRx3UUquEMkeAp9FBtqKX+Rm gr6lvDXX2UM453GgurFJvTHe0lYnwRsTZA2ObcdVUrU7rvrM9ml+vHdnd9DFf8tFFYUJ D9c44u+G+tKRqqa+o1QsBbPwzAkPAjp/vp5AhiLoEtSX+WzehTMAsAB1uA6ovDZ0BqtW RyB28VI+jYFMgWkGzKcEIGvqeZo+ONcy4K5odVmLpSYC8E+2V2111od809enCvIAlUwf movRSE6GuTAS7XzDArjLRAdNIlt16US/yEV4+LeINGqO6AMoRe0s/oVE+l44DPO2zvZj m3TQ== 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=S1Y8wTl2wCcrU0k1huUV064vToavb00IavIF6/ytSuo=; b=q8RLjGquzKE2pHKr1mwdUSB5Vg1FYeijbCVCG51LTJqOyuut4XAT2ukkDDm83oRcV0 DXS+2xLHelXwsOUI6u57B4gHmzkILLC93LSNsAkR3OAIil4+rFyaxeOfoX7fncBK3gIb WAQWOKNhv+e/s4hC2ihx0uvYdc0whf71uclvHR8QYdRB0KQeJQ185FdzcwFKc8tVDfal eLhLrqZndKcjeP9JY60kgQG9LIlBTXwtnj7hFR/iu/uPgjfP90cu/6QuFOd0DeMYs68R tQkRd/UZVn/yYxadC2Q/CLCbSR9E8BfbNgO15YYDMrezYx607xIpgswz7yyKbKtJPSj0 LLqQ== X-Gm-Message-State: AOAM531G/aPI0GQ3jPm+FqA/AIGWOCeUq+DFalINqpkhyy0jPAFv4wYr gZ/Qsu/qF+yFaQLLlXo+1kekV8Ni X-Google-Smtp-Source: ABdhPJzM5qytx3NA8RfbC/NPu+QdDN/Qh5Wn16zz7n9vuIUCBKm+2BQAQy1rikzTzte3HdPfHR3t7g== X-Received: by 2002:a05:6808:6ca:: with SMTP id m10mr3477886oih.27.1592317111283; Tue, 16 Jun 2020 07:18: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 u15sm275579oie.29.2020.06.16.07.18.30 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jun 2020 07:18:30 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Subject: [PATCH 42/78] plugins/core: add missing break in cb_to_tcg_flags Date: Tue, 16 Jun 2020 09:15:11 -0500 Message-Id: <20200616141547.24664-43-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> References: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::242; envelope-from=flukshun@gmail.com; helo=mail-oi1-x242.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Emilio G. Cota" , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Fixes: 54cb65d8588 Reported-by: Robert Henry Signed-off-by: Emilio G. Cota Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20200105072940.32204-1-cota@braap.org> Cc: qemu-stable@nongnu.org Message-Id: <20200225124710.14152-12-alex.bennee@linaro.org> (cherry picked from commit dcc474c69e6a59044b9bb54624bd636cbfd98aa9) Signed-off-by: Michael Roth --- plugins/core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/core.c b/plugins/core.c index 9e1b9e7a91..ed863011ba 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -286,6 +286,7 @@ static inline uint32_t cb_to_tcg_flags(enum qemu_plugin_cb_flags flags) switch (flags) { case QEMU_PLUGIN_CB_RW_REGS: ret = 0; + break; case QEMU_PLUGIN_CB_R_REGS: ret = TCG_CALL_NO_WG; break; From patchwork Tue Jun 16 14:15:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 188044 Delivered-To: patch@linaro.org Received: by 2002:a92:cf06:0:0:0:0:0 with SMTP id c6csp3717688ilo; Tue, 16 Jun 2020 07:47:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyA2f539vrRiRE+c9BBE/xVZ1lE6G/ZT+28LKqwz2tm12aJl42PdYpSBF7mwUSYi3uh3YBc X-Received: by 2002:a25:544:: with SMTP id 65mr4717760ybf.309.1592318830350; Tue, 16 Jun 2020 07:47:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592318830; cv=none; d=google.com; s=arc-20160816; b=rIgcQRpyJLOkp09geherJAFT0s7gFzT695PROg5yqWJYwRSKg5qAjgHUzIAF7GcFU2 cOmGMPy/gO5YeGshPM8Pf0NK8cCLIZ91cI/RuPoloxlvlGwj1iMv9FkbgcMSUucEqjgt lQSMcqn47HHoo0at0QPaGFYlVFsbJ+dLefrwk6fvWwyzV4+wiKnL+QMZa2b5PfhITRme PJ9lq0/1HoJTqLyl6ixrckaqQjdamcwu0bnXhQdXPx35bSgqy7AV+FO7ECgyiH6lVmV0 2+Rtx660ItyDRqGX3pgoZ9m4aJGIUJXL37Vx4ipI33bVgEyzCt6rJ3nEER+pcgALeyMm 3VWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=JwnlDNPbrLcvfJMKjMv3fUQyb6M3rRDS3gPnPd6DoeI=; b=g8iBM/uWkUuP7EM5MdlmGyiy9kKo7q9XFQa1N1RZl5IIPgFgfhaz1eO+UT+G3uGQ3s CEgZHJcucpGcWWZPa5FddopVhpYdY52pKtEKpIBD142mapAOLgrkWNQeTk/g6srGHU/N XHkoqT7sevtyNZpUpDQKWA8NR1bWz1zZMUTnUkwU/riyPIp6+70c5zDo+22dnkJtg5Zo xRtXCOTa3QGuya7IiWaexf32mkqnc5YDQbPge65lW1JOMlJa98U5ziG6FFrhumKGkQzR Fso/q6MXl8NqqBMEIn+BIRaFXpnfWNuPMSlrJMFgR/YdXbz+Y+rtYx8qYbsyenP28BLW WVUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=DQ6sTO8B; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d93si16786503ybi.258.2020.06.16.07.47.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jun 2020 07:47:10 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=DQ6sTO8B; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from localhost ([::1]:53786 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlCrl-00048l-P9 for patch@linaro.org; Tue, 16 Jun 2020 10:47:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57810) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlCQ8-0002n5-QB; Tue, 16 Jun 2020 10:18:37 -0400 Received: from mail-oi1-x244.google.com ([2607:f8b0:4864:20::244]:37871) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jlCQ6-0006p3-5Z; Tue, 16 Jun 2020 10:18:36 -0400 Received: by mail-oi1-x244.google.com with SMTP id a3so19411717oid.4; Tue, 16 Jun 2020 07:18: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 :mime-version:content-transfer-encoding; bh=JwnlDNPbrLcvfJMKjMv3fUQyb6M3rRDS3gPnPd6DoeI=; b=DQ6sTO8BmJxCdDff6CoXV8iE76R/p6LqXYLhi7td3vcF8xHszO8WGtLmEu1Gc+8eLA MFi7Euax6CM1oyw1drQc3GFy2RMzLYYxeEyB6aSfRq9m1n9ohnSoRS0NHr9UNYHkI4oV +mXlKy1e4V5EkKlFqyrbZ2lvHjdzXLt+JcZPFLvhYw0BBYWlyeAXaHth8D06oJHN5/bH 7GPrvEAOHLopp3SO2z2P5tpKsG+AKO8njIXAyZyxaRibtqIplYiq7O6goWcjT9TwpfYB 6ix2K6U7nemQmD9U/DYF5sTKsN/T2b9/ziCI2wwsWWyZoFAAQo76y3XTdFcKteqx4asT SMkA== 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=JwnlDNPbrLcvfJMKjMv3fUQyb6M3rRDS3gPnPd6DoeI=; b=lA821lgJg4v9hAVN1O4bLaz5HJgW8XayBcnxUOCkbDSY2axgS+UtXEjaVF92fJ0xVJ eJMPCb2gzEXzVkBdNHNq2okOHR+xnGjL6cbwv86iiSF9Sgx2KG4lSRKtHOnf2gEKVs0s 60ylh6x7rug3IX5H8uVu54mw1bRH3niUiNxbXHRkUlKQ52jtR3aeZuuR697qiBSSpncN 80FUx7s0CWb5Ij3h1MqFoJU0/6GeSYV8fWsJFHNUVAWO7uL3K5QF9vQtyTmJ7Ax385XK zZWp40koroZMUzH2iB5KmQhbyYizgUvi61Y1K/IqhAIzKxtoi3Fs1vYywiOC67oyiCKr Fh9A== X-Gm-Message-State: AOAM531Lg85tbYtc2tSv4z5Eq0nkD5kZVKx0tCIRLsC4RVcSy5wOhWHH JsR18U/jfQBZhaecumRmBdnqv8XA X-Received: by 2002:a54:4718:: with SMTP id k24mr3241700oik.133.1592317112536; Tue, 16 Jun 2020 07:18: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 w10sm4087452otp.44.2020.06.16.07.18.31 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jun 2020 07:18:31 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Subject: [PATCH 43/78] tcg: save vaddr temp for plugin usage Date: Tue, 16 Jun 2020 09:15:12 -0500 Message-Id: <20200616141547.24664-44-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> References: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::244; envelope-from=flukshun@gmail.com; helo=mail-oi1-x244.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Alex Bennée While do_gen_mem_cb does copy (via extu_tl_i64) vaddr into a new temp this won't help if the vaddr temp gets clobbered by the actual load/store op. To avoid this clobbering we explicitly copy vaddr before the op to ensure it is live my the time we do the instrumentation. Suggested-by: Richard Henderson Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson Reviewed-by: Emilio G. Cota Cc: qemu-stable@nongnu.org Message-Id: <20200225124710.14152-18-alex.bennee@linaro.org> (cherry picked from commit fcc54ab5c7ca84ae72e8bf3781c33c9193a911aa) Signed-off-by: Michael Roth --- tcg/tcg-op.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) -- 2.17.1 diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c index c245126f98..eb5d172e49 100644 --- a/tcg/tcg-op.c +++ b/tcg/tcg-op.c @@ -2794,13 +2794,26 @@ static void tcg_gen_req_mo(TCGBar type) } } +static inline TCGv plugin_prep_mem_callbacks(TCGv vaddr) +{ +#ifdef CONFIG_PLUGIN + if (tcg_ctx->plugin_insn != NULL) { + /* Save a copy of the vaddr for use after a load. */ + TCGv temp = tcg_temp_new(); + tcg_gen_mov_tl(temp, vaddr); + return temp; + } +#endif + return vaddr; +} + static inline void plugin_gen_mem_callbacks(TCGv vaddr, uint16_t info) { #ifdef CONFIG_PLUGIN - if (tcg_ctx->plugin_insn == NULL) { - return; + if (tcg_ctx->plugin_insn != NULL) { + plugin_gen_empty_mem_callback(vaddr, info); + tcg_temp_free(vaddr); } - plugin_gen_empty_mem_callback(vaddr, info); #endif } @@ -2822,6 +2835,7 @@ void tcg_gen_qemu_ld_i32(TCGv_i32 val, TCGv addr, TCGArg idx, MemOp memop) } } + addr = plugin_prep_mem_callbacks(addr); gen_ldst_i32(INDEX_op_qemu_ld_i32, val, addr, memop, idx); plugin_gen_mem_callbacks(addr, info); @@ -2868,6 +2882,7 @@ void tcg_gen_qemu_st_i32(TCGv_i32 val, TCGv addr, TCGArg idx, MemOp memop) memop &= ~MO_BSWAP; } + addr = plugin_prep_mem_callbacks(addr); gen_ldst_i32(INDEX_op_qemu_st_i32, val, addr, memop, idx); plugin_gen_mem_callbacks(addr, info); @@ -2905,6 +2920,7 @@ void tcg_gen_qemu_ld_i64(TCGv_i64 val, TCGv addr, TCGArg idx, MemOp memop) } } + addr = plugin_prep_mem_callbacks(addr); gen_ldst_i64(INDEX_op_qemu_ld_i64, val, addr, memop, idx); plugin_gen_mem_callbacks(addr, info); @@ -2967,6 +2983,7 @@ void tcg_gen_qemu_st_i64(TCGv_i64 val, TCGv addr, TCGArg idx, MemOp memop) memop &= ~MO_BSWAP; } + addr = plugin_prep_mem_callbacks(addr); gen_ldst_i64(INDEX_op_qemu_st_i64, val, addr, memop, idx); plugin_gen_mem_callbacks(addr, info); From patchwork Tue Jun 16 14:15:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 280339 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A9A25C433E0 for ; Tue, 16 Jun 2020 14:42:36 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7A39220882 for ; Tue, 16 Jun 2020 14:42:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HmOUrGKU" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7A39220882 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:35608 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlCnL-0004Ip-MY for qemu-devel@archiver.kernel.org; Tue, 16 Jun 2020 10:42:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57870) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlCQE-00030h-RH; Tue, 16 Jun 2020 10:18:46 -0400 Received: from mail-ot1-x331.google.com ([2607:f8b0:4864:20::331]:33084) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jlCQD-0006to-9U; Tue, 16 Jun 2020 10:18:42 -0400 Received: by mail-ot1-x331.google.com with SMTP id n6so16067638otl.0; Tue, 16 Jun 2020 07:18: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=Z/IEPTuPLem1LbcsQ8EirE06h15XALksmXQzNW0/kN0=; b=HmOUrGKUSQaGJnZWkCXwLwn84XIjmPrDe7NxQfcT6r8CHjdZKz9gI0wqjA8RC5oPO9 zTnZUcmJM1YRYdqa+brIF3VnIdvy2v2UmfSVzMhU7xp+uepuse471+SVx3Qgk+qDjyr0 vLLm94Mw2Y/OO+L6m7HE9fa4MW+Lz7up6fFyZJ0agaBPMKdGZOjXy+NnDuE1T1aKSXv0 PjPL9wxiNlmFnHaIVwJJ7UdVhx+rPSLVHcadk5OkOk6kXgPu1+LPnzOFJ35YZlxjvvmV PASnr92fzPu0KMn/rwWjl7g3jKif0KF9dFOClf1xr8cPRTm+ZrCLxbGNHS3butuBhdWn A5kA== 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=Z/IEPTuPLem1LbcsQ8EirE06h15XALksmXQzNW0/kN0=; b=TPTbmoclPjGWQEN+WcBxvIiy1k1nXNvRm3bzrkDb66OYa1jC8KETUC9UnbpcDlgJt7 e0yYM1PMz7iNbir+agL1aVOYXJSjf6YNvWC13SW4IDSawbYMLxyfcOor4HyFtlBKwg1g dhiIEBa/pfEkb1dDAy8PUchbfsHdWRKb1tAy0RkBld/xDRc4BNhvL+IbQTkeysMFcPWV mQLF8uSTF7cFiDAZ+Mb9/xfnGJb/CyQQIOl4LjnCUql7qb5Rvsocn/FFkfeDvJ0Oqbar 2Xoua5kt4evlyfeS1tKLQGctskK/EH0Qxngvty0s18np5LcjWh22P1lxQ5Dydf52ikPY 9XkA== X-Gm-Message-State: AOAM533FXhhI0ZrsTXWfQWDyDz3aPj15YagloZqRRQ4UVrKFYGBPi5lP BPoLBUuC+2NSfOd78KDi7L4523QD X-Google-Smtp-Source: ABdhPJyN7+rmq1LVwe42qIaf+uH2LQcWEs+Qj8d6O78YIuEoUEk7LrSp9P2vy1X+JszvFCKdo6d6bA== X-Received: by 2002:a05:6830:1512:: with SMTP id k18mr2616069otp.37.1592317119076; Tue, 16 Jun 2020 07:18:39 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id x6sm2880173ooe.5.2020.06.16.07.18.38 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jun 2020 07:18:38 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Subject: [PATCH 48/78] iotests/026: Test EIO on preallocated zero cluster Date: Tue, 16 Jun 2020 09:15:17 -0500 Message-Id: <20200616141547.24664-49-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> References: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::331; envelope-from=flukshun@gmail.com; helo=mail-ot1-x331.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-stable@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Max Reitz Test what happens when writing data to a preallocated zero cluster, but the data write fails. Signed-off-by: Max Reitz Message-Id: <20200225143130.111267-3-mreitz@redhat.com> Signed-off-by: Kevin Wolf (cherry picked from commit 31ab00f3747c00fdbb9027cea644b40dd1405480) Signed-off-by: Michael Roth --- tests/qemu-iotests/026 | 21 +++++++++++++++++++++ tests/qemu-iotests/026.out | 10 ++++++++++ tests/qemu-iotests/026.out.nocache | 10 ++++++++++ 3 files changed, 41 insertions(+) diff --git a/tests/qemu-iotests/026 b/tests/qemu-iotests/026 index 3430029ed6..d89729697f 100755 --- a/tests/qemu-iotests/026 +++ b/tests/qemu-iotests/026 @@ -215,6 +215,27 @@ _make_test_img 64M $QEMU_IO -c "write 0 1M" -c "write 0 1M" "$BLKDBG_TEST_IMG" | _filter_qemu_io _check_test_img +echo +echo === Avoid freeing preallocated zero clusters on failure === +echo + +cat > "$TEST_DIR/blkdebug.conf" < X-Patchwork-Id: 280333 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8F39AC433E0 for ; Tue, 16 Jun 2020 14:49:17 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5EE73208B3 for ; Tue, 16 Jun 2020 14:49:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BMyCatf7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5EE73208B3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:37140 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlCto-0000ZL-GU for qemu-devel@archiver.kernel.org; Tue, 16 Jun 2020 10:49:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57900) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlCQK-00036B-JM; Tue, 16 Jun 2020 10:18:48 -0400 Received: from mail-oi1-x22f.google.com ([2607:f8b0:4864:20::22f]:44003) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jlCQI-0006u6-TZ; Tue, 16 Jun 2020 10:18:48 -0400 Received: by mail-oi1-x22f.google.com with SMTP id j189so19335373oih.10; Tue, 16 Jun 2020 07:18: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=uvyAq22LZpRLFDPeqbXH7QRTPLBpYz1NSiWqpfZpfYg=; b=BMyCatf75+tnK8vU/KBC59W0QgZqlGVForqrSq1Q6xc8DuCTyPFcAUWu9Jm6yonbqQ TExSublKlZ8iXV5mDvtTdH6UYnMCmTEVYjv1ku6Mlhpm1bjJv5h9ifEZ88CQNjI2Hv3y otgKAmbykqsxx1livqpeNRiVnM0UyxkHHwC8yXrxO9d34A9GaOc/moaWO6oSCSscLbR7 5KhH7aEnzBH3yxR2so4oLc9rjBT+Mj3nqdMUHHWs8aMM1dE9scwCnNnPmv7kGJPiV+mp VvgaDZPwd3rKbP72Wxl+jb99tuki+Qvsw+E1xLKlzvKG2a3EYpLpAzvBddTFf8MzobqZ K7Jg== 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=uvyAq22LZpRLFDPeqbXH7QRTPLBpYz1NSiWqpfZpfYg=; b=iRlEh5qOj1rPmagd4q1hUtqAkLKhGDP57zNGP9e7IpUzIt+qNPrhG5WRlRamseuFrE ku1yMfOQaidLjeluAciRs9j3bH3mplrpR4T7nSjvHaXg4Xd81ma/7Rby6WlZ1h4ecNS5 Yh+vxf6666+B9Z04fzhYOF/hyCwtH5eh+oHDvd4NnV0X/gy01sjMhwqoGDUrIXbSOT+E bmzEIcHQbdUbCuZyj2ipgv2crMpz/UWjGcFH1/sfs887FXn4qHcDWy88EKF+9MAux0UQ AGVJumJKM1/3qPwv9Q79XjmV5tGllscqwNfq2hZcSrD6a3xU45HmKIeCnggy28ifI1pZ 7fBA== X-Gm-Message-State: AOAM533GjCLm70AoGNaedLnVxiFZ3IO1FkrbO4YzxCxliOz9NlSVGXKI OMp0CijOmhHgCf8PzINIK6alLdj/ X-Google-Smtp-Source: ABdhPJzCkYT8mgvg/PpJRcol5Oad5nfYzaKSveTXknJISbylDgZ0tl5j5EEhRrxv4pLdWL+5MFuzfg== X-Received: by 2002:a05:6808:4b:: with SMTP id v11mr3387714oic.31.1592317121076; Tue, 16 Jun 2020 07:18: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 m94sm4078517otm.19.2020.06.16.07.18.39 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jun 2020 07:18:39 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Subject: [PATCH 49/78] iotests/026: Test EIO on allocation in a data-file Date: Tue, 16 Jun 2020 09:15:18 -0500 Message-Id: <20200616141547.24664-50-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> References: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::22f; envelope-from=flukshun@gmail.com; helo=mail-oi1-x22f.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-stable@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Max Reitz Test what happens when writing data to an external data file, where the write requires an L2 entry to be allocated, but the data write fails. Signed-off-by: Max Reitz Message-Id: <20200225143130.111267-4-mreitz@redhat.com> Signed-off-by: Kevin Wolf (cherry picked from commit 81311255f217859413c94f2cd9cebf2684bbda94) Signed-off-by: Michael Roth --- tests/qemu-iotests/026 | 32 ++++++++++++++++++++++++++++++ tests/qemu-iotests/026.out | 6 ++++++ tests/qemu-iotests/026.out.nocache | 6 ++++++ 3 files changed, 44 insertions(+) diff --git a/tests/qemu-iotests/026 b/tests/qemu-iotests/026 index d89729697f..c1c96a41d9 100755 --- a/tests/qemu-iotests/026 +++ b/tests/qemu-iotests/026 @@ -30,6 +30,7 @@ _cleanup() { _cleanup_test_img rm "$TEST_DIR/blkdebug.conf" + rm -f "$TEST_IMG.data_file" } trap "_cleanup; exit \$status" 0 1 2 3 15 @@ -236,6 +237,37 @@ $QEMU_IO -c "write 0 $CLUSTER_SIZE" "$BLKDBG_TEST_IMG" | _filter_qemu_io _check_test_img +echo +echo === Avoid freeing external data clusters on failure === +echo + +# Similar test as the last one, except we test what happens when there +# is an error when writing to an external data file instead of when +# writing to a preallocated zero cluster +_make_test_img -o "data_file=$TEST_IMG.data_file" $CLUSTER_SIZE + +# Put blkdebug above the data-file, and a raw node on top of that so +# that blkdebug will see a write_aio event and emit an error +$QEMU_IO -c "write 0 $CLUSTER_SIZE" \ + "json:{ + 'driver': 'qcow2', + 'file': { 'driver': 'file', 'filename': '$TEST_IMG' }, + 'data-file': { + 'driver': 'raw', + 'file': { + 'driver': 'blkdebug', + 'config': '$TEST_DIR/blkdebug.conf', + 'image': { + 'driver': 'file', + 'filename': '$TEST_IMG.data_file' + } + } + } + }" \ + | _filter_qemu_io + +_check_test_img + # success, all done echo "*** done" rm -f $seq.full diff --git a/tests/qemu-iotests/026.out b/tests/qemu-iotests/026.out index 83989996ff..c1b3b58482 100644 --- a/tests/qemu-iotests/026.out +++ b/tests/qemu-iotests/026.out @@ -653,4 +653,10 @@ wrote 1024/1024 bytes at offset 0 1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) write failed: Input/output error No errors were found on the image. + +=== Avoid freeing external data clusters on failure === + +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1024 data_file=TEST_DIR/t.IMGFMT.data_file +write failed: Input/output error +No errors were found on the image. *** done diff --git a/tests/qemu-iotests/026.out.nocache b/tests/qemu-iotests/026.out.nocache index 9359d26d7e..8d5001648a 100644 --- a/tests/qemu-iotests/026.out.nocache +++ b/tests/qemu-iotests/026.out.nocache @@ -661,4 +661,10 @@ wrote 1024/1024 bytes at offset 0 1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) write failed: Input/output error No errors were found on the image. + +=== Avoid freeing external data clusters on failure === + +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1024 data_file=TEST_DIR/t.IMGFMT.data_file +write failed: Input/output error +No errors were found on the image. *** done From patchwork Tue Jun 16 14:15:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 280332 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 34639C433E0 for ; Tue, 16 Jun 2020 14:49:39 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id ECF1D208B8 for ; Tue, 16 Jun 2020 14:49:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MYVwFBH7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ECF1D208B8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:39176 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlCuA-0001OF-7r for qemu-devel@archiver.kernel.org; Tue, 16 Jun 2020 10:49:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57920) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlCQM-00039l-21; Tue, 16 Jun 2020 10:18:50 -0400 Received: from mail-ot1-x342.google.com ([2607:f8b0:4864:20::342]:41881) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jlCQI-0006uI-UC; Tue, 16 Jun 2020 10:18:49 -0400 Received: by mail-ot1-x342.google.com with SMTP id k15so16043643otp.8; Tue, 16 Jun 2020 07:18: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=SgpdSwyB/UPAjpHte2vWC5d1tT7Kus4ixfvhv062JB4=; b=MYVwFBH7/AnBnwQ9A2eK8LFphytp8bU3pr/4X3LPC/jAKosUDZqoKZk7NzToK98JEz YIPZ73mGRHWalaaAsGcLg4rDCoPXnMOZn9SUUNw4EZMkrczWsbOnL/XBVuejR67llLgo JSHMGKGeFt3EPut/Y24TDy0JoAyZuxvFFvkcPVinFjzdE3XL1GDep4PBeAo52uBQhY1P 9sUE5XR6sYAz83dIaJAk4ML5SUI7T+4mSCeKnQJ1KGdgeW2rRhA3LkT19weuSPLk7QLJ EquGD0SlIadpksv/VnSdI35FX//2h23b9E7BOW+ewrnVK/VNCleIwK3W8EV1U2Mt3rs+ 2wxA== 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=SgpdSwyB/UPAjpHte2vWC5d1tT7Kus4ixfvhv062JB4=; b=dlyVNQjtCiRDEmUcm/RoM9PfNcvrcMtHgA/bq/5kPcRH4CLOcW2NFOhJizZ4ROA//3 hAFyhuzvNNcwanoWMcxw2R9eO88UKhPvmNUn0SCVZMB1pLKy67UZUfZKrSQsbFeFcbsG FDKTUpRWlT8ftQyQHj+nZ7wyJN8BfzXK/QoIGXcwQwjSeLaNkjBWK7prcpgeb9+uGxcQ WZ/w8MLXf4BA1Y+rA4I32dY5bQdvPrZ49sk8ipZsMSiDlmBCvUILCZTPjpVBmNDUsu+s 6R9yJt6cXiBsXE6kO4gYjGd9iX65AMbtp8V8NoGu0t8zxLb4aV2aUe0dhMog9rvlJbba h7xw== X-Gm-Message-State: AOAM533o+Duh9riDck214BE3EfBTHY4MuNdWHDaQuqIPLQ4CldzZoXoq 3iGDNopdeX9HWNvAmNs9x1SQLBJ2 X-Google-Smtp-Source: ABdhPJw575GwJSJIKal5/MbtrI6wUpCYlFqgB+cYolkPOq7hIJCi05KVx01bi+3n0IykxXgHJVDxkw== X-Received: by 2002:a9d:34c:: with SMTP id 70mr2662442otv.224.1592317123373; Tue, 16 Jun 2020 07:18: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 f1sm4093085ool.16.2020.06.16.07.18.41 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jun 2020 07:18:41 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Subject: [PATCH 50/78] virtio: gracefully handle invalid region caches Date: Tue, 16 Jun 2020 09:15:19 -0500 Message-Id: <20200616141547.24664-51-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> References: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::342; envelope-from=flukshun@gmail.com; helo=mail-ot1-x342.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Cornelia Huck , qemu-stable@nongnu.org, Stefan Hajnoczi , Michael Tsirkin Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Stefan Hajnoczi The virtqueue code sets up MemoryRegionCaches to access the virtqueue guest RAM data structures. The code currently assumes that VRingMemoryRegionCaches is initialized before device emulation code accesses the virtqueue. An assertion will fail in vring_get_region_caches() when this is not true. Device fuzzing found a case where this assumption is false (see below). Virtqueue guest RAM addresses can also be changed from a vCPU thread while an IOThread is accessing the virtqueue. This breaks the same assumption but this time the caches could become invalid partway through the virtqueue code. The code fetches the caches RCU pointer multiple times so we will need to validate the pointer every time it is fetched. Add checks each time we call vring_get_region_caches() and treat invalid caches as a nop: memory stores are ignored and memory reads return 0. The fuzz test failure is as follows: $ qemu -M pc -device virtio-blk-pci,id=drv0,drive=drive0,addr=4.0 \ -drive if=none,id=drive0,file=null-co://,format=raw,auto-read-only=off \ -drive if=none,id=drive1,file=null-co://,file.read-zeroes=on,format=raw \ -display none \ -qtest stdio endianness outl 0xcf8 0x80002020 outl 0xcfc 0xe0000000 outl 0xcf8 0x80002004 outw 0xcfc 0x7 write 0xe0000000 0x24 0x00ffffffabffffffabffffffabffffffabffffffabffffffabffffffabffffffabffffffabffffffabffffffabffffffabffffffabffffffab5cffffffabffffffabffffffabffffffabffffffabffffffabffffffabffffffabffffffabffffffabffffffabffffffabffffffabffffffabffffffab0000000001 inb 0x4 writew 0xe000001c 0x1 write 0xe0000014 0x1 0x0d The following error message is produced: qemu-system-x86_64: /home/stefanha/qemu/hw/virtio/virtio.c:286: vring_get_region_caches: Assertion `caches != NULL' failed. The backtrace looks like this: #0 0x00007ffff5520625 in raise () at /lib64/libc.so.6 #1 0x00007ffff55098d9 in abort () at /lib64/libc.so.6 #2 0x00007ffff55097a9 in _nl_load_domain.cold () at /lib64/libc.so.6 #3 0x00007ffff5518a66 in annobin_assert.c_end () at /lib64/libc.so.6 #4 0x00005555559073da in vring_get_region_caches (vq=) at qemu/hw/virtio/virtio.c:286 #5 vring_get_region_caches (vq=) at qemu/hw/virtio/virtio.c:283 #6 0x000055555590818d in vring_used_flags_set_bit (mask=1, vq=0x5555575ceea0) at qemu/hw/virtio/virtio.c:398 #7 virtio_queue_split_set_notification (enable=0, vq=0x5555575ceea0) at qemu/hw/virtio/virtio.c:398 #8 virtio_queue_set_notification (vq=vq@entry=0x5555575ceea0, enable=enable@entry=0) at qemu/hw/virtio/virtio.c:451 #9 0x0000555555908512 in virtio_queue_set_notification (vq=vq@entry=0x5555575ceea0, enable=enable@entry=0) at qemu/hw/virtio/virtio.c:444 #10 0x00005555558c697a in virtio_blk_handle_vq (s=0x5555575c57e0, vq=0x5555575ceea0) at qemu/hw/block/virtio-blk.c:775 #11 0x0000555555907836 in virtio_queue_notify_aio_vq (vq=0x5555575ceea0) at qemu/hw/virtio/virtio.c:2244 #12 0x0000555555cb5dd7 in aio_dispatch_handlers (ctx=ctx@entry=0x55555671a420) at util/aio-posix.c:429 #13 0x0000555555cb67a8 in aio_dispatch (ctx=0x55555671a420) at util/aio-posix.c:460 #14 0x0000555555cb307e in aio_ctx_dispatch (source=, callback=, user_data=) at util/async.c:260 #15 0x00007ffff7bbc510 in g_main_context_dispatch () at /lib64/libglib-2.0.so.0 #16 0x0000555555cb5848 in glib_pollfds_poll () at util/main-loop.c:219 #17 os_host_main_loop_wait (timeout=) at util/main-loop.c:242 #18 main_loop_wait (nonblocking=) at util/main-loop.c:518 #19 0x00005555559b20c9 in main_loop () at vl.c:1683 #20 0x0000555555838115 in main (argc=, argv=, envp=) at vl.c:4441 Reported-by: Alexander Bulekov Cc: Michael Tsirkin Cc: Cornelia Huck Cc: Paolo Bonzini Cc: qemu-stable@nongnu.org Signed-off-by: Stefan Hajnoczi Message-Id: <20200207104619.164892-1-stefanha@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin (cherry picked from commit abdd16f4681cc4d6bf84990227b5c9b98e869ccd) Signed-off-by: Michael Roth --- hw/virtio/virtio.c | 99 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 91 insertions(+), 8 deletions(-) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 344d817644..6c71141ed1 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -282,15 +282,19 @@ static void vring_packed_flags_write(VirtIODevice *vdev, /* Called within rcu_read_lock(). */ static VRingMemoryRegionCaches *vring_get_region_caches(struct VirtQueue *vq) { - VRingMemoryRegionCaches *caches = atomic_rcu_read(&vq->vring.caches); - assert(caches != NULL); - return caches; + return atomic_rcu_read(&vq->vring.caches); } + /* Called within rcu_read_lock(). */ static inline uint16_t vring_avail_flags(VirtQueue *vq) { VRingMemoryRegionCaches *caches = vring_get_region_caches(vq); hwaddr pa = offsetof(VRingAvail, flags); + + if (!caches) { + return 0; + } + return virtio_lduw_phys_cached(vq->vdev, &caches->avail, pa); } @@ -299,6 +303,11 @@ static inline uint16_t vring_avail_idx(VirtQueue *vq) { VRingMemoryRegionCaches *caches = vring_get_region_caches(vq); hwaddr pa = offsetof(VRingAvail, idx); + + if (!caches) { + return 0; + } + vq->shadow_avail_idx = virtio_lduw_phys_cached(vq->vdev, &caches->avail, pa); return vq->shadow_avail_idx; } @@ -308,6 +317,11 @@ static inline uint16_t vring_avail_ring(VirtQueue *vq, int i) { VRingMemoryRegionCaches *caches = vring_get_region_caches(vq); hwaddr pa = offsetof(VRingAvail, ring[i]); + + if (!caches) { + return 0; + } + return virtio_lduw_phys_cached(vq->vdev, &caches->avail, pa); } @@ -323,6 +337,11 @@ static inline void vring_used_write(VirtQueue *vq, VRingUsedElem *uelem, { VRingMemoryRegionCaches *caches = vring_get_region_caches(vq); hwaddr pa = offsetof(VRingUsed, ring[i]); + + if (!caches) { + return; + } + virtio_tswap32s(vq->vdev, &uelem->id); virtio_tswap32s(vq->vdev, &uelem->len); address_space_write_cached(&caches->used, pa, uelem, sizeof(VRingUsedElem)); @@ -334,6 +353,11 @@ static uint16_t vring_used_idx(VirtQueue *vq) { VRingMemoryRegionCaches *caches = vring_get_region_caches(vq); hwaddr pa = offsetof(VRingUsed, idx); + + if (!caches) { + return 0; + } + return virtio_lduw_phys_cached(vq->vdev, &caches->used, pa); } @@ -342,8 +366,12 @@ static inline void vring_used_idx_set(VirtQueue *vq, uint16_t val) { VRingMemoryRegionCaches *caches = vring_get_region_caches(vq); hwaddr pa = offsetof(VRingUsed, idx); - virtio_stw_phys_cached(vq->vdev, &caches->used, pa, val); - address_space_cache_invalidate(&caches->used, pa, sizeof(val)); + + if (caches) { + virtio_stw_phys_cached(vq->vdev, &caches->used, pa, val); + address_space_cache_invalidate(&caches->used, pa, sizeof(val)); + } + vq->used_idx = val; } @@ -353,8 +381,13 @@ static inline void vring_used_flags_set_bit(VirtQueue *vq, int mask) VRingMemoryRegionCaches *caches = vring_get_region_caches(vq); VirtIODevice *vdev = vq->vdev; hwaddr pa = offsetof(VRingUsed, flags); - uint16_t flags = virtio_lduw_phys_cached(vq->vdev, &caches->used, pa); + uint16_t flags; + if (!caches) { + return; + } + + flags = virtio_lduw_phys_cached(vq->vdev, &caches->used, pa); virtio_stw_phys_cached(vdev, &caches->used, pa, flags | mask); address_space_cache_invalidate(&caches->used, pa, sizeof(flags)); } @@ -365,8 +398,13 @@ static inline void vring_used_flags_unset_bit(VirtQueue *vq, int mask) VRingMemoryRegionCaches *caches = vring_get_region_caches(vq); VirtIODevice *vdev = vq->vdev; hwaddr pa = offsetof(VRingUsed, flags); - uint16_t flags = virtio_lduw_phys_cached(vq->vdev, &caches->used, pa); + uint16_t flags; + if (!caches) { + return; + } + + flags = virtio_lduw_phys_cached(vq->vdev, &caches->used, pa); virtio_stw_phys_cached(vdev, &caches->used, pa, flags & ~mask); address_space_cache_invalidate(&caches->used, pa, sizeof(flags)); } @@ -381,6 +419,10 @@ static inline void vring_set_avail_event(VirtQueue *vq, uint16_t val) } caches = vring_get_region_caches(vq); + if (!caches) { + return; + } + pa = offsetof(VRingUsed, ring[vq->vring.num]); virtio_stw_phys_cached(vq->vdev, &caches->used, pa, val); address_space_cache_invalidate(&caches->used, pa, sizeof(val)); @@ -410,7 +452,11 @@ static void virtio_queue_packed_set_notification(VirtQueue *vq, int enable) VRingMemoryRegionCaches *caches; RCU_READ_LOCK_GUARD(); - caches = vring_get_region_caches(vq); + caches = vring_get_region_caches(vq); + if (!caches) { + return; + } + vring_packed_event_read(vq->vdev, &caches->used, &e); if (!enable) { @@ -592,6 +638,10 @@ static int virtio_queue_packed_empty_rcu(VirtQueue *vq) } cache = vring_get_region_caches(vq); + if (!cache) { + return 1; + } + vring_packed_desc_read_flags(vq->vdev, &desc.flags, &cache->desc, vq->last_avail_idx); @@ -772,6 +822,10 @@ static void virtqueue_packed_fill_desc(VirtQueue *vq, } caches = vring_get_region_caches(vq); + if (!caches) { + return; + } + vring_packed_desc_write(vq->vdev, &desc, &caches->desc, head, strict_order); } @@ -944,6 +998,10 @@ static void virtqueue_split_get_avail_bytes(VirtQueue *vq, max = vq->vring.num; caches = vring_get_region_caches(vq); + if (!caches) { + goto err; + } + while ((rc = virtqueue_num_heads(vq, idx)) > 0) { MemoryRegionCache *desc_cache = &caches->desc; unsigned int num_bufs; @@ -1084,6 +1142,9 @@ static void virtqueue_packed_get_avail_bytes(VirtQueue *vq, max = vq->vring.num; caches = vring_get_region_caches(vq); + if (!caches) { + goto err; + } for (;;) { unsigned int num_bufs = total_bufs; @@ -1189,6 +1250,10 @@ void virtqueue_get_avail_bytes(VirtQueue *vq, unsigned int *in_bytes, } caches = vring_get_region_caches(vq); + if (!caches) { + goto err; + } + desc_size = virtio_vdev_has_feature(vq->vdev, VIRTIO_F_RING_PACKED) ? sizeof(VRingPackedDesc) : sizeof(VRingDesc); if (caches->desc.len < vq->vring.num * desc_size) { @@ -1382,6 +1447,11 @@ static void *virtqueue_split_pop(VirtQueue *vq, size_t sz) i = head; caches = vring_get_region_caches(vq); + if (!caches) { + virtio_error(vdev, "Region caches not initialized"); + goto done; + } + if (caches->desc.len < max * sizeof(VRingDesc)) { virtio_error(vdev, "Cannot map descriptor ring"); goto done; @@ -1504,6 +1574,11 @@ static void *virtqueue_packed_pop(VirtQueue *vq, size_t sz) i = vq->last_avail_idx; caches = vring_get_region_caches(vq); + if (!caches) { + virtio_error(vdev, "Region caches not initialized"); + goto done; + } + if (caches->desc.len < max * sizeof(VRingDesc)) { virtio_error(vdev, "Cannot map descriptor ring"); goto done; @@ -1623,6 +1698,10 @@ static unsigned int virtqueue_packed_drop_all(VirtQueue *vq) VRingPackedDesc desc; caches = vring_get_region_caches(vq); + if (!caches) { + return 0; + } + desc_cache = &caches->desc; virtio_queue_set_notification(vq, 0); @@ -2406,6 +2485,10 @@ static bool virtio_packed_should_notify(VirtIODevice *vdev, VirtQueue *vq) VRingMemoryRegionCaches *caches; caches = vring_get_region_caches(vq); + if (!caches) { + return false; + } + vring_packed_event_read(vdev, &caches->avail, &e); old = vq->signalled_used; From patchwork Tue Jun 16 14:15:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 280335 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 17B06C433E0 for ; Tue, 16 Jun 2020 14:47:13 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 976F2208B8 for ; Tue, 16 Jun 2020 14:47:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LsudBc9i" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 976F2208B8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:56108 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlCrn-00055K-Pr for qemu-devel@archiver.kernel.org; Tue, 16 Jun 2020 10:47:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57942) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlCQO-0003Ee-5F; Tue, 16 Jun 2020 10:18:52 -0400 Received: from mail-oi1-x243.google.com ([2607:f8b0:4864:20::243]:43686) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jlCQM-0006uw-JB; Tue, 16 Jun 2020 10:18:51 -0400 Received: by mail-oi1-x243.google.com with SMTP id j189so19335790oih.10; Tue, 16 Jun 2020 07:18: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 :mime-version:content-transfer-encoding; bh=U7J2TqZ1ks8KNH7mIqSpb6zD0BiSTiY4lPX/uz7chis=; b=LsudBc9irn12ll41uXuWAfo+MOHKdy5VJgTNuXGo7I9aj1VBx74Ot75xvrLZIydr2g v4nLwd90MsuF0XTOl5Cwbudyy6Oz09Fdhl0xYdTvsoJSTjFpRFIoTvEq+L1LxtBl0EoZ kDybpw1pJdJFsXO+ZZ4T/a6fmTZ5VUDwuCVxgmHVBBdVg7diqo+rHNiJ3XX5m4O/LJ0g z5pgQbFbQtXsTH/htaTpfbZnW0fp/95q1O9ZSdTzIo+IitmyWVLSRf6MVnEK89zhR5s7 /QWIBP41/B2++1vxllA9XLDAKD9hQxzhL1CsejreHgWViht4UOQHWnTc3xc2bl2TVrw7 dukw== 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=U7J2TqZ1ks8KNH7mIqSpb6zD0BiSTiY4lPX/uz7chis=; b=nOD9PfhD/tOaQABGbp1zzCs0o6v9/eRnRmTclSMAx4AUXfoGK1lA9i1KQ9paG7yBVM CeFFpjG8MNpkm9I/ecA3HxhiIOHag1/ZYR3zUv8eg4zfDIZVLqiHjWmNy10pCUuwbGkh 2o7vx+V7RQuJ4uJkU+9WwPnUXDpgyd7lvNMVKSIFb5cDX6bB5cMHiHd3gf0RM0rjC93v G+E+yjkRD75V2W9m8AliePxHAWm4GpigE8KzywtHsQZI1ENulEcA8gsHyow4jQE2EavP FQswHXTA3t/TSSkjtHKgjXsK0KdA1m5HtRMI2nA2RaeA2GYFAXrpYXaWS5Y/r/zX3hn3 53zA== X-Gm-Message-State: AOAM533nxAV0yFXsWJKyPqBGkZ9yLcgBXsjDXdfdgFHaLzSXX89GVHtg MurAYk9+C8e6y7IG2qCdt4qJaMKf X-Google-Smtp-Source: ABdhPJzx/fWZpwsFoWHuJuIXAHDmV8uOqg6JcpZDnUy2K/AzBn9aajdchNTjFX1UOPANstr3M6z2ag== X-Received: by 2002:aca:1b13:: with SMTP id b19mr3649055oib.132.1592317128547; Tue, 16 Jun 2020 07:18: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 m18sm4155574ooe.12.2020.06.16.07.18.46 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jun 2020 07:18:46 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Subject: [PATCH 51/78] scsi/qemu-pr-helper: Fix out-of-bounds access to trnptid_list[] Date: Tue, 16 Jun 2020 09:15:20 -0500 Message-Id: <20200616141547.24664-52-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> References: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::243; envelope-from=flukshun@gmail.com; helo=mail-oi1-x243.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christophe de Dinechin , Paolo Bonzini , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Christophe de Dinechin Compile error reported by gcc 10.0.1: scsi/qemu-pr-helper.c: In function ‘multipath_pr_out’: scsi/qemu-pr-helper.c:523:32: error: array subscript is outside array bounds of ‘struct transportid *[0]’ [-Werror=array-bounds] 523 | paramp.trnptid_list[paramp.num_transportid++] = id; | ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from scsi/qemu-pr-helper.c:36: /usr/include/mpath_persist.h:168:22: note: while referencing ‘trnptid_list’ 168 | struct transportid *trnptid_list[]; | ^~~~~~~~~~~~ scsi/qemu-pr-helper.c:424:35: note: defined here ‘paramp’ 424 | struct prout_param_descriptor paramp; | ^~~~~~ This highlights an actual implementation issue in function multipath_pr_out. The variable paramp is declared with type `struct prout_param_descriptor`, which is a struct terminated by an empty array in mpath_persist.h: struct transportid *trnptid_list[]; That empty array was filled with code that looked like that: trnptid_list[paramp.descr.num_transportid++] = id; This is an actual out-of-bounds access. The fix is to malloc `paramp`. Signed-off-by: Christophe de Dinechin Signed-off-by: Paolo Bonzini (cherry picked from commit 4ce1e15fbc7266a108a7c77a3962644b3935346e) Signed-off-by: Michael Roth --- scsi/qemu-pr-helper.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/scsi/qemu-pr-helper.c b/scsi/qemu-pr-helper.c index debb18f4aa..38c273de19 100644 --- a/scsi/qemu-pr-helper.c +++ b/scsi/qemu-pr-helper.c @@ -421,10 +421,13 @@ static int multipath_pr_out(int fd, const uint8_t *cdb, uint8_t *sense, int rq_servact = cdb[1]; int rq_scope = cdb[2] >> 4; int rq_type = cdb[2] & 0xf; - struct prout_param_descriptor paramp; + g_autofree struct prout_param_descriptor *paramp = NULL; char transportids[PR_HELPER_DATA_SIZE]; int r; + paramp = g_malloc0(sizeof(struct prout_param_descriptor) + + sizeof(struct transportid *) * MPATH_MX_TIDS); + if (sz < PR_OUT_FIXED_PARAM_SIZE) { /* Illegal request, Parameter list length error. This isn't fatal; * we have read the data, send an error without closing the socket. @@ -454,10 +457,9 @@ static int multipath_pr_out(int fd, const uint8_t *cdb, uint8_t *sense, * used by libmpathpersist (which, of course, will immediately * do the opposite). */ - memset(¶mp, 0, sizeof(paramp)); - memcpy(¶mp.key, ¶m[0], 8); - memcpy(¶mp.sa_key, ¶m[8], 8); - paramp.sa_flags = param[20]; + memcpy(¶mp->key, ¶m[0], 8); + memcpy(¶mp->sa_key, ¶m[8], 8); + paramp->sa_flags = param[20]; if (sz > PR_OUT_FIXED_PARAM_SIZE) { size_t transportid_len; int i, j; @@ -520,12 +522,13 @@ static int multipath_pr_out(int fd, const uint8_t *cdb, uint8_t *sense, return CHECK_CONDITION; } - paramp.trnptid_list[paramp.num_transportid++] = id; + assert(paramp->num_transportid < MPATH_MX_TIDS); + paramp->trnptid_list[paramp->num_transportid++] = id; } } r = mpath_persistent_reserve_out(fd, rq_servact, rq_scope, rq_type, - ¶mp, noisy, verbose); + paramp, noisy, verbose); return mpath_reconstruct_sense(fd, r, sense); } #endif From patchwork Tue Jun 16 14:15:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 280340 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3F03FC433DF for ; Tue, 16 Jun 2020 14:40:54 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0C0AE20644 for ; Tue, 16 Jun 2020 14:40:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Zk9TOKcB" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0C0AE20644 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:55724 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlClh-0007so-5u for qemu-devel@archiver.kernel.org; Tue, 16 Jun 2020 10:40:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57962) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlCQQ-0003Jh-6D; Tue, 16 Jun 2020 10:18:54 -0400 Received: from mail-ot1-x344.google.com ([2607:f8b0:4864:20::344]:37443) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jlCQO-0006vA-IW; Tue, 16 Jun 2020 10:18:53 -0400 Received: by mail-ot1-x344.google.com with SMTP id v13so16030474otp.4; Tue, 16 Jun 2020 07:18: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 :mime-version:content-transfer-encoding; bh=eT4kasepupf0quY9iPCk6nU2ks2xXCw/NfEezYt8oHw=; b=Zk9TOKcBcbcRvgjLNBjKCxNze2FGr/VvYIwqXWwz2JxjMETRQ0OKHPGX19tQw89fHU 3cHyKxELNJNTiiB3CXygXEU/r5XUmrtxIBh5CIaluxZu5H3udY1SkmJXKHs+LTeKY3Cp zMO+xx1/66JMqMQ8Ko67B+/JQVwkAkpxdalB9M2hs95r2LP91YXLgojj35ajc+qegwY+ GcCNdxiGBmrLADsXVKUCc/i6eWOSJ4rfQ3w3KUiW1B/GVsW8UuEdvNMkt1/J8thOlFCR rkoGVJELiEGywWbun4YJ/teZ94Ntayjd5PTkK83iFXxyf1pPFbtwy//879HBB/NpWJEU 56UQ== 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=eT4kasepupf0quY9iPCk6nU2ks2xXCw/NfEezYt8oHw=; b=nogD/0KLRmaUIRSa1l54h4EYRjsg/3wDEcRW+BvFGOzWYLf3yJZDYws7Sd1hZsdna0 GKdTAJjtabIn4Mat1jn3SA9VvJ006tg7WzUTKynlN78dQTKCfxxkMzP8PJb0XAykCNHD iffrZ7cFGnl5+P7DhlladNeIdOT7myP6xs/gAQ9RAwQGbtiC3VtSs1by+f0Yl6w6G7lW hlPY2bLZDKOwkVSd0oZPa8/pcQwAlABTz+2OcM7r1//Ov8Ri9bXSNt0wU6mnOcfnCdRM qCnnrWVjF7PyslP7/362WeVHg9ylSb2xWuLuq1BfhvfuM+/OpQsrH2AGGHfI3wh9xCV5 Py3Q== X-Gm-Message-State: AOAM532jtt15qDCd2rTucAuX9jZjnhrLZqbFy/JTtF471Qosse7aTTBX xsmlH6tw32wEIXQzOXgQxLymNUfM X-Google-Smtp-Source: ABdhPJyMH1zL1V54S0jl8dEBw22p+kWgOqC3YRAeAJJhkdzMEeCcEvnoYTiOSsgzCfb+xUpihKyJ7A== X-Received: by 2002:a9d:7f93:: with SMTP id t19mr2598707otp.347.1592317130464; Tue, 16 Jun 2020 07:18: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 e17sm4169311oiy.21.2020.06.16.07.18.48 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jun 2020 07:18:49 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Subject: [PATCH 52/78] block/qcow2-threads: fix qcow2_decompress Date: Tue, 16 Jun 2020 09:15:21 -0500 Message-Id: <20200616141547.24664-53-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> References: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::344; envelope-from=flukshun@gmail.com; helo=mail-ot1-x344.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vladimir Sementsov-Ogievskiy , qemu-stable@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Vladimir Sementsov-Ogievskiy On success path we return what inflate() returns instead of 0. And it most probably works for Z_STREAM_END as it is positive, but is definitely broken for Z_BUF_ERROR. While being here, switch to errno return code, to be closer to qcow2_compress API (and usual expectations). Revert condition in if to be more positive. Drop dead initialization of ret. Cc: qemu-stable@nongnu.org # v4.0 Fixes: 341926ab83e2b Signed-off-by: Vladimir Sementsov-Ogievskiy Message-Id: <20200302150930.16218-1-vsementsov@virtuozzo.com> Reviewed-by: Alberto Garcia Reviewed-by: Ján Tomko Signed-off-by: Max Reitz (cherry picked from commit e7266570f2cf7b3ca2a156c677ee0a59d563458b) Signed-off-by: Michael Roth --- block/qcow2-threads.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/block/qcow2-threads.c b/block/qcow2-threads.c index 8f5a0d1ebe..0d193d1614 100644 --- a/block/qcow2-threads.c +++ b/block/qcow2-threads.c @@ -128,12 +128,12 @@ static ssize_t qcow2_compress(void *dest, size_t dest_size, * @src - source buffer, @src_size bytes * * Returns: 0 on success - * -1 on fail + * -EIO on fail */ static ssize_t qcow2_decompress(void *dest, size_t dest_size, const void *src, size_t src_size) { - int ret = 0; + int ret; z_stream strm; memset(&strm, 0, sizeof(strm)); @@ -144,17 +144,19 @@ static ssize_t qcow2_decompress(void *dest, size_t dest_size, ret = inflateInit2(&strm, -12); if (ret != Z_OK) { - return -1; + return -EIO; } ret = inflate(&strm, Z_FINISH); - if ((ret != Z_STREAM_END && ret != Z_BUF_ERROR) || strm.avail_out != 0) { + if ((ret == Z_STREAM_END || ret == Z_BUF_ERROR) && strm.avail_out == 0) { /* * We approve Z_BUF_ERROR because we need @dest buffer to be filled, but * @src buffer may be processed partly (because in qcow2 we know size of * compressed data with precision of one sector) */ - ret = -1; + ret = 0; + } else { + ret = -EIO; } inflateEnd(&strm); From patchwork Tue Jun 16 14:15:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 280337 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7034AC433E0 for ; Tue, 16 Jun 2020 14:44:13 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 276D120882 for ; Tue, 16 Jun 2020 14:44:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="k/N7NDx9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 276D120882 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:44126 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlCou-0007xQ-91 for qemu-devel@archiver.kernel.org; Tue, 16 Jun 2020 10:44:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57974) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlCQS-0003Nc-IT; Tue, 16 Jun 2020 10:18:58 -0400 Received: from mail-oi1-x22d.google.com ([2607:f8b0:4864:20::22d]:44311) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jlCQQ-0006vV-NJ; Tue, 16 Jun 2020 10:18:56 -0400 Received: by mail-oi1-x22d.google.com with SMTP id x202so19363408oix.11; Tue, 16 Jun 2020 07:18:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=jFs70PZoIy1XIbQQYgl9tpKPoSsJPaMLiLMqPc7+5mM=; b=k/N7NDx9SLLQHabflOgD2RKa+qc/DmEiqET0sJo5/+btYaWJ1WrJ0kA4dL4j7Q80YC bLzMDzJUed1jldEYYssizR7qwiHtNxe79whtXhG7UOOTndYciKkOwS/o4951eDb4zVwB nIryLuk3XVRoULE/wCkMjjIMMIjzMspS/RpAZqJd/0FsaBfuA2Zu4XlM2Cc9RA+/60Vq GNhw0tQ2qzVj/1sriPFcl4mHt2cnqsAAW8dsm8GM20paEVS0qKxdj2CphZpZvIY+UfQf 7mN7xv0EyVFNLUxwK8iQmtxm/6fYmxcziVtbKonNO0Rxp7v2MA3m77miyWk5eaDNigxT sbQA== 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=jFs70PZoIy1XIbQQYgl9tpKPoSsJPaMLiLMqPc7+5mM=; b=B0taLODJVDkwsjljJWjR8gElQ4FtbukCFOIPjxwwNnKM0+wSYfChiMO9zkKNEREZGf 199KsY01honXb8UniXTYb4BmIlhXBgsQ6VYqQ5egZArO7Yl7f6MWwXjC/4Fow/FSid5T RQSvDd60eb8+l/auW3HWTwl6c8fGQS4nM9zFtgwSltM1/Cd7QcJk3P4b4Ri8IYLYxnAJ o+d2HOKTiY8fV9VnUqAljus8rCCu4uY7A0p3PwB7K6QQjNIL53aPWu2CeVFu9+h4L3Pl 7UWbBZkdzakynbvuJ5+wjAJtXTK+0jN4ruftAFfxyYp1g+V0vRWdIE7rJV84EJOBvSsy Z+Eg== X-Gm-Message-State: AOAM532LVskWrMSkGCFEeOn4VzjX0zo6Xz/9af1f+xynlRJAwLQy6heQ UNLs1+wVh9x4naf3gzaxIok+31IJ X-Google-Smtp-Source: ABdhPJx4oyZef7Jclt0y78AegImh8kwqT2iB9Nyer0/wcZgDg12X2NG4kyCt6FcG5zsPGRD/B7AOyw== X-Received: by 2002:aca:e157:: with SMTP id y84mr3446181oig.161.1592317132496; Tue, 16 Jun 2020 07:18: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 w10sm4087599otp.44.2020.06.16.07.18.50 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jun 2020 07:18:50 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Subject: [PATCH 53/78] job: refactor progress to separate object Date: Tue, 16 Jun 2020 09:15:22 -0500 Message-Id: <20200616141547.24664-54-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> References: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::22d; envelope-from=flukshun@gmail.com; helo=mail-oi1-x22d.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vladimir Sementsov-Ogievskiy , qemu-stable@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Vladimir Sementsov-Ogievskiy We need it in separate to pass to the block-copy object in the next commit. Cc: qemu-stable@nongnu.org Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Andrey Shinkevich Reviewed-by: Max Reitz Message-Id: <20200311103004.7649-2-vsementsov@virtuozzo.com> Signed-off-by: Max Reitz (cherry picked from commit 01fe1ca945345d3dc420d70c69488143dc0451b1) Signed-off-by: Michael Roth --- blockjob.c | 16 +++++----- include/qemu/job.h | 11 ++----- include/qemu/progress_meter.h | 58 +++++++++++++++++++++++++++++++++++ job-qmp.c | 4 +-- job.c | 6 ++-- qemu-img.c | 6 ++-- 6 files changed, 76 insertions(+), 25 deletions(-) create mode 100644 include/qemu/progress_meter.h diff --git a/blockjob.c b/blockjob.c index c6e20e2fcd..701bd2588d 100644 --- a/blockjob.c +++ b/blockjob.c @@ -298,8 +298,8 @@ BlockJobInfo *block_job_query(BlockJob *job, Error **errp) info->device = g_strdup(job->job.id); info->busy = atomic_read(&job->job.busy); info->paused = job->job.pause_count > 0; - info->offset = job->job.progress_current; - info->len = job->job.progress_total; + info->offset = job->job.progress.current; + info->len = job->job.progress.total; info->speed = job->speed; info->io_status = job->iostatus; info->ready = job_is_ready(&job->job), @@ -329,8 +329,8 @@ static void block_job_event_cancelled(Notifier *n, void *opaque) qapi_event_send_block_job_cancelled(job_type(&job->job), job->job.id, - job->job.progress_total, - job->job.progress_current, + job->job.progress.total, + job->job.progress.current, job->speed); } @@ -349,8 +349,8 @@ static void block_job_event_completed(Notifier *n, void *opaque) qapi_event_send_block_job_completed(job_type(&job->job), job->job.id, - job->job.progress_total, - job->job.progress_current, + job->job.progress.total, + job->job.progress.current, job->speed, !!msg, msg); @@ -378,8 +378,8 @@ static void block_job_event_ready(Notifier *n, void *opaque) qapi_event_send_block_job_ready(job_type(&job->job), job->job.id, - job->job.progress_total, - job->job.progress_current, + job->job.progress.total, + job->job.progress.current, job->speed); } diff --git a/include/qemu/job.h b/include/qemu/job.h index bd59cd8944..32aabb1c60 100644 --- a/include/qemu/job.h +++ b/include/qemu/job.h @@ -28,6 +28,7 @@ #include "qapi/qapi-types-job.h" #include "qemu/queue.h" +#include "qemu/progress_meter.h" #include "qemu/coroutine.h" #include "block/aio.h" @@ -117,15 +118,7 @@ typedef struct Job { /** True if this job should automatically dismiss itself */ bool auto_dismiss; - /** - * Current progress. The unit is arbitrary as long as the ratio between - * progress_current and progress_total represents the estimated percentage - * of work already done. - */ - int64_t progress_current; - - /** Estimated progress_current value at the completion of the job */ - int64_t progress_total; + ProgressMeter progress; /** * Return code from @run and/or @prepare callback(s). diff --git a/include/qemu/progress_meter.h b/include/qemu/progress_meter.h new file mode 100644 index 0000000000..9a23ff071c --- /dev/null +++ b/include/qemu/progress_meter.h @@ -0,0 +1,58 @@ +/* + * Helper functionality for some process progress tracking. + * + * Copyright (c) 2011 IBM Corp. + * Copyright (c) 2012, 2018 Red Hat, Inc. + * Copyright (c) 2020 Virtuozzo International GmbH + * + * 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. + */ + +#ifndef QEMU_PROGRESS_METER_H +#define QEMU_PROGRESS_METER_H + +typedef struct ProgressMeter { + /** + * Current progress. The unit is arbitrary as long as the ratio between + * current and total represents the estimated percentage + * of work already done. + */ + uint64_t current; + + /** Estimated current value at the completion of the process */ + uint64_t total; +} ProgressMeter; + +static inline void progress_work_done(ProgressMeter *pm, uint64_t done) +{ + pm->current += done; +} + +static inline void progress_set_remaining(ProgressMeter *pm, uint64_t remaining) +{ + pm->total = pm->current + remaining; +} + +static inline void progress_increase_remaining(ProgressMeter *pm, + uint64_t delta) +{ + pm->total += delta; +} + +#endif /* QEMU_PROGRESS_METER_H */ diff --git a/job-qmp.c b/job-qmp.c index fbfed25a00..fecc939ebd 100644 --- a/job-qmp.c +++ b/job-qmp.c @@ -143,8 +143,8 @@ static JobInfo *job_query_single(Job *job, Error **errp) .id = g_strdup(job->id), .type = job_type(job), .status = job->status, - .current_progress = job->progress_current, - .total_progress = job->progress_total, + .current_progress = job->progress.current, + .total_progress = job->progress.total, .has_error = !!job->err, .error = job->err ? \ g_strdup(error_get_pretty(job->err)) : NULL, diff --git a/job.c b/job.c index 04409b40aa..134a07b92e 100644 --- a/job.c +++ b/job.c @@ -369,17 +369,17 @@ void job_unref(Job *job) void job_progress_update(Job *job, uint64_t done) { - job->progress_current += done; + progress_work_done(&job->progress, done); } void job_progress_set_remaining(Job *job, uint64_t remaining) { - job->progress_total = job->progress_current + remaining; + progress_set_remaining(&job->progress, remaining); } void job_progress_increase_remaining(Job *job, uint64_t delta) { - job->progress_total += delta; + progress_increase_remaining(&job->progress, delta); } void job_event_cancelled(Job *job) diff --git a/qemu-img.c b/qemu-img.c index 95a24b9762..9ae07bbc80 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -881,9 +881,9 @@ static void run_block_job(BlockJob *job, Error **errp) do { float progress = 0.0f; aio_poll(aio_context, true); - if (job->job.progress_total) { - progress = (float)job->job.progress_current / - job->job.progress_total * 100.f; + if (job->job.progress.total) { + progress = (float)job->job.progress.current / + job->job.progress.total * 100.f; } qemu_progress_print(progress, 0); } while (!job_is_ready(&job->job) && !job_is_completed(&job->job)); From patchwork Tue Jun 16 14:15:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 280329 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4423DC433DF for ; Tue, 16 Jun 2020 14:53:58 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0DA5C20679 for ; Tue, 16 Jun 2020 14:53:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="IqK+GgBf" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0DA5C20679 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:58700 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlCyL-0000tB-7R for qemu-devel@archiver.kernel.org; Tue, 16 Jun 2020 10:53:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58046) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlCQd-0003XX-6A; Tue, 16 Jun 2020 10:19:11 -0400 Received: from mail-oi1-x241.google.com ([2607:f8b0:4864:20::241]:37874) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jlCQb-0006xa-ME; Tue, 16 Jun 2020 10:19:06 -0400 Received: by mail-oi1-x241.google.com with SMTP id a3so19413326oid.4; Tue, 16 Jun 2020 07:19:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=V65H2WdSRAK88T/KlWVxHCbmRYaYQ8jXFvHNXk1Yflo=; b=IqK+GgBfugP2I9f499pW7yQGZ38XltjSJqKnyK0ifqook8dGH8YYUIbyM+8QQUE+WB 6Agzebnwjg91MF63/sugbUc5CBG786oAco60IXZ1SqRobpuhTWtSYCYfP2vBILR0hmTr XxLGOFVcwbg861dcTrEtjuyZGTVS3IlUuABrKPwU8ZOA3525TQ32BNH7dSQVwO7MZvzu Q+l269QzLYnwl3Jw2Asbm4nVXNe5kGmP3XsIdLkHq5W2Nuvr8tP6+l8EmKPd5JBm/UJY Ra6av29Vss5ayTejvw1aIyFg6MQBbQzAfsCYsYKthjGIz5JlmJsaZExX1k6KkPho0XAQ Yacg== 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=V65H2WdSRAK88T/KlWVxHCbmRYaYQ8jXFvHNXk1Yflo=; b=ZtzBPt5Iu4JtJjd7iz3kJreSdwXsiIiXfqAtkbdT8vMxLJ8olvW/0UPfwA5WzzGasL p26ZIaFrJtyGdNd2N8b5wHJhtFIk/8GL0bV+oE95xd6hqsIfmrXOOtm+6LMlxoVueiXQ KTXm054AJOPi2eEKG2nywR/XeyaTdybQb/JlKYSk1TeZKyBgdye/4n/kTSUvSEKTeYvh CS8AacBD5pLAnB6+RZ1/R7sHqnpQ1ZBvnMM3d1Zvy1vkIFIYFP5AGuYJZSjja5ZaX9b3 xrQ4PrYOg/BxeqOvow80COTYU4RFtPfDDl/BDz5/N9JCnTACupK98rVJD6gCYVwsRm2s HTBg== X-Gm-Message-State: AOAM530ImqTk+kSJwNs7WTbAmZXpdUGbrKsey58Pksm39nbqbs9e5VXO mjOWmwheT7wiLgN7gt5YUC73HqQx X-Google-Smtp-Source: ABdhPJxXvPvCpe6jZK/n7n+7m6vnoY7vO9GPDffgmQ7b8YPZxKIj3ZeyyCDufiUf3GjJbnZlh4COuQ== X-Received: by 2002:aca:ad88:: with SMTP id w130mr3664364oie.103.1592317141901; Tue, 16 Jun 2020 07:19: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 g2sm2963099oou.0.2020.06.16.07.19.00 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jun 2020 07:19:00 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Subject: [PATCH 57/78] compat: disable edid on correct virtio-gpu device Date: Tue, 16 Jun 2020 09:15:26 -0500 Message-Id: <20200616141547.24664-58-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> References: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::241; envelope-from=flukshun@gmail.com; helo=mail-oi1-x241.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cornelia Huck , qemu-stable@nongnu.org, Gerd Hoffmann Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Cornelia Huck Commit bb15791166c1 ("compat: disable edid on virtio-gpu base device") tried to disable 'edid' on the virtio-gpu base device. However, that device is not 'virtio-gpu', but 'virtio-gpu-device'. Fix it. Fixes: bb15791166c1 ("compat: disable edid on virtio-gpu base device") Reported-by: Lukáš Doktor Tested-by: Lukáš Doktor Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Cornelia Huck Message-id: 20200318093919.24942-1-cohuck@redhat.com Cc: qemu-stable@nongnu.org Signed-off-by: Cornelia Huck Signed-off-by: Gerd Hoffmann (cherry picked from commit 02501fc39381c4dabaf6becdd12c2a4754c3847c) Signed-off-by: Michael Roth --- hw/core/machine.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index aa63231f31..1872263bf0 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -37,7 +37,7 @@ GlobalProperty hw_compat_4_0[] = { { "secondary-vga", "edid", "false" }, { "bochs-display", "edid", "false" }, { "virtio-vga", "edid", "false" }, - { "virtio-gpu", "edid", "false" }, + { "virtio-gpu-device", "edid", "false" }, { "virtio-device", "use-started", "false" }, { "virtio-balloon-device", "qemu-4-0-config-size", "true" }, { "pl031", "migrate-tick-offset", "false" }, From patchwork Tue Jun 16 14:15:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 280330 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A8A6DC433E0 for ; Tue, 16 Jun 2020 14:52:10 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7D0E5208B8 for ; Tue, 16 Jun 2020 14:52:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mR8N9e50" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7D0E5208B8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:50440 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlCwb-0005xx-MM for qemu-devel@archiver.kernel.org; Tue, 16 Jun 2020 10:52:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58050) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlCQd-0003Xd-Hs; Tue, 16 Jun 2020 10:19:11 -0400 Received: from mail-ot1-x342.google.com ([2607:f8b0:4864:20::342]:38314) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jlCQc-0006xe-02; Tue, 16 Jun 2020 10:19:07 -0400 Received: by mail-ot1-x342.google.com with SMTP id n70so16046712ota.5; Tue, 16 Jun 2020 07:19: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=H56oUyDfYltLK80fHHPutYvS4jI1ii23yt2DPH3g7jo=; b=mR8N9e50RCg23pLx3lKQlKlZBTAxe7ycOstMiYqo+u5iEaxm7sROaN6zZQx5Gv+Sdx dI1NmQ5e7eQDvYZXmue7nhzfEu0PdnXxww3/i+C+jcYC2AQz9HrrRNr+yxqSPUDWe2tx PwFzzk7vl6YsIp6sNN0h5AgxM4Rr4lipa7U3cazENk8YzIJfSv0Kc4gXxoTsYdI5lmEN sNEvCZkGe6l4U0XLJGXpgSbv5Gs7vxc+3urlyDHfgKbRGUnbZ97/68psdnQBcfCSPgdt dx1icNfzL+23gLTQQ4ApAU/Ob1AcaRHbydw3h9IwitxBP5/B3RMWrQ+o0/M0hgbYOHar LBuw== 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=H56oUyDfYltLK80fHHPutYvS4jI1ii23yt2DPH3g7jo=; b=qWX+agNeBWFoFc35OaLZwafBPh5W2MfmW/Q12E0P77QtYlzrl1pfGMtxUTkW0JEXYc CND7YIfqtJgBiAIMHfpy2svwZ0TP+RQ0RuZXw4NzDyjh4tVOvxmpd3BlPO/vSxpG3ZkF cdjOJ+8qebKwSclxg7DkDgYGEhisa8G8/rhkUbGcwRf3iR+gLVqmWm9BU7DQ969Gw1A5 QjZFbUQHeXFtdLFKcS7EBmmOBpgtgz2Mek+dyJukzZpNg3yzv2J6cM5GyZTViOwOQhzh 55yx4OFMguu9pYD/Y+1/CUTLtw6JFlCysfrOkMsfzWUIOsEtk1y8Zbri6zR2J5dfSoWt IR8w== X-Gm-Message-State: AOAM530whbEfiyDYzdQ6aKr5sOnwLl3HGPFCOBgCmURcRMkfAePQ752M u3jqLQ1rO2e0lMfPiOBZ6sB23vZr X-Google-Smtp-Source: ABdhPJyu5pc0DvMfVeaxEpuB/WEofk2K3ge4Q2IeJ41xYDar/iRg6/OgDt74uFg+NhRVfojxbuDZew== X-Received: by 2002:a9d:3df7:: with SMTP id l110mr2495125otc.214.1592317143900; Tue, 16 Jun 2020 07:19: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 e25sm4082086otj.73.2020.06.16.07.19.02 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jun 2020 07:19:02 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Subject: [PATCH 58/78] qga: Installer: Wait for installation to finish Date: Tue, 16 Jun 2020 09:15:27 -0500 Message-Id: <20200616141547.24664-59-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> References: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::342; envelope-from=flukshun@gmail.com; helo=mail-ot1-x342.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sameeh Jubran , Basil Salman , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Basil Salman Installation might fail if we don't wait for the provider unregisteration process to finish. Signed-off-by: Sameeh Jubran Signed-off-by: Basil Salman Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Michael Roth (cherry picked from commit bb1ce44b15f159b67fafc5f4b285bbf20a1961e9) Signed-off-by: Michael Roth --- qga/installer/qemu-ga.wxs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qga/installer/qemu-ga.wxs b/qga/installer/qemu-ga.wxs index 64bf90bd85..f6781752e6 100644 --- a/qga/installer/qemu-ga.wxs +++ b/qga/installer/qemu-ga.wxs @@ -81,7 +81,7 @@ Arguments="-d --retry-path" > - + From patchwork Tue Jun 16 14:15:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 280327 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E7A60C433E0 for ; Tue, 16 Jun 2020 14:55:29 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B82C420644 for ; Tue, 16 Jun 2020 14:55:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GAnh6LxN" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B82C420644 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:39090 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlCzp-0004LB-14 for qemu-devel@archiver.kernel.org; Tue, 16 Jun 2020 10:55:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58068) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlCQh-0003Xh-Oe; Tue, 16 Jun 2020 10:19:11 -0400 Received: from mail-oi1-x242.google.com ([2607:f8b0:4864:20::242]:40315) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jlCQd-0006xs-9Z; Tue, 16 Jun 2020 10:19:08 -0400 Received: by mail-oi1-x242.google.com with SMTP id t25so19384808oij.7; Tue, 16 Jun 2020 07:19: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=lEcayuvB+XGeWNX8U/Yu92PQGUAoKZ14ovL5ftbZCxY=; b=GAnh6LxNH6I2LyEAf7T2OHebxodipl3Wzk9PmkLXuXD/ix0miP4QPr1rilFE1Npl18 ureW8Fp9erWINJAQT27zEMLz86HAzs665EYRwbHmPbx6UWw1VE3ZDm2NJOoFSnX43JBp bGfYJkfbUnR3Rha04jydqYl47DuJ9SQHNvPEas/QUSk8B3gGeFdukKSV5X6JuhJBmGAy +0iVaU1KG3ko3YVoY3FcEGBLAu3du80FGe4s6glKqu4JIys5rGMPbVVDZjh3JORncqMA 8tggU5tgGp4ZqM+W1OLTlZgLjp/D/bj90yUwVp3JCV9LZSMZWSa52+Faz/pGQzzf9Qt+ 6rkg== 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=lEcayuvB+XGeWNX8U/Yu92PQGUAoKZ14ovL5ftbZCxY=; b=sFJIDSYlqDklPGM/zRKqs3v+pMiWMSMCHFsvrHVSQeg2iKBSkkS48P6RX0SFQhz+UK 7aSEQ7sibYfNBSD1z4iAsuZ697e2qFAM6ScVi/8XaudfQi6NWg4WmCdP+5LuDTedJADH d7BYVOuUSjxI2/Jq2hfEGpb3FSnN/lCLTkMwOoonXoVuQDJKc7mxPDCeDm6jo68YX8Be 0feEqoZSH3BSBth8H2scWUB0y8SXW8nWz9N9SgLAypndj9iVt4omlgEs4T1EgB4LneBp JwkTF8h75p2kEZJcknZmm5ob9/Bb3Pp4A8XBhPR/hmqKdotUzMiChvu781fvfXSp4ajX x6vQ== X-Gm-Message-State: AOAM530DMc7ZZJoTpwb6EqVizL243rUK81COsS9pwLYKNE5G+waEldKc M/A+wGlnFzQrjv5qLEzh9QdCNNqN X-Google-Smtp-Source: ABdhPJzIg6sqCW7gxojRgIsnEhaN+ZXNtttu7aBVQ9zTzQIb4d+VffBOsqvS4QWOQRYh3vSPRoi03w== X-Received: by 2002:aca:fd94:: with SMTP id b142mr3610894oii.9.1592317145394; Tue, 16 Jun 2020 07:19: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 b4sm4085033oti.3.2020.06.16.07.19.04 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jun 2020 07:19:04 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Subject: [PATCH 59/78] qga-win: Handle VSS_E_PROVIDER_ALREADY_REGISTERED error Date: Tue, 16 Jun 2020 09:15:28 -0500 Message-Id: <20200616141547.24664-60-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> References: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::242; envelope-from=flukshun@gmail.com; helo=mail-oi1-x242.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sameeh Jubran , Basil Salman , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Sameeh Jubran This patch handles the case where VSS Provider is already registered, where in such case qga uninstalls the provider and registers it again. Signed-off-by: Sameeh Jubran Signed-off-by: Basil Salman Signed-off-by: Michael Roth (cherry picked from commit b2413df83348acf371c03bced9a3845bba883ed5) Signed-off-by: Michael Roth --- qga/vss-win32/install.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/qga/vss-win32/install.cpp b/qga/vss-win32/install.cpp index 6713e58670..a456841360 100644 --- a/qga/vss-win32/install.cpp +++ b/qga/vss-win32/install.cpp @@ -443,6 +443,17 @@ STDAPI DllRegisterServer(void) VSS_PROV_SOFTWARE, const_cast(QGA_PROVIDER_VERSION), g_gProviderVersion); + if (hr == (long int) VSS_E_PROVIDER_ALREADY_REGISTERED) { + DllUnregisterServer(); + hr = pVssAdmin->RegisterProvider(g_gProviderId, CLSID_QGAVSSProvider, + const_cast + (QGA_PROVIDER_LNAME), + VSS_PROV_SOFTWARE, + const_cast + (QGA_PROVIDER_VERSION), + g_gProviderVersion); + } + if (FAILED(hr)) { errmsg_dialog(hr, "RegisterProvider failed"); } From patchwork Tue Jun 16 14:15:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 280328 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 93D4EC433E0 for ; Tue, 16 Jun 2020 14:54:12 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 64CE420679 for ; Tue, 16 Jun 2020 14:54:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="phqAh/g2" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 64CE420679 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:60256 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlCyZ-0001VK-Ju for qemu-devel@archiver.kernel.org; Tue, 16 Jun 2020 10:54:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58146) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlCQl-0003ec-3u; Tue, 16 Jun 2020 10:19:15 -0400 Received: from mail-oi1-x242.google.com ([2607:f8b0:4864:20::242]:46993) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jlCQh-0006yE-Qj; Tue, 16 Jun 2020 10:19:14 -0400 Received: by mail-oi1-x242.google.com with SMTP id 25so19336412oiy.13; Tue, 16 Jun 2020 07:19:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=IhA7tGc4qQITgrYTWHPDVz8A3fUsUmDnXkD5C60/dcc=; b=phqAh/g2YyNhyYCcznlu2ECdKdM0Hr6yuvdTPxKmWmQR4xxGMx9tvaVvhlLv3to1jK JdH5PfVSRY6yw/Swf9N/R5/8apODnV7eyUJcPkKxcniHwOzJxk01lTo4nCk+chll+YTh LqZTQ4dJvh0V7sT7FIi9dhkMg3PfWfmY+mBhrT7JmG8u10Pa2l6c9c9SSQn5uooMuOMz y+Cv66OKlXOPjPU3/hGZQithDbp4VHiT4OuKMJRFhT/xfYd2IfPl0OEKX2n18vjOmBMf kYhw3Gct3zujlhPMU4b1cnEIf4yALFghhuW96IgW204U2MlT1Y1fijA/NP3lMGcAGTUW 82Vg== 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=IhA7tGc4qQITgrYTWHPDVz8A3fUsUmDnXkD5C60/dcc=; b=G+yv/dmRDqv18/4zrPLo3QDS4uP0ov2xpnCcMgB3Jy6omE8huL4vKC8rqpj7yZLgNC p9d/yy86ru/hFBLtvvjYw2zSkhdnZIp8Iy8fPr6LTK5HUU0P6RJofxR8Vvt8gBOYvbkE YhoopCIe0nFPHeHEA/2BMaUoQ77nfXaXSzqW31LeHuAkmD3E4NFVUFyxyaxREYuKdeJ4 6zK/qYwNXHncwmfb/WS4K1h6WqX7EMxfziKIZ3sN2Vv/WAxM1oaVtQRjxI1dINq76JT8 GZnNhGnnIPnTytOBDn8PvbqLvJAFmeDTXDXjW+YWPJ4lwMxbhpR/RLMsPtojmN5boWYh NKOw== X-Gm-Message-State: AOAM532dQTtGdnH7dm7i75NbuAYPtPeTPqghNoRwFtUemPw9hBW1PrQW 2naXzBxRYksKUqeR000G65297J2s X-Google-Smtp-Source: ABdhPJz161B8mMuQHVo7VUZnppv5cLaSH+XIZyIK3/i25uAoSYq1AOoqbirZIFziElVD2sw8CjdBOA== X-Received: by 2002:aca:eb42:: with SMTP id j63mr3315973oih.144.1592317147300; Tue, 16 Jun 2020 07:19:07 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id m13sm4086378oou.25.2020.06.16.07.19.05 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jun 2020 07:19:06 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Subject: [PATCH 60/78] qga-win: prevent crash when executing guest-file-read with large count Date: Tue, 16 Jun 2020 09:15:29 -0500 Message-Id: <20200616141547.24664-61-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> References: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::242; envelope-from=flukshun@gmail.com; helo=mail-oi1-x242.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Basil Salman , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Basil Salman guest-file-read command is currently implemented to read from a file handle count number of bytes. when executed with a very large count number qemu-ga crashes. after some digging turns out that qemu-ga crashes after trying to allocate a buffer large enough to save the data read in it, the buffer was allocated using g_malloc0 which is not fail safe, and results a crash in case of failure. g_malloc0 was replaced with g_try_malloc0() which returns NULL on failure, A check was added for that case in order to prevent qemu-ga from crashing and to send a response to the qemu-ga client accordingly. Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1594054 Signed-off-by: Basil Salman Reported-by: Fakhri Zulkifli Cc: qemu-stable@nongnu.org Signed-off-by: Michael Roth (cherry picked from commit 807e2b6fce022707418bc8f61c069d91c613b3d2) Signed-off-by: Michael Roth --- qga/commands-win32.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/qga/commands-win32.c b/qga/commands-win32.c index 55ba5b263a..01e02e4440 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -342,7 +342,13 @@ GuestFileRead *qmp_guest_file_read(int64_t handle, bool has_count, } fh = gfh->fh; - buf = g_malloc0(count+1); + buf = g_try_malloc0(count + 1); + if (!buf) { + error_setg(errp, + "failed to allocate sufficient memory " + "to complete the requested service"); + return NULL; + } is_ok = ReadFile(fh, buf, count, &read_count, NULL); if (!is_ok) { error_setg_win32(errp, GetLastError(), "failed to read file"); From patchwork Tue Jun 16 14:15:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 280326 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95C9DC433E0 for ; Tue, 16 Jun 2020 14:55:51 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 699FB20644 for ; Tue, 16 Jun 2020 14:55:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="E1VQGJ83" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 699FB20644 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:41294 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlD0A-0005IQ-K6 for qemu-devel@archiver.kernel.org; Tue, 16 Jun 2020 10:55:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58178) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlCQm-0003i1-H8; Tue, 16 Jun 2020 10:19:16 -0400 Received: from mail-ot1-x343.google.com ([2607:f8b0:4864:20::343]:44578) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jlCQk-0006yz-PB; Tue, 16 Jun 2020 10:19:16 -0400 Received: by mail-ot1-x343.google.com with SMTP id e5so16019583ote.11; Tue, 16 Jun 2020 07:19: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=luDTWDuXHrw0jVjHUOWwtj8xIi3ns98/jyoG5nV+cZo=; b=E1VQGJ83vVvyJBRTBkk5zIDSoUzhRTWSCrFmgxTEjDuVOhShz7BYhDtaaRvR6AFTdr aw9zcdX29aetglsKxQB9wu5WD5Ro/+8DnafQGs6PitkIQEhy/t8U5F5HJDo1eItqbOgD SfF6sA+K9vU5e1z8vvUE9/xo9vSKf2nyClOD9nruDtxmtJpzGxS+V3Hjysmqf1rkzKT1 rFPqxhsB0DEUEC9q88cS89PvzLyTeCiSkfMbV15EWArIXvF4joIWYe7ZTBWxGcCyJzYB dlANiOUgzArrpUzz5EhvRcvSIuHIszMRnSMJ8GJqQVHZyi0xjc8F79JPctgWPCPVMUyT 7U+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=luDTWDuXHrw0jVjHUOWwtj8xIi3ns98/jyoG5nV+cZo=; b=Gi3YuwWDBCPJ0kdd1uHG+XTSZ0QXqeFKL7Puf7Nj9aFjrjoIwiZ0W3/OrWuJFI9F20 awnu1uwoYeKc3mqUIk1Rz9vVx6SxqxpnBtrSJ5IJtG555sdG6qqU0OHUhQ4u+KeY57vX 2QFbEOTUxccLQ+3WQ1B2rqXjzEqwLym+UHCwHD2gU2YMmj8KsnxtJsy8s7u0O/gYuYFj CsHL8VkKzGO1xRIHg/FclsMyftUfGyCkdtm7dWl9dU98qyeRAKvQSBOrUJ/lBbI7W/z8 IWMdVaxaJKCwAPMHxetIyi5Zhuexxnimz/X/PeKv7MM2l76lC1cPG1hHKUgBzahcRUw2 +vQA== X-Gm-Message-State: AOAM533v/iH0ekKzTSFmDKdkhbKqeTerdX4CfzPg2yI4A705Va5SIbgN TF3QJ9yLOf+UJAweBwRF3xUWY2eP X-Google-Smtp-Source: ABdhPJwbOyq1+L9ExYcFnBJhBoSELKR5ybwRb06V3bl6Opt/lhZPmyxCJWx1ewsHpo/FJr62l7VF+Q== X-Received: by 2002:a05:6830:13d3:: with SMTP id e19mr2629793otq.290.1592317152347; Tue, 16 Jun 2020 07:19: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 t11sm4072451otr.65.2020.06.16.07.19.09 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jun 2020 07:19:10 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Subject: [PATCH 61/78] qga: Fix undefined C behavior Date: Tue, 16 Jun 2020 09:15:30 -0500 Message-Id: <20200616141547.24664-62-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> References: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::343; envelope-from=flukshun@gmail.com; helo=mail-ot1-x343.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Eric Blake The QAPI struct GuestFileWhence has a comment about how we are exploiting equivalent values between two different integer types shared in a union. But C says behavior is undefined on assignments to overlapping storage when the two types are not the same width, and indeed, 'int64_t value' and 'enum QGASeek name' are very likely to be different in width. Utilize a temporary variable to fix things. Reported-by: Peter Maydell Fixes: 0b4b49387 Fixes: Coverity CID 1421990 Signed-off-by: Eric Blake Signed-off-by: Michael Roth (cherry picked from commit a23f38a72921fa915536a981a4f8a9134512f120) Signed-off-by: Michael Roth --- qga/commands.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/qga/commands.c b/qga/commands.c index 0c7d1385c2..8ec7fa3c04 100644 --- a/qga/commands.c +++ b/qga/commands.c @@ -482,10 +482,15 @@ done: * the guest's SEEK_ constants. */ int ga_parse_whence(GuestFileWhence *whence, Error **errp) { - /* Exploit the fact that we picked values to match QGA_SEEK_*. */ + /* + * Exploit the fact that we picked values to match QGA_SEEK_*; + * however, we have to use a temporary variable since the union + * members may have different size. + */ if (whence->type == QTYPE_QSTRING) { + int value = whence->u.name; whence->type = QTYPE_QNUM; - whence->u.value = whence->u.name; + whence->u.value = value; } switch (whence->u.value) { case QGA_SEEK_SET: From patchwork Tue Jun 16 14:15:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 188045 Delivered-To: patch@linaro.org Received: by 2002:a92:cf06:0:0:0:0:0 with SMTP id c6csp3720774ilo; Tue, 16 Jun 2020 07:51:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzgku/khq4KX1//ZarAixrDGtbkvbpKRsilzsf1h1ky++469BzKMUwu0aij6/CCeBPUCjqg X-Received: by 2002:a25:3bd8:: with SMTP id i207mr4639600yba.167.1592319080788; Tue, 16 Jun 2020 07:51:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592319080; cv=none; d=google.com; s=arc-20160816; b=eoeTvKCdzfekKSY1QQZYIsNoApKOdwITOhNroKeslRmgte1MVYBw1gkxv4LSVer9CZ CWZ4uwRasTdqVu1Mq6os/c32Le1snosPU3+shh55u/xKEGV5oZ+okoiGhhYdIDkgDuvC Sd9iKxOdi9jgecQ5bL3rKjqPjQxMvNhtKzmEUZGTk6R/1BU4uOWM5g3IW4CC4mxINHiH LOoKk6+okkv05ehlfF4bdFB1Dy4rNJHUUFmfW44Nj3DzrkzuEbdFRzUu22T3yRlCnbrp 2709UUuWbttQKSrAqoqkj+AjpgkTi/MfTs95TNZ3FvyCJJJ1SOyyeMlbXCRYlyOBK5lr Kd2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:references:in-reply-to :message-id:date:subject:to:from:dkim-signature; bh=rOQwJDphmhaIdRqWIt/ysSZEwiemdpwpObYdcb/nTmA=; b=gvWJXykvjOpfhSoSlmfapZ/4iNpql5qrDE8JUPYOyb+0wqXwq343J7zf40DSpzfkKp 5Wwo/c05l6QvZMR+Xvot/UeuPFW2o/o4g2DXekdSjvXNw2MsclPNUOFD251xHVoh8y0J EFlpC68ijmDtxKl1Ct4GDAygfBMuNew4mYXTURBLdZArgyWtAYdAcyGS47dPy8OblM/4 SAk/GC4VT5pMXrnibhjyn9LVA2501fKnqj42djc+lRGkM6T+VJ0YBHp2aBNPKjJuQ+x/ k9tgAN5NIAGha0GFtLpmloGtldXz1KDgXPpn4GXUA3GjQJNhfgBU5VOvYxni3mYzNySs 2jxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=stoZDnAF; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id w1si23938544ybt.389.2020.06.16.07.51.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jun 2020 07:51:20 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=stoZDnAF; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from localhost ([::1]:44300 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlCvo-0003WB-6W for patch@linaro.org; Tue, 16 Jun 2020 10:51:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58222) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlCQr-0003vG-Va; Tue, 16 Jun 2020 10:19:22 -0400 Received: from mail-ot1-x343.google.com ([2607:f8b0:4864:20::343]:42866) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jlCQq-00070V-Da; Tue, 16 Jun 2020 10:19:21 -0400 Received: by mail-ot1-x343.google.com with SMTP id t6so16023672otk.9; Tue, 16 Jun 2020 07:19:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=rOQwJDphmhaIdRqWIt/ysSZEwiemdpwpObYdcb/nTmA=; b=stoZDnAFLyaVidRBFf2vh7DppTmcd++JgdNyKYUO4mPu1j4IF8owJSWXYIEHQHvvdb lo2jFmPP9F9VLVt+lO0+5W8zdRWFB74hiFXbzgQHPmJYG02BCzxxYjBD3B9nFL6rrrHk gNXNhW10ZRSGPzm0QFxFRzLIlQXqR73xqZhsP8lApUuGwFD9MjDeid5uzoseO8UztJe4 1C93sDQG5QMPB+Ve+jj2W8ny0/gyHz1mreBJ5Z/ZF7WuA+/lebHxi7vTqLhV/jNKNmq8 /zR6oVPewxB0V6+Dm5klaoY2RZwk2DHdCPsMyYPvRpNhA/aS+mbeUluIWDMAWkfOqA9F JLpQ== 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=rOQwJDphmhaIdRqWIt/ysSZEwiemdpwpObYdcb/nTmA=; b=gVCnh06poEHutEU8H/1ytJeQ32300LsJtKwaSltNiEFeM7kyBdnOAfflWefALnWfsK RmJQim+8vJvAyx3J/+Eofi2cfWkgEBgymnj32X2ctaozD2USKJgOtJ6EC2t8UdbFYu9M 2po6fngdsPVW08c8pFRoYpLX/gNC062Ox7nRmVLR8yrYTKff6gxEeYBKe5A8y2dkYvjJ YH2zrR1Yffu8o3cQv/KOdXZqHmKbG8nZegFTyNxhPAdyYNf6jkSnGJLYs3pjjCpha55p NnAZ3IUc6y0L+uNi/bBq4R0wiZTXW3kiXf9q/qumMYPFW+6XD7enf8SlkOiPBOkBfspr e0Iw== X-Gm-Message-State: AOAM53047jDZPneaTxoLScTI2XQOm0tTWQAmiXAEOMYw10PWivQNDhzi vCctm1IbAJFafPwfDULWcYpmEdTj X-Received: by 2002:a9d:554d:: with SMTP id h13mr2342117oti.201.1592317157109; Tue, 16 Jun 2020 07:19: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 c10sm4120781ooq.30.2020.06.16.07.19.15 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jun 2020 07:19:15 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Subject: [PATCH 63/78] hw/i386/amd_iommu.c: Fix corruption of log events passed to guest Date: Tue, 16 Jun 2020 09:15:32 -0500 Message-Id: <20200616141547.24664-64-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> References: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::343; envelope-from=flukshun@gmail.com; helo=mail-ot1-x343.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-stable@nongnu.org, "Michael S . Tsirkin" Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell In the function amdvi_log_event(), we write an event log buffer entry into guest ram, whose contents are passed to the function via the "uint64_t *evt" argument. Unfortunately, a spurious '&' in the call to dma_memory_write() meant that instead of writing the event to the guest we would write the literal value of the pointer, plus whatever was in the following 8 bytes on the stack. This error was spotted by Coverity. Fix the bug by removing the '&'. Fixes: CID 1421945 Cc: qemu-stable@nongnu.org Signed-off-by: Peter Maydell Message-Id: <20200326105349.24588-1-peter.maydell@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin (cherry picked from commit 32a2d6b1f6b4405f0fc20c031e61d5d48e3d9cd1) Signed-off-by: Michael Roth --- hw/i386/amd_iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.17.1 diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c index d55dbf07fc..ac5f2fddc5 100644 --- a/hw/i386/amd_iommu.c +++ b/hw/i386/amd_iommu.c @@ -181,7 +181,7 @@ static void amdvi_log_event(AMDVIState *s, uint64_t *evt) } if (dma_memory_write(&address_space_memory, s->evtlog + s->evtlog_tail, - &evt, AMDVI_EVENT_LEN)) { + evt, AMDVI_EVENT_LEN)) { trace_amdvi_evntlog_fail(s->evtlog, s->evtlog_tail); } From patchwork Tue Jun 16 14:15:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 188047 Delivered-To: patch@linaro.org Received: by 2002:a92:cf06:0:0:0:0:0 with SMTP id c6csp3726280ilo; Tue, 16 Jun 2020 07:58:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJym572B8vF8aB2G3JgzlozxlWwrca95iHMI9SLNQMEeI2b39G6Tmie963K8PM6s/EoiZFmZ X-Received: by 2002:a25:5044:: with SMTP id e65mr4811671ybb.98.1592319534855; Tue, 16 Jun 2020 07:58:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592319534; cv=none; d=google.com; s=arc-20160816; b=wCACk/6GEhsb3LtclzQyDY3CHYU8zG85/4lnsda2xEJwlFHoFRdTsCP9vORMbKdNyJ 2iNyUd+wbCGF+UUndj4pf45bTV/07xeZp/n/ySyLo36J2Lescry5/hxZXuaHMg7j0mqu hTuEgnNa879AKz+dcf2vsovbtHEjIaShBgNfbqn/blYWteByHiuLqtfsH6zjXOx+QBhu TCaM6Gl1hFpoBxEEBRkHmbqp6srete+hr1g9Vzozbj+PxPZeeusv53t45w/tboiczZuf a5O4p3h2C2dWj1SNa+hKiX3vNHAbu2CPPgcYVByNPJwuO6kieU0MjG4hQtacdeyLvDLS j28Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:references:in-reply-to :message-id:date:subject:to:from:dkim-signature; bh=RMIBO3jpMOms/D4uQke8brSu1T+4gHbWwgG0M1rmYeo=; b=je6FYlEwkA3/aM6Z9boqeJqbz+sXAil/RONDSTX14xIIBXUbXKWdC7BqfXuqsIN2Yu rnJ7Ae9ayKoE6ePmi5WStkNhE+vQGnUssMBjkHdEQY7XF89vfRP4EHsFKQ4NfCeJN/rW SE2rc4dJPmmQvAD28P6xRn5T53zMAo3jFgHsR890ef5KwMAJ53IoizIjv/Elvkk7HG2e miRnjl/isxtjMPZlQjaAXOcoyP21Yt94nJ5VY8E0J+8fzrjtjdqyelTtm50sAEKDjT1X RzN6bhmtzhjjJkXuIOqDzUOxJsATE/9T3cGAqE0KlZTCoDwFf67jizJ/JRDiLDMZ8egY sQqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=L5h4A1jh; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id w66si16693321ybc.388.2020.06.16.07.58.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jun 2020 07:58:54 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=L5h4A1jh; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from localhost ([::1]:55200 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlD38-0002UH-Aw for patch@linaro.org; Tue, 16 Jun 2020 10:58:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58228) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlCQs-0003x6-Rt; Tue, 16 Jun 2020 10:19:22 -0400 Received: from mail-ot1-x344.google.com ([2607:f8b0:4864:20::344]:35108) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jlCQr-00070e-0Q; Tue, 16 Jun 2020 10:19:22 -0400 Received: by mail-ot1-x344.google.com with SMTP id d4so1647887otk.2; Tue, 16 Jun 2020 07:19: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=RMIBO3jpMOms/D4uQke8brSu1T+4gHbWwgG0M1rmYeo=; b=L5h4A1jhSAISjOnt4/5iYKvvgYcm5d938db0dmepSl2M9/GNnDVaU0NISXALHuae0a bSq5wwXIjC50EaUQHGXdKkIg+QJz4a1/dX9VuluD4sprBXNGZxxkbOGyI0mMljOOcCYu s1QLux4RP+t1Y7SIhm30vosfD27nrBvbgB9/uEJLEUsJ8icXtZlZ6ffrrWKzZ8melFqs jr0yV672mX3YeNfejFCAIVnseZsbLuOYBGz1f/B0zVPU07ux1buVVtUhmk3nC3wRK3kn 0BK6oEKdG58Bbe0kW1PKt0XwXrTGUabW5tYWWUE57XPUrEV1pJZPOATtYFeRR8iBhGy/ VS/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=RMIBO3jpMOms/D4uQke8brSu1T+4gHbWwgG0M1rmYeo=; b=gDZ5qR3uN0EAVbkCTVLrhLz3GofPp7R057vFoOGKXvWfAgeci1npc/SLsEZ2QmuAPQ hGlcktznb/zWO5pnnZ8Z0P1/EziLHYv+CKeify3PKXhi1Bjwl1TStspWy+Fhzn195AJh 0v85jpK4waoG1JQyUUMjNm4KK3AZ13HVAVJH5olEJDCwXthTry+2y5WefUS8RHL/1VVn y1a7goyoebkQnfaLLi+hTeZc5Cin/Jv9TuQ0Ql3tRbQJ3j053fEUnYBRCfE4W/AbB/EW N4BUtZFoBVs2OkRLIoa7AayG3Nds/k8YR5Jx3BFIEvOMy87FT8UPgLwwQE703UV1aZc2 670Q== X-Gm-Message-State: AOAM5339meVR9erV3qZmW+XLAbOt+CVYWcI24QOPxb3DzkecIT3CwSd3 coWvcrCtYaCYcTtAjr7vQkCwddP6 X-Received: by 2002:a9d:39f5:: with SMTP id y108mr2647644otb.262.1592317159005; Tue, 16 Jun 2020 07:19: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 c9sm4031760oov.35.2020.06.16.07.19.17 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jun 2020 07:19:17 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Subject: [PATCH 64/78] tcg/i386: Fix INDEX_op_dup2_vec Date: Tue, 16 Jun 2020 09:15:33 -0500 Message-Id: <20200616141547.24664-65-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> References: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::344; envelope-from=flukshun@gmail.com; helo=mail-ot1-x344.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson We were only constructing the 64-bit element, and not replicating the 64-bit element across the rest of the vector. Cc: qemu-stable@nongnu.org Signed-off-by: Richard Henderson (cherry picked from commit e20cb81d9c5a3d0f9c08f3642728a210a1c162c9) Signed-off-by: Michael Roth --- tcg/i386/tcg-target.inc.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) -- 2.17.1 diff --git a/tcg/i386/tcg-target.inc.c b/tcg/i386/tcg-target.inc.c index 9d8ed974e0..77b78c941c 100644 --- a/tcg/i386/tcg-target.inc.c +++ b/tcg/i386/tcg-target.inc.c @@ -2855,9 +2855,13 @@ static void tcg_out_vec_op(TCGContext *s, TCGOpcode opc, goto gen_simd; #if TCG_TARGET_REG_BITS == 32 case INDEX_op_dup2_vec: - /* Constraints have already placed both 32-bit inputs in xmm regs. */ - insn = OPC_PUNPCKLDQ; - goto gen_simd; + /* First merge the two 32-bit inputs to a single 64-bit element. */ + tcg_out_vex_modrm(s, OPC_PUNPCKLDQ, a0, a1, a2); + /* Then replicate the 64-bit elements across the rest of the vector. */ + if (type != TCG_TYPE_V64) { + tcg_out_dup_vec(s, type, MO_64, a0, a0); + } + break; #endif case INDEX_op_abs_vec: insn = abs_insn[vece]; From patchwork Tue Jun 16 14:15:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 188048 Delivered-To: patch@linaro.org Received: by 2002:a92:cf06:0:0:0:0:0 with SMTP id c6csp3728923ilo; Tue, 16 Jun 2020 08:01:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzKn1uEVAqPSxQijO72ERMkZCja45/YgLOYIfJZ8Iu/uEfO4xYdT9M5nLeSwncj/l3EzxqT X-Received: by 2002:a25:9843:: with SMTP id k3mr4790061ybo.444.1592319710983; Tue, 16 Jun 2020 08:01:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592319710; cv=none; d=google.com; s=arc-20160816; b=mFZEvpJc3FKi8OvkOM4J2MXXhPTzw3d2MaHytdXq8m4AVoJoQ3lGC75vHjsF70o04x B4FPcm9Z6BqZ/racJEdO0c8q/X0uUQ4u9i0Ntwf9iJG7zznz9ibmQcrtaSWuwezPfq7O 7mfaD4xeOXRaP7YAiEFYr6lP3bvEN25+MFORwny55WQIFnzgu5OXXTFsXCcUn7EuF7Mg wvurKwGLglzvBkfIKQJ/KJisDicRGGb0amCZbMalFetjIJcg55sflstt/uIII6sdP+Cg x1MWuwqbUYXSXQnjY32dXRsFvCT3AlctAKl6c6PUDH/fhn7efUlKUbfSjxtC2IArjCOj Xy2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=noqPjXnkCbN2ZwLY+0aBhSvH8URJIHJjto2UAYCZdFY=; b=bU9NC/Z/udERzNjlcyku0wlnUY8A5Fdl4axj2hP4ycGZdRbqiBgnxKddP5iuQslm6I GKHrpuDovrJCx0MQy4AKT+FZlF/nANDU/LEB4G0M+ByKXJgZ1KihmnEBJapPBa2z1LIr B2kK7ZZUzgO1rGvqTJuAhjYsiU35FvkZIgcy/VJ5ibq+Z1mq4odW22evXDepNLHsq3Zx YNc7Ug+k7bromsz5dJw60dpRCLhDEZt6FhHwvXz57gaL3sNj5vSuEVItnkc6rAowLFjl tDriJBrXDtDbExkGm5xronseYmZ0pe32t3HE5CcsS+ZnlIpjZbtGj3gtOloCG37o1OPq dtZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=OzBXBMUw; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id f67si16603238ybi.238.2020.06.16.08.01.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jun 2020 08:01:50 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=OzBXBMUw; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from localhost ([::1]:35474 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlD5y-0005xk-8c for patch@linaro.org; Tue, 16 Jun 2020 11:01:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58252) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlCQu-000413-Kf; Tue, 16 Jun 2020 10:19:24 -0400 Received: from mail-oi1-x241.google.com ([2607:f8b0:4864:20::241]:46995) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jlCQs-000716-WC; Tue, 16 Jun 2020 10:19:24 -0400 Received: by mail-oi1-x241.google.com with SMTP id 25so19337111oiy.13; Tue, 16 Jun 2020 07:19: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 :mime-version:content-transfer-encoding; bh=noqPjXnkCbN2ZwLY+0aBhSvH8URJIHJjto2UAYCZdFY=; b=OzBXBMUwVENfA+rErN79JRgTSK7Ty6MTtCvqcKXgUxY4H7BQBsH8lYGZF1p4rj/KIR XUwFeD3rxWUq2UOvtZYTpEWA2AFBU9fkZM4cFU+/nQsdySVQcIjmVM/u9wCMhFBcWogv WMPllz5L1uV/oLVhoWGS4a6MjgFVd6gS/NCo82WxU+oLvIvYfq/lj48zwitqnCx9PSys lTA+n0FOfqvGR1agwyN4h6yyiISEGpZfOO42tZPL/bgdjo3XM6l0UmShpT0VZc7XSy7G HYDFLckqnI2jN2GaW2p+eNvmlzq7GjhFcS5yXMf1p6yoPDPldEgTxe5q4rEIhg5GCmFJ AQhQ== 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=noqPjXnkCbN2ZwLY+0aBhSvH8URJIHJjto2UAYCZdFY=; b=g59UHjwZzOolUZeZFgnffc84OndIAbimn15wjdaRsBjTm8cFxx3z/aulMHO70H/ibW MzDNTxVWIQd+s7vSButTfpmDV/LQXUjVLySJ7yQL2JNeHyNMFXyc7hO3mHjVT59w7BMW 0tSF55dyDRuoLn+djFYcfSHS1n+WN8VDL9T9y1Mw5wJ8ou/b+Ehm1l16a3cS0iwU2Hrm JUvkrqn04iVttG1K6C2cTmsEwGBbbLpPF0oprvmc0DuXOf/aeXvpWPlL5VmpguHNpryu f+vl3glXeJlKnhIJsvCrpS8Oo2ULWRA0ezDg8lxaHBtu77K9zfStFwRwLa+tIeYL4ZS0 P9gw== X-Gm-Message-State: AOAM532dub78ZP8x4x0vnk8kv5I4wHXCuiDlpUa0Jn6bx91c2kEv6a/s slWsjDVTaVpY9OktyayD0ia+Z+gx X-Received: by 2002:a05:6808:b14:: with SMTP id s20mr3636322oij.155.1592317161054; Tue, 16 Jun 2020 07:19:21 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id m18sm4155903ooe.12.2020.06.16.07.19.19 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jun 2020 07:19:20 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Subject: [PATCH 65/78] dump: Fix writing of ELF section Date: Tue, 16 Jun 2020 09:15:34 -0500 Message-Id: <20200616141547.24664-66-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> References: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::241; envelope-from=flukshun@gmail.com; helo=mail-oi1-x241.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell In write_elf_section() we set the 'shdr' pointer to point to local structures shdr32 or shdr64, which we fill in to be written out to the ELF dump. Unfortunately the address we pass to fd_write_vmcore() has a spurious '&' operator, so instead of writing out the section header we write out the literal pointer value followed by whatever is on the stack after the 'shdr' local variable. Pass the correct address into fd_write_vmcore(). Spotted by Coverity: CID 1421970. Cc: qemu-stable@nongnu.org Signed-off-by: Peter Maydell Reviewed-by: Marc-André Lureau Reviewed-by: Philippe Mathieu-Daudé Message-id: 20200324173630.12221-1-peter.maydell@linaro.org (cherry picked from commit 174d2d6856bf435f4f58e9303ba30dd0e1279d3f) Signed-off-by: Michael Roth --- dump/dump.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.17.1 diff --git a/dump/dump.c b/dump/dump.c index 6fb6e1245a..22ed1d3b0d 100644 --- a/dump/dump.c +++ b/dump/dump.c @@ -364,7 +364,7 @@ static void write_elf_section(DumpState *s, int type, Error **errp) shdr = &shdr64; } - ret = fd_write_vmcore(&shdr, shdr_size, s); + ret = fd_write_vmcore(shdr, shdr_size, s); if (ret < 0) { error_setg_errno(errp, -ret, "dump: failed to write section header table"); From patchwork Tue Jun 16 14:15:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 280322 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9367EC433E0 for ; Tue, 16 Jun 2020 15:02:37 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6596220644 for ; Tue, 16 Jun 2020 15:02:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EuC3QgdI" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6596220644 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:40838 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlD6i-0008J2-It for qemu-devel@archiver.kernel.org; Tue, 16 Jun 2020 11:02:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58278) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlCQy-0004A8-Ge; Tue, 16 Jun 2020 10:19:28 -0400 Received: from mail-oi1-x242.google.com ([2607:f8b0:4864:20::242]:42132) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jlCQw-00071X-S1; Tue, 16 Jun 2020 10:19:28 -0400 Received: by mail-oi1-x242.google.com with SMTP id s21so19371882oic.9; Tue, 16 Jun 2020 07:19: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 :mime-version:content-transfer-encoding; bh=4th/1Paxx9afMaB06sbfxHi7/R5Y+YQCpXI6dbC8fig=; b=EuC3QgdI1032Fdah8iGAenrSBnmrTivos7ZlFA82iW61CF+n4QyRv+8AtEcsskD4Ie 5a4hRcxzarlwYmJ1B2a4C3MXYbs7upBecsAUh7cFLJSC7a644Pix8CgEaFSf95FXVav9 Qi4HwlBy5BOjNF8DhbT4PVeP+YlDmf0jgGAcFLg5+kcmGfIrTynpjwvJEms/+S2ZUSCf lXI6gLtVc8ILeF/zrpnTYrIRZ/p70V0UPUs7X3inJzYM+Wkr4bfjBQ44J8wHaJMrVTsU zHZPPeWP8R1HmVAs5N2M8X3E0G/w6sqYLWoXEyAI2UuRhzLudQQY6vnJnkUIEV2iWGP2 z/fg== 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=4th/1Paxx9afMaB06sbfxHi7/R5Y+YQCpXI6dbC8fig=; b=VyEv9gNTT1u3WXnzfYTAe+ee5UNa72/chUVEKk2PnLC6VM9+c7KBgLDBrgqtMcqff3 ZyCCXMbbyrOgH+MO8mHipykX4SsOqYDSa1jNGr3TC0cHu5EgTHM8PMZV0pVpJAOTFH8p Pg4VseXmXPNAetLWlS63DM9GW8g55tTVmGwo9n8Klteam/+/gPOGnbLv3NVzI+ejDcoN 7tMyVKPd2L326PBUavD2ooi6ROBvMWzg1vQVT3BJykt6+so52Q/+PdZ9pEBRXQQni1mO 7nQQ5FQkofNzkwJYKHvcfIxVZqw6fkFPAH4CqMRnvnToR5OQ0T+KJtM/aq91PrX3hM/O ZAxA== X-Gm-Message-State: AOAM533njVHJmmaLM6DjR7lP3dBbR9wZDm8wmZ7d4CDcgGhj8bd2doO8 YzZA8s17UGqW6UA7vb7byxioTMq+/9o= X-Google-Smtp-Source: ABdhPJyJ9i3fD/IYbNRvWq7d49O7DpYeRbTyTeiILXBPO5wbubRhwAUKmJJEjvpYQqUtQlzjn7ImLQ== X-Received: by 2002:a54:4d96:: with SMTP id y22mr3269197oix.55.1592317164853; Tue, 16 Jun 2020 07:19:24 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id h27sm2129255otg.23.2020.06.16.07.19.23 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jun 2020 07:19:23 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Subject: [PATCH 67/78] vhost-user-gpu: Release memory returned by vu_queue_pop() with free() Date: Tue, 16 Jun 2020 09:15:36 -0500 Message-Id: <20200616141547.24664-68-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> References: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::242; envelope-from=flukshun@gmail.com; helo=mail-oi1-x242.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , =?utf-8?q?Philippe_Mathieu-D?= =?utf-8?b?YXVkw6k=?= , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé vu_queue_pop() returns memory that must be freed with free(). Cc: qemu-stable@nongnu.org Reported-by: Coverity (CID 1421887 ALLOC_FREE_MISMATCH) Suggested-by: Peter Maydell Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Marc-André Lureau Signed-off-by: Peter Maydell (cherry picked from commit 4ff97121a3ee631971aadc87e3d4e7fb66f15aa8) Signed-off-by: Michael Roth --- contrib/vhost-user-gpu/main.c | 4 ++-- contrib/vhost-user-gpu/virgl.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/contrib/vhost-user-gpu/main.c b/contrib/vhost-user-gpu/main.c index b45d2019b4..a019d0a9ac 100644 --- a/contrib/vhost-user-gpu/main.c +++ b/contrib/vhost-user-gpu/main.c @@ -848,7 +848,7 @@ vg_handle_ctrl(VuDev *dev, int qidx) QTAILQ_INSERT_TAIL(&vg->fenceq, cmd, next); vg->inflight++; } else { - g_free(cmd); + free(cmd); } } } @@ -939,7 +939,7 @@ vg_handle_cursor(VuDev *dev, int qidx) } vu_queue_push(dev, vq, elem, 0); vu_queue_notify(dev, vq); - g_free(elem); + free(elem); } } diff --git a/contrib/vhost-user-gpu/virgl.c b/contrib/vhost-user-gpu/virgl.c index 43413e29df..b0bc22c3c1 100644 --- a/contrib/vhost-user-gpu/virgl.c +++ b/contrib/vhost-user-gpu/virgl.c @@ -519,7 +519,7 @@ virgl_write_fence(void *opaque, uint32_t fence) g_debug("FENCE %" PRIu64, cmd->cmd_hdr.fence_id); vg_ctrl_response_nodata(g, cmd, VIRTIO_GPU_RESP_OK_NODATA); QTAILQ_REMOVE(&g->fenceq, cmd, next); - g_free(cmd); + free(cmd); g->inflight--; } } From patchwork Tue Jun 16 14:15:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 280320 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 227C8C433E0 for ; Tue, 16 Jun 2020 15:06:52 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DC36E20786 for ; Tue, 16 Jun 2020 15:06:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="pZeZIXer" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DC36E20786 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:56454 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlDAp-0007Cy-47 for qemu-devel@archiver.kernel.org; Tue, 16 Jun 2020 11:06:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58316) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlCR2-0004J5-E4; Tue, 16 Jun 2020 10:19:32 -0400 Received: from mail-ot1-x342.google.com ([2607:f8b0:4864:20::342]:32780) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jlCR0-00071u-Q6; Tue, 16 Jun 2020 10:19:32 -0400 Received: by mail-ot1-x342.google.com with SMTP id n6so16069938otl.0; Tue, 16 Jun 2020 07:19:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GSZfWFoXNTSGnh+M3lmAlBzkhHMx2WNUVXqbsauaOG4=; b=pZeZIXermwJMrDKQ83R4TtmZScmBcqjj/CtZ1flh0tH1nm4Oc64wMkXHo2lFfK4ox7 q21U7Zzf/V+up3EriCmcq+Jik4zCoLoKMyOxcjH/+Zr2FkiPY8QVTKoImOyBpgedyUYQ MzMlWEEqY5cy6UbWYCMNjewl56z2Qfo3WVwl0XFjfj1YuayjpQAEkDpml/B0JZcdaPPb YiMwPhjBCryVmsOo1RrzI8Moo1ymoZl8ofn4mBiBNyo8suYEPdFNe/XLUJYUQeFN21FF N0PuiVS0aQ/Tg6RKffpq172HzRhlP2vVwbVdpAP5TV+vq2N6wT7wJmxpr3BikMmVBDAD 08ig== 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=GSZfWFoXNTSGnh+M3lmAlBzkhHMx2WNUVXqbsauaOG4=; b=eA4fGGvLPpSzVEc3gOJPZ8E9nS/tRxwQH1CF0A9dAWxCoP+sP3rrBkfE2ehhCoARDD otIRPFWXVkLH3LtrV6M444/LzTFFV1WirXSS3Me7E/pZCXK7GduGKGEH6P/ZTM4O+XZp LOj8BssyDmDG5dmFEOEv9oyLs2JIf2Oxo8vR47rYNY5I9lVHfCGLEjYRZvb1dQ2Lw+FR I26M+AFuQPsKge+CYSOd1/Bf0zECK8i+doveRExIGDa1WgrNHMupodWpIUmAbkUxk/X6 54uctTiTil0x3SP5KP63EqA7YDy5qEBGf0LBzHvf/9wCYYx2RGOAeWPd5iO3pLrkQZKH hHUg== X-Gm-Message-State: AOAM533aoCw/xkDYZv2fl3lG0FcaeVqt1KpcOQqvt2DObZipMiEm5AcT U8B1/GOgkLLUPRbjS0OV3zX92AvHjLM= X-Google-Smtp-Source: ABdhPJwA8v5akFDw+7piDRGgsNddhM/t6lethh0+hfEQmDc66qTEPI/nvOftRYt/unmH8n7zB3iDlg== X-Received: by 2002:a05:6830:1f1b:: with SMTP id u27mr2693775otg.327.1592317168834; Tue, 16 Jun 2020 07:19: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 q2sm4180208oti.36.2020.06.16.07.19.27 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jun 2020 07:19:27 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Subject: [PATCH 69/78] hostmem: don't use mbind() if host-nodes is empty Date: Tue, 16 Jun 2020 09:15:38 -0500 Message-Id: <20200616141547.24664-70-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> References: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::342; envelope-from=flukshun@gmail.com; helo=mail-ot1-x342.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Igor Mammedov , qemu-stable@nongnu.org, Eduardo Habkost Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Igor Mammedov Since 5.0 QEMU uses hostmem backend for allocating main guest RAM. The backend however calls mbind() which is typically NOP in case of default policy/absent host-nodes bitmap. However when runing in container with black-listed mbind() syscall, QEMU fails to start with error "cannot bind memory to host NUMA nodes: Operation not permitted" even when user hasn't provided host-nodes to pin to explictly (which is the case with -m option) To fix issue, call mbind() only in case when user has provided host-nodes explicitly (i.e. host_nodes bitmap is not empty). That should allow to run QEMU in containers with black-listed mbind() without memory pinning. If QEMU provided memory-pinning is required user still has to white-list mbind() in container configuration. Reported-by: Manuel Hohmann Signed-off-by: Igor Mammedov Message-Id: <20200430154606.6421-1-imammedo@redhat.com> Tested-by: Philippe Mathieu-Daudé Cc: qemu-stable@nongnu.org Signed-off-by: Eduardo Habkost (cherry picked from commit 70b6d525dfb51d5e523d568d1139fc051bc223c5) Signed-off-by: Michael Roth --- backends/hostmem.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/backends/hostmem.c b/backends/hostmem.c index e773bdfa6e..21b1993e49 100644 --- a/backends/hostmem.c +++ b/backends/hostmem.c @@ -363,8 +363,10 @@ host_memory_backend_memory_complete(UserCreatable *uc, Error **errp) assert(sizeof(backend->host_nodes) >= BITS_TO_LONGS(MAX_NODES + 1) * sizeof(unsigned long)); assert(maxnode <= MAX_NODES); - if (mbind(ptr, sz, backend->policy, - maxnode ? backend->host_nodes : NULL, maxnode + 1, flags)) { + + if (maxnode && + mbind(ptr, sz, backend->policy, backend->host_nodes, maxnode + 1, + flags)) { if (backend->policy != MPOL_DEFAULT || errno != ENOSYS) { error_setg_errno(errp, errno, "cannot bind memory to host NUMA nodes"); From patchwork Tue Jun 16 14:15:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 188049 Delivered-To: patch@linaro.org Received: by 2002:a92:cf06:0:0:0:0:0 with SMTP id c6csp3731289ilo; Tue, 16 Jun 2020 08:04:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy02xPvKYSWflu2VVxb5UzVFZ2mhvKJWtgBRZZg1APZj4+1K135HRh8GAlsXfJkmIayqOb7 X-Received: by 2002:a25:bcc2:: with SMTP id l2mr4484207ybm.154.1592319849116; Tue, 16 Jun 2020 08:04:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592319849; cv=none; d=google.com; s=arc-20160816; b=CMurcuT+JzQg1fLhIrYzBtqurcS09ai4vg4yWlMr66b35/o4xO9EQoq7v5ukdAuO6F 30Z8+tYfRB3e4o/95SYwLAIbIVfzTkjMwSSTD9tKNSAuBlmMCSb6nSslVwbPKhv7v+sB 5SDHOqARpQB4t1jbhGNabZtWxIcVcmh7aQaxxzvNWSAXAEteAbrpTxgFsecjIjv+G5XF +B+BlLQj5qjGcJvPO73zsZj48Y55zDEm8QQGwS9Qkh+cG3iPyZC3Aavzy8gvAUzHc2gS XNZwgfAj/k8qdjkgrwXnzbOw36KjFwyQEqaEjN9KG7I7y4xLIgepCoVKgofw6QzVFqGt UN3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:references:in-reply-to :message-id:date:subject:to:from:dkim-signature; bh=3BFt3zvBmH3599GWUmBzmTB/ubSoG/ped8JbzfOjFXw=; b=WhiXg054wQXR9tJXW+24rSorrMSebYa+fGLrf4XqAxmiuwN35+wQj/e6ybHwugbzCt Xhhc7Cf0oD/+q9oaEfUUEJNaSFUqcXD3j9Jqw8OgmNB/sEN/rq/lksA76EH6hnVmrq2M ABL8R2E/jmAtRMwqZN3L2AqK3Ldxu7PetTKTHa8k0bKMB8YvaIR1mw8ezBSrs8fOnwfN 33n363zwqRMezEyeq5bM5UKmNJ94PRmCMlOLVcfL5T1WUn/kPsoZTNRIu7wF29GHnRFG wGB42R8JZuskgeRrGcf7kEcTjF2G2+1rgEswb4jeqxORn28n3UASfomw6noIV69hfwHH BXcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=kNvEQ8B4; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id z7si17587899ybh.132.2020.06.16.08.04.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jun 2020 08:04:09 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=kNvEQ8B4; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from localhost ([::1]:45898 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlD8C-000250-JL for patch@linaro.org; Tue, 16 Jun 2020 11:04:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58328) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlCR3-0004Mt-Va; Tue, 16 Jun 2020 10:19:33 -0400 Received: from mail-ot1-x344.google.com ([2607:f8b0:4864:20::344]:36793) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jlCR2-00072A-EG; Tue, 16 Jun 2020 10:19:33 -0400 Received: by mail-ot1-x344.google.com with SMTP id 97so16065216otg.3; Tue, 16 Jun 2020 07:19: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=3BFt3zvBmH3599GWUmBzmTB/ubSoG/ped8JbzfOjFXw=; b=kNvEQ8B4wVz1tV+sEO5jSOSA3DzQsWrbhzaNXYblj7yVmLs+VzrYpLEjlc5u6AE+KG NWHIXqYgDJMDdgpizSb9rN+YLnRbT6L1ltd/6muxIdWTlyB8asuA/ue3+JauMetGZIfS +c+9Dh8VDBTJFAPQRYQ439UORUrxATz2mtwfZVcBxz35ElMuMusVU6FNE9fkBkPgGrgk Bwm0LN7R0XJkZkY4O4Qr/4yX2pMzwnoSP1SpU0NYIfEfBnTHSf0va5CNDrkOwf4IEnOW j1c01cqO0RupiBT0aXXWoTI6J7hg5MCt84MIhV3MJKlnRay1eOvg2ozMVXqB++IluJu5 /lAg== 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=3BFt3zvBmH3599GWUmBzmTB/ubSoG/ped8JbzfOjFXw=; b=XXYObBI0xJxekcCOSNzYEerqmhJ9ehIc8gH2Kr3m+p1vvktE3umv/AizlRZFTDebK8 8hmTQuwpGGSuu9a2g8G8hvUA2ow8WdWIIZP8HzckcCUDlIDAfDDo4PeeQmEanX2Qoo8C I9/CpmJgyRwCbrPNlcutx/4ssM2OxW8BQZtYPqUcdS0aHTfZIQMI1m1h/NrvgqRM34q4 X/4INqNzgLDPfM/Zd+8olFRLP9O0qhvos/JTx2erV1au5OijKaEZhTU2HnhlSYybxftk HmL7g5tzCmrwjpXTyAG3/9fXjYbLev7XXPpb6v29Fh1U9r+fxB2WUsv/UJqpXpwOYAKR 9JgA== X-Gm-Message-State: AOAM530LiVhd3hLnGAqMFJHhy9KK6uzCeV5Rqo/ZwOv7sjHiHsSb5Egl 11hg78O8MLpIp6yXKqXReCqG7vZmS3A= X-Received: by 2002:a05:6830:1e61:: with SMTP id m1mr2475536otr.13.1592317170646; Tue, 16 Jun 2020 07:19:30 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id g51sm4042298otg.17.2020.06.16.07.19.29 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jun 2020 07:19:29 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Subject: [PATCH 70/78] target/arm: Clear tail in gvec_fmul_idx_*, gvec_fmla_idx_* Date: Tue, 16 Jun 2020 09:15:39 -0500 Message-Id: <20200616141547.24664-71-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> References: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::344; envelope-from=flukshun@gmail.com; helo=mail-ot1-x344.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Must clear the tail for AdvSIMD when SVE is enabled. Fixes: ca40a6e6e39 Cc: qemu-stable@nongnu.org Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Message-id: 20200513163245.17915-15-richard.henderson@linaro.org Signed-off-by: Peter Maydell (cherry picked from commit 525d9b6d42844e187211d25b69be8b378785bc24) Signed-off-by: Michael Roth --- target/arm/vec_helper.c | 2 ++ 1 file changed, 2 insertions(+) -- 2.17.1 diff --git a/target/arm/vec_helper.c b/target/arm/vec_helper.c index dedef62403..a9f40ac78a 100644 --- a/target/arm/vec_helper.c +++ b/target/arm/vec_helper.c @@ -737,6 +737,7 @@ void HELPER(NAME)(void *vd, void *vn, void *vm, void *stat, uint32_t desc) \ d[i + j] = TYPE##_mul(n[i + j], mm, stat); \ } \ } \ + clear_tail(d, oprsz, simd_maxsz(desc)); \ } DO_MUL_IDX(gvec_fmul_idx_h, float16, H2) @@ -761,6 +762,7 @@ void HELPER(NAME)(void *vd, void *vn, void *vm, void *va, \ mm, a[i + j], 0, stat); \ } \ } \ + clear_tail(d, oprsz, simd_maxsz(desc)); \ } DO_FMLA_IDX(gvec_fmla_idx_h, float16, H2) From patchwork Tue Jun 16 14:15:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 280319 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 34EC0C433E1 for ; Tue, 16 Jun 2020 15:06:58 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 059F720786 for ; Tue, 16 Jun 2020 15:06:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="SWbKEzDJ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 059F720786 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:57006 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlDAv-0007Qv-9B for qemu-devel@archiver.kernel.org; Tue, 16 Jun 2020 11:06:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58378) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlCRA-0004aj-1y; Tue, 16 Jun 2020 10:19:40 -0400 Received: from mail-ot1-x343.google.com ([2607:f8b0:4864:20::343]:43071) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jlCR8-00072y-I3; Tue, 16 Jun 2020 10:19:39 -0400 Received: by mail-ot1-x343.google.com with SMTP id u23so16059903otq.10; Tue, 16 Jun 2020 07:19:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=3JNcCSJ/kBeHtX0/zO54ZJ/KkiPaS7XdkWk5gBIKMaU=; b=SWbKEzDJXTlhOGPRxCBUq/VSJTxerFgtd6Js8v/0C6pZP42/d7VmKVUtNVp/Ng7zTN 52+wKw8QPoE5L3GseyveeiAvhscfGg05acMSggGQYZ7MeTYj4A4rr2StJIrEnBm1SK41 qs23tYmEvDUio+nvdlADrPrJCuiCeroXxaBtNcSgCplPB+WJjxq5knzcdgRFE0pTnnOq RWxdCWfJ2jWDLV9QpG1RQ+Be9nT8/OdmLsS/j4nWOYOmmppIrEn4UZsoLSeW9mhiZDnh 6yukUJ7MPA2zmnIEv/3/LNLS7UgXcHuAJ944JjlvGhtg12Mc89IZZ+CWcPVkW+zy+jYu gsgQ== 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=3JNcCSJ/kBeHtX0/zO54ZJ/KkiPaS7XdkWk5gBIKMaU=; b=Dwqnd/3/D75KU6Of0/09k40jEmzNRbV7vDozPz1FzTQRV4g1wbnUcGOo8/9KbNH5HD jARK12Iz/Ne531ID0QrS21iK6B763J/wK6uReCHfEqBHswd4eVTv1AI7R/ZDYi5saPvJ H01YHa2/0YwXic08zeaDhXr5zHYUpK4oFer2QLJqElWQ0vnEihHYEAJ5CsjWr+UhKXyx nrKslOj0VzjDwLoxXUhbfHlfSedVVh8EyfVvcerZgbqLocPr6iqJXBvOrHbmiar218wf ONbbgctxCqxhp8vs67DsNp6XQ7WW8Povokeic2vzWVo8/1+eThvwVGpI0TjPnQX/z5+k Vogg== X-Gm-Message-State: AOAM530sZIOaMHL5ElgEHYzUdF2Cm0b0HDRPpo/WmmtbdY4MN/uu/5DY FgxOP49CtuKh7hZe3d36Y0lDy5X8LIU= X-Google-Smtp-Source: ABdhPJy0zRa7wP88F5KjuCugrmlQdMpDBcO2hNniESaGdgXtaIWBf1ofT9K0oNIf88rlsLAmNZd08g== X-Received: by 2002:a9d:2de6:: with SMTP id g93mr2787749otb.28.1592317175739; Tue, 16 Jun 2020 07:19: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 w1sm4123203ooq.1.2020.06.16.07.19.34 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jun 2020 07:19:35 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Subject: [PATCH 72/78] 9p: Lock directory streams with a CoMutex Date: Tue, 16 Jun 2020 09:15:41 -0500 Message-Id: <20200616141547.24664-73-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> References: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::343; envelope-from=flukshun@gmail.com; helo=mail-ot1-x343.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Greg Kurz Locking was introduced in QEMU 2.7 to address the deprecation of readdir_r(3) in glibc 2.24. It turns out that the frontend code is the worst place to handle a critical section with a pthread mutex: the code runs in a coroutine on behalf of the QEMU mainloop and then yields control, waiting for the fsdev backend to process the request in a worker thread. If the client resends another readdir request for the same fid before the previous one finally unlocked the mutex, we're deadlocked. This never bit us because the linux client serializes readdir requests for the same fid, but it is quite easy to demonstrate with a custom client. A good solution could be to narrow the critical section in the worker thread code and to return a copy of the dirent to the frontend, but this causes quite some changes in both 9p.c and codir.c. So, instead of that, in order for people to easily backport the fix to older QEMU versions, let's simply use a CoMutex since all the users for this sit in coroutines. Fixes: 7cde47d4a89d ("9p: add locking to V9fsDir") Reviewed-by: Christian Schoenebeck Message-Id: <158981894794.109297.3530035833368944254.stgit@bahia.lan> Signed-off-by: Greg Kurz (cherry picked from commit ed463454efd0ac3042ff772bfe1b1d846dc281a5) Signed-off-by: Michael Roth --- hw/9pfs/9p.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/9pfs/9p.h b/hw/9pfs/9p.h index 3904f82901..069c86333f 100644 --- a/hw/9pfs/9p.h +++ b/hw/9pfs/9p.h @@ -186,22 +186,22 @@ typedef struct V9fsXattr typedef struct V9fsDir { DIR *stream; - QemuMutex readdir_mutex; + CoMutex readdir_mutex; } V9fsDir; static inline void v9fs_readdir_lock(V9fsDir *dir) { - qemu_mutex_lock(&dir->readdir_mutex); + qemu_co_mutex_lock(&dir->readdir_mutex); } static inline void v9fs_readdir_unlock(V9fsDir *dir) { - qemu_mutex_unlock(&dir->readdir_mutex); + qemu_co_mutex_unlock(&dir->readdir_mutex); } static inline void v9fs_readdir_init(V9fsDir *dir) { - qemu_mutex_init(&dir->readdir_mutex); + qemu_co_mutex_init(&dir->readdir_mutex); } /* From patchwork Tue Jun 16 14:15:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 280318 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CB4BFC433E0 for ; Tue, 16 Jun 2020 15:08:56 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 514FE20786 for ; Tue, 16 Jun 2020 15:08:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="qifVdR3N" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 514FE20786 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:36946 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlDCp-0002Xj-Bp for qemu-devel@archiver.kernel.org; Tue, 16 Jun 2020 11:08:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58396) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlCRB-0004dk-9I; Tue, 16 Jun 2020 10:19:41 -0400 Received: from mail-ot1-x344.google.com ([2607:f8b0:4864:20::344]:41889) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jlCR9-000734-J9; Tue, 16 Jun 2020 10:19:40 -0400 Received: by mail-ot1-x344.google.com with SMTP id k15so16046034otp.8; Tue, 16 Jun 2020 07:19: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=kAY3Dn2N1bHaiQSIZRgbVopwR1kTKhAsT3MjOygGjVA=; b=qifVdR3NpgESKquRDTJKu0r4SlbeUQmTzdnUiSHPHMkDB80rdOxPXUaw0dcjRpRucf +eF/uS6WIM6UYEakBAK/sH9BZZYv+EfayDJ7CSAnWPXQob7lBnhgdAzXOAN/NpQHK6Xh SJkfDjkl1YfKWcUo0+4WPEWvYDb5M/gS2Cq47pFydCXEJJS3AZ2sm3LlM+0oblLDMFUg MNa6H7a40jRRhCgywJl7hKoIySuKUY1ZdkxU4qaxOrXkW5YJdToQTRAsbv6bibdKS+VQ Ld2Op//B9qTfTRy+Q68I8NG0c1qR3NM/LADC7utA4/qLeZY6XilXFtr+Axtmj/W6BC76 Y9AA== 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=kAY3Dn2N1bHaiQSIZRgbVopwR1kTKhAsT3MjOygGjVA=; b=N0iO6AVoh8OcnQAyHdI0zU5oN8plc1YeUGTviB2/qf4Egf+8xG9JkzLVTDoc0jfenl shRdU7ncAtMkMFHxuYdqJ10OIwLcf+Ltp8bwk7LTBVNhRYXyRrug6vBCFWuT6tmzWmZl B61oEZmIgAvQuhEmHf0GhgoOdEOFPpJZEw7B4audVDcqyNyOjAn0l/dpRbF3qqHDdSX+ iacReB5QON2ebLbkyeJ3NscApnnvrzZOJtaW1u055dEHTNRrT+85LBedDC/E90yNT8GU 6b4giCZ8Adm5i9Y2Ab/vo+rlWDKhOJngY6S4UTTEfkpM0aWQ9pMSa76BYdPprvCrd96E iFNw== X-Gm-Message-State: AOAM532CDKDvToy18EpMKqNJQBbXPfchrEFvFZUtiweBD80SfPCg8T9E Tgn6OhIwM0yGl50SZO+Tr1/mt362ikQ= X-Google-Smtp-Source: ABdhPJzSaBmx+9tvAUsCnDJq8AbtirjnA2aqB3i0DTmNRZUJwerV+z2vnRsKY4VVNy3exTDFqU59oQ== X-Received: by 2002:a9d:4691:: with SMTP id z17mr2524965ote.88.1592317176949; Tue, 16 Jun 2020 07:19:36 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id k7sm4035245oon.29.2020.06.16.07.19.36 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jun 2020 07:19:36 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Subject: [PATCH 73/78] net: Do not include a newline in the id of -nic devices Date: Tue, 16 Jun 2020 09:15:42 -0500 Message-Id: <20200616141547.24664-74-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> References: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::344; envelope-from=flukshun@gmail.com; helo=mail-ot1-x344.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , qemu-stable@nongnu.org, Laurent Vivier Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Thomas Huth The '\n' sneaked in by accident here, an "id" string should really not contain a newline character at the end. Fixes: 78cd6f7bf6b ('net: Add a new convenience option "--nic" ...') Signed-off-by: Thomas Huth Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20200518074352.23125-1-thuth@redhat.com> Signed-off-by: Laurent Vivier (cherry picked from commit 0561dfac082becdd9e89110249a27b309b62aa9f) Signed-off-by: Michael Roth --- net/net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/net.c b/net/net.c index 84aa6d8d00..58adaafba9 100644 --- a/net/net.c +++ b/net/net.c @@ -1524,7 +1524,7 @@ static int net_param_nic(void *dummy, QemuOpts *opts, Error **errp) /* Create an ID if the user did not specify one */ nd_id = g_strdup(qemu_opts_id(opts)); if (!nd_id) { - nd_id = g_strdup_printf("__org.qemu.nic%i\n", idx); + nd_id = g_strdup_printf("__org.qemu.nic%i", idx); qemu_opts_set_id(opts, nd_id); } From patchwork Tue Jun 16 14:15:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 280325 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 22B74C433DF for ; Tue, 16 Jun 2020 14:58:26 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E584C20644 for ; Tue, 16 Jun 2020 14:58:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="AHDiXuVa" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E584C20644 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:52664 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlD2f-0001UW-5E for qemu-devel@archiver.kernel.org; Tue, 16 Jun 2020 10:58:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58410) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlCRC-0004gp-Fy; Tue, 16 Jun 2020 10:19:42 -0400 Received: from mail-ot1-x335.google.com ([2607:f8b0:4864:20::335]:33095) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jlCRA-000738-DS; Tue, 16 Jun 2020 10:19:42 -0400 Received: by mail-ot1-x335.google.com with SMTP id n6so16070437otl.0; Tue, 16 Jun 2020 07:19:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=wTa4JXsyGprfTOQ8Gi0ZAfpppR1mnoFXQbPOUyCGbeA=; b=AHDiXuVaW8mbWnYKHaVlKB3o0TzMQMfM2eCdrO/vtPwaWmz/WZ7P260cFZU9loLjkU tauKFVKcHaHB8gceFghgQLCFmw1X2qrs/6lp810NpfwskmPY0MmE4oiEj5tB5+P/P+ic c3h1QyxhK5k+PjORnJXr+HqNqFj4f71Ybyo4asirih8bIX9vKczeDp+mSxDxFWCQfGvK DMAMkD+BJGfgdHj2Wp+y0vZN87IUqjmFLs0Mu3IZeuPTPuxVhsloI75KGIEPq/nf2wtB bAjRX1DB0Uruq60H5UQOJOnFsrkILPYBzG4275/pD/I0sw9OfFzVMBsqC+p6t8SzaK+d PVqQ== 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=wTa4JXsyGprfTOQ8Gi0ZAfpppR1mnoFXQbPOUyCGbeA=; b=n4INjOJJ1pqc9+JnRwG7FGnOyK5lG/ejOQV9MJ6pkQeXWi5JB0mf6rVSs3FfzOrqOA CtrD2MkL4HzsrOGZiBonKvr7lZd+uDkWbVYBEAC5yITPf8Wtnz174i4kBTaay9QqKQV3 8c0vaURRTHDxx3dpNUBbsnUCO+2getwXSLt+Hih8KYjE++MgCpyiRTy4IlYJFauj3peO SHWQo04KmrK9ZzsQm+0l2NJMYBZkDaT2oXEETghEeISAjDXnf71DU78V95KHGxqU3X9w Iy5B9DYbNKcTE5/Q0wTuHJYlJGZSClWxofKNReeDi49OT8XY10ukXyo845QFKEbCyo5l NPXg== X-Gm-Message-State: AOAM531Lvus5Y+2MWGDa36ksBVWW4aNzOW8+d/r9KXMsxiN96Is3uEwp n5RHY5wR2B/jyFNcvypQ3tgk+hoo0SE= X-Google-Smtp-Source: ABdhPJwpF8KZWlRaGuSWvv4bToelCH0bFP3NQucaLKzUXNtGVVVIZKBS3mwqwo6X4aiipKbJ/E0/Pg== X-Received: by 2002:a9d:e88:: with SMTP id 8mr2432781otj.279.1592317178203; Tue, 16 Jun 2020 07:19:38 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id c129sm946246oif.53.2020.06.16.07.19.37 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jun 2020 07:19:37 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Subject: [PATCH 74/78] nbd/server: Avoid long error message assertions CVE-2020-10761 Date: Tue, 16 Jun 2020 09:15:43 -0500 Message-Id: <20200616141547.24664-75-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> References: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::335; envelope-from=flukshun@gmail.com; helo=mail-ot1-x335.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Eric Blake Ever since commit 36683283 (v2.8), the server code asserts that error strings sent to the client are well-formed per the protocol by not exceeding the maximum string length of 4096. At the time the server first started sending error messages, the assertion could not be triggered, because messages were completely under our control. However, over the years, we have added latent scenarios where a client could trigger the server to attempt an error message that would include the client's information if it passed other checks first: - requesting NBD_OPT_INFO/GO on an export name that is not present (commit 0cfae925 in v2.12 echoes the name) - requesting NBD_OPT_LIST/SET_META_CONTEXT on an export name that is not present (commit e7b1948d in v2.12 echoes the name) At the time, those were still safe because we flagged names larger than 256 bytes with a different message; but that changed in commit 93676c88 (v4.2) when we raised the name limit to 4096 to match the NBD string limit. (That commit also failed to change the magic number 4096 in nbd_negotiate_send_rep_err to the just-introduced named constant.) So with that commit, long client names appended to server text can now trigger the assertion, and thus be used as a denial of service attack against a server. As a mitigating factor, if the server requires TLS, the client cannot trigger the problematic paths unless it first supplies TLS credentials, and such trusted clients are less likely to try to intentionally crash the server. We may later want to further sanitize the user-supplied strings we place into our error messages, such as scrubbing out control characters, but that is less important to the CVE fix, so it can be a later patch to the new nbd_sanitize_name. Consideration was given to changing the assertion in nbd_negotiate_send_rep_verr to instead merely log a server error and truncate the message, to avoid leaving a latent path that could trigger a future CVE DoS on any new error message. However, this merely complicates the code for something that is already (correctly) flagging coding errors, and now that we are aware of the long message pitfall, we are less likely to introduce such errors in the future, which would make such error handling dead code. Reported-by: Xueqiang Wei CC: qemu-stable@nongnu.org Fixes: https://bugzilla.redhat.com/1843684 CVE-2020-10761 Fixes: 93676c88d7 Signed-off-by: Eric Blake Message-Id: <20200610163741.3745251-2-eblake@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy (cherry picked from commit 5c4fe018c025740fef4a0a4421e8162db0c3eefd) Signed-off-by: Michael Roth --- nbd/server.c | 23 ++++++++++++++++++++--- tests/qemu-iotests/143 | 4 ++++ tests/qemu-iotests/143.out | 2 ++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/nbd/server.c b/nbd/server.c index 24ebc1a805..d5b9df092c 100644 --- a/nbd/server.c +++ b/nbd/server.c @@ -217,7 +217,7 @@ nbd_negotiate_send_rep_verr(NBDClient *client, uint32_t type, msg = g_strdup_vprintf(fmt, va); len = strlen(msg); - assert(len < 4096); + assert(len < NBD_MAX_STRING_SIZE); trace_nbd_negotiate_send_rep_err(msg); ret = nbd_negotiate_send_rep_len(client, type, len, errp); if (ret < 0) { @@ -231,6 +231,19 @@ nbd_negotiate_send_rep_verr(NBDClient *client, uint32_t type, return 0; } +/* + * Return a malloc'd copy of @name suitable for use in an error reply. + */ +static char * +nbd_sanitize_name(const char *name) +{ + if (strnlen(name, 80) < 80) { + return g_strdup(name); + } + /* XXX Should we also try to sanitize any control characters? */ + return g_strdup_printf("%.80s...", name); +} + /* Send an error reply. * Return -errno on error, 0 on success. */ static int GCC_FMT_ATTR(4, 5) @@ -595,9 +608,11 @@ static int nbd_negotiate_handle_info(NBDClient *client, Error **errp) exp = nbd_export_find(name); if (!exp) { + g_autofree char *sane_name = nbd_sanitize_name(name); + return nbd_negotiate_send_rep_err(client, NBD_REP_ERR_UNKNOWN, errp, "export '%s' not present", - name); + sane_name); } /* Don't bother sending NBD_INFO_NAME unless client requested it */ @@ -995,8 +1010,10 @@ static int nbd_negotiate_meta_queries(NBDClient *client, meta->exp = nbd_export_find(export_name); if (meta->exp == NULL) { + g_autofree char *sane_name = nbd_sanitize_name(export_name); + return nbd_opt_drop(client, NBD_REP_ERR_UNKNOWN, errp, - "export '%s' not present", export_name); + "export '%s' not present", sane_name); } ret = nbd_opt_read(client, &nb_queries, sizeof(nb_queries), errp); diff --git a/tests/qemu-iotests/143 b/tests/qemu-iotests/143 index f649b36195..d2349903b1 100755 --- a/tests/qemu-iotests/143 +++ b/tests/qemu-iotests/143 @@ -58,6 +58,10 @@ _send_qemu_cmd $QEMU_HANDLE \ $QEMU_IO_PROG -f raw -c quit \ "nbd+unix:///no_such_export?socket=$SOCK_DIR/nbd" 2>&1 \ | _filter_qemu_io | _filter_nbd +# Likewise, with longest possible name permitted in NBD protocol +$QEMU_IO_PROG -f raw -c quit \ + "nbd+unix:///$(printf %4096d 1 | tr ' ' a)?socket=$SOCK_DIR/nbd" 2>&1 \ + | _filter_qemu_io | _filter_nbd | sed 's/aaaa*aa/aa--aa/' _send_qemu_cmd $QEMU_HANDLE \ "{ 'execute': 'quit' }" \ diff --git a/tests/qemu-iotests/143.out b/tests/qemu-iotests/143.out index 1f4001c601..fc9c0a761f 100644 --- a/tests/qemu-iotests/143.out +++ b/tests/qemu-iotests/143.out @@ -5,6 +5,8 @@ QA output created by 143 {"return": {}} qemu-io: can't open device nbd+unix:///no_such_export?socket=SOCK_DIR/nbd: Requested export not available server reported: export 'no_such_export' not present +qemu-io: can't open device nbd+unix:///aa--aa1?socket=SOCK_DIR/nbd: Requested export not available +server reported: export 'aa--aa...' not present { 'execute': 'quit' } {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} From patchwork Tue Jun 16 14:15:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 280323 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 53999C433E0 for ; Tue, 16 Jun 2020 15:00:15 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 26A6D20644 for ; Tue, 16 Jun 2020 15:00:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YfwjlYVY" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 26A6D20644 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:33162 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlD4Q-0004xd-Ab for qemu-devel@archiver.kernel.org; Tue, 16 Jun 2020 11:00:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58448) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlCRH-0004rC-C2; Tue, 16 Jun 2020 10:19:47 -0400 Received: from mail-ot1-x335.google.com ([2607:f8b0:4864:20::335]:45652) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jlCRF-000747-PB; Tue, 16 Jun 2020 10:19:46 -0400 Received: by mail-ot1-x335.google.com with SMTP id m2so16025702otr.12; Tue, 16 Jun 2020 07:19: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=dMB5MwLjGYUQmCwqpEn0/VvW/KiFIQ/TwNzYbII5zMw=; b=YfwjlYVYuCCddrGwULgmqRJnMgsrSMER3nFxJ76dM3M5aVhg7JmfxqBuIhqctDH0ry 5MCq2eRcPkN4iGJGPfi4kUSJPQqlavKhgW+QGTlQI0+bWb0wXpyn6V3JFDtu8jGPOUba 7e6mpx4cZmWjCnIU6vPqJPNjH8lGplz7O42+p2/UvK0C+XH0W788Pp5v1P47om2c5AZW ZmJc+SFrJ+fFaI2ncHO4+ooC1DnsdCVm0KTTooQFKXNPfyfraK41Neq6xjWPSNkhbjXF sj/Mw7JubY6PLboERVTTPzGjsVYSko5ue9ciIsfLR7Tpcjo4BFggKHwFG24HgNF2P+ml XbPg== 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=dMB5MwLjGYUQmCwqpEn0/VvW/KiFIQ/TwNzYbII5zMw=; b=I7qqPMvgokfU/rbjnJtb0YSRlhh/s+SGzbtJPXIW4T6Il3Cp1OQQcFOZr7b3YumF/q askXeTqfWZBPET2dQ1Gaz4n/ObQa3w/dVYmg49tgk0/c+8Bk7pCj1XRh+AAOmIhLP+A+ DmywoiNPgt+5A3T7Rgx1Rqnor5vQc9f+IRCWch9whOq4MBGg8GzZXNmVQMOnexcHkBvV R3lY+ZrrECphmkujLgELmxKrmXqJGHax2bgQpXM0QifsRwQ50Bs5wK0UUYUkmQdIfjD8 vpTNec6+wczA5yt769DEMuk9wb/YpEocYNY4quO+3IKy9OgrTM48LGRMQD2xGn9o+UMW binw== X-Gm-Message-State: AOAM530jBWl0FLyOhzi9hXGWatn33YThPKNWo+0i34GygvIjfpCOYp9y G8CnQSduhuekAN6BpODmFoprUNBhIMA= X-Google-Smtp-Source: ABdhPJzQtMYSb4xZ6tXVSUTBJmy3URMZch/tD66cioMMEQWMeocRL5dEeYhJx5MrMTEfNJ2jKYKaCQ== X-Received: by 2002:a9d:5c04:: with SMTP id o4mr2482249otk.21.1592317184076; Tue, 16 Jun 2020 07:19:44 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id y125sm3033947oiy.9.2020.06.16.07.19.43 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Jun 2020 07:19:43 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Subject: [PATCH 77/78] virtio-balloon: unref the iothread when unrealizing Date: Tue, 16 Jun 2020 09:15:46 -0500 Message-Id: <20200616141547.24664-78-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> References: <20200616141547.24664-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::335; envelope-from=flukshun@gmail.com; helo=mail-ot1-x335.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Michael S . Tsirkin" , David Hildenbrand , qemu-stable@nongnu.org, Alexander Duyck , Wei Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: David Hildenbrand We took a reference when realizing, so let's drop that reference when unrealizing. Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Alexander Duyck Fixes: c13c4153f76d ("virtio-balloon: VIRTIO_BALLOON_F_FREE_PAGE_HINT") Cc: qemu-stable@nongnu.org Cc: Wei Wang Cc: Alexander Duyck Cc: Michael S. Tsirkin Cc: Philippe Mathieu-Daudé Signed-off-by: David Hildenbrand Message-Id: <20200520100439.19872-4-david@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin (cherry picked from commit 105aef9c9479786d27c1c45c9b0b1fa03dc46be3) 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 64fdd0e332..9762a65600 100644 --- a/hw/virtio/virtio-balloon.c +++ b/hw/virtio/virtio-balloon.c @@ -820,6 +820,7 @@ static void virtio_balloon_device_unrealize(DeviceState *dev, Error **errp) if (s->free_page_bh) { qemu_bh_delete(s->free_page_bh); + object_unref(OBJECT(s->iothread)); virtio_balloon_free_page_stop(s); precopy_remove_notifier(&s->free_page_report_notify); }