From nobody Sat May 11 07:32:29 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1594665210; cv=none; d=zohomail.com; s=zohoarc; b=hLqcOzGuF8a9Di4lVfrOcqjVZiSoFoo5bpGveL9THqmKndyMVKjBMyDuigE1mrT8kx4tDWQi98/QdC3rJgoBJFBYQ7LrCq+YjtGYn4JBevbRJSCiK+Xx0wjcOrJTkuiLYyrIGSa/F+LSfuekUQHtJZsTnSvRR9YtlCuGGplU2Jg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594665210; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=CfEDbVfF7kj/yGhqKmfevoqL1P6U47hn56zU8XjW1QI=; b=QnCphbG/ZapxARUyH+fKif6tWBOcATp7dj6F0sF7K/+pMNfa+rM0Slme9vKdVzqqcdN7V9LSqdveB9KFrdf/VdPlaNDPpmUxV2yf220TIHDy/dIRo6YCuyrKqQTPNmmqUNTT6IraFrQCa6h1T4/ekJ/t+TRxqrNxgAuUZtLa/Lk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1594665210563625.2203151806345; Mon, 13 Jul 2020 11:33:30 -0700 (PDT) Received: from localhost ([::1]:46726 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jv3Gb-0003ey-CY for importer@patchew.org; Mon, 13 Jul 2020 14:33:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40196) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jv3FQ-0001wQ-MX; Mon, 13 Jul 2020 14:32:16 -0400 Received: from mail-ed1-x543.google.com ([2a00:1450:4864:20::543]:42266) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jv3FP-0004FB-5f; Mon, 13 Jul 2020 14:32:16 -0400 Received: by mail-ed1-x543.google.com with SMTP id z17so14578049edr.9; Mon, 13 Jul 2020 11:32:14 -0700 (PDT) Received: from x1w.redhat.com (138.red-83-57-170.dynamicip.rima-tde.net. [83.57.170.138]) by smtp.gmail.com with ESMTPSA id ce12sm4353148edb.4.2020.07.13.11.32.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2020 11:32:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CfEDbVfF7kj/yGhqKmfevoqL1P6U47hn56zU8XjW1QI=; b=dXM10/4nPGnWiypzrPjXOAc3vegBlO2sa76aTCpJnpxtMQvbMLOcqkuI7x27jrvg+A yGdXfib+one6Ipu/i47ziQg9iEhKSvGYeKfh1A0IE3B5zTFOksh6htFf+1qWTXhCGemU B4uo5diiwVUEJtEybKCyIhh9dYZe+n5FLaZ+vPIThjHJ+Qxjah2mCQ31woDOtQrOCGnT NCu0/Whlu+Y2BzmbRflF41tkZg4ubWO1qDDjj40L55BICXefcMXsQWUpVlhJ0pzqodsN E4JVXDhSx2qA2eeAL7kp/wRlvCYmzkhiq3GmuU/e0XxYRABfXwq6v3W1PFzO+tkZPVEO lfQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=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=CfEDbVfF7kj/yGhqKmfevoqL1P6U47hn56zU8XjW1QI=; b=V4loOVhtqQ+NOXcI9lW0VRuhOXlPw8pTzyRga7bht5DKMydtD/sOH7Ny8SE5PxfPGI RBHUOrgYAT4TAUr7yqtuAo744eFeCo5lurBYggUs/CyFkRc+OohnHnGt2BhJS+a51UwB MZcjJEmhrcvckAED++OzqUKjtcC5Xcr5Zn8XFk79pXTaC4YXbCzTvkCOquac2KbvO5Pm SfVWQH2gThMYfTgUqIoxAcM4YjnLtJspfGZac2LGCoyM7NVZhWL5LoEGvWmMvZ/qhm8/ 6Fg5k82Xy+5qJmJLzM5+VWPUTwOCpA/uHZw0Ueiu9vOYBD4hPJBvW7bg8iuLwRw736Pm dBdg== X-Gm-Message-State: AOAM531wjLxFBg3D7Sp8UUPcY2HDgaXIDUNavu3t/srn8Lpb4scnzFVA ekJshplek4oPZa9l+jClwxP/D7Qctts= X-Google-Smtp-Source: ABdhPJwSfMDH2o9uAjFduzeSbJ6NmFtBBP7BNEucfDswEp4P/0ad0zv5VDuhFVMp2QWCQ+ajEBUdRQ== X-Received: by 2002:a05:6402:947:: with SMTP id h7mr692719edz.213.1594665132944; Mon, 13 Jul 2020 11:32:12 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 1/9] MAINTAINERS: Cc qemu-block mailing list Date: Mon, 13 Jul 2020 20:32:01 +0200 Message-Id: <20200713183209.26308-2-f4bug@amsat.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200713183209.26308-1-f4bug@amsat.org> References: <20200713183209.26308-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::543; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ed1-x543.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=no autolearn_force=no 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 , Prasad J Pandit , qemu-block@nongnu.org, Alistair Francis , Wainer dos Santos Moschetta , Alexander Bulekov , Niek Linnenbank , Cleber Rosa , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Philippe Mathieu-Daud=C3=A9 We forgot to include the qemu-block mailing list while adding this section in commit 076a0fc32a7. Fix this. Suggested-by: Paolo Bonzini Reviewed-by: Peter Maydell Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20200630133912.9428-2-f4bug@amsat.org> --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index fe8139f367..d9c71d0bb3 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1674,6 +1674,7 @@ F: hw/ssi/xilinx_* =20 SD (Secure Card) M: Philippe Mathieu-Daud=C3=A9 +L: qemu-block@nongnu.org S: Odd Fixes F: include/hw/sd/sd* F: hw/sd/core.c --=20 2.21.3 From nobody Sat May 11 07:32:29 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=amsat.org ARC-Seal: i=1; a=rsa-sha256; t=1594665211; cv=none; d=zohomail.com; s=zohoarc; b=H5X6FZljxd0BWCT7rlS7T4gUS2NIlvv2KnbE5DoCwHKSwWSwaYgSJVoWGIOMR8RuHocC9Qos1JGa2chwrHc2riiU7X8RDtJa9makaZhxmOC9yw64ur6qq8+qguxKks686sdRgO3uxx+7Axg/F+Bzc0b/rij+FGGYf3LZg4F/O4M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594665211; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=uyp96aoYkkNgfFwZ8UhO6hrlMhJXRb1SNh8r9bSD384=; b=AWnbp9WAl/qATLeA5IxCueXkdejXbRPjhXXhteIbxXICxiKx24TnpvVruNZ+0JVt7JRHhlY5H0McRU1PpnQhyDAM1CON3GrDR3rAAdcR+Augh7UlrUjoh7NReRyjtB/tJa3VMlUakOivGOzrhGjXGrJoSZKW04vs7I1axgtL3Hs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1594665211403989.1042884549337; Mon, 13 Jul 2020 11:33:31 -0700 (PDT) Received: from localhost ([::1]:46770 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jv3Gc-0003fz-5I for importer@patchew.org; Mon, 13 Jul 2020 14:33:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40236) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jv3FS-0001wx-0K; Mon, 13 Jul 2020 14:32:18 -0400 Received: from mail-ed1-x543.google.com ([2a00:1450:4864:20::543]:39949) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jv3FQ-0004FX-74; Mon, 13 Jul 2020 14:32:17 -0400 Received: by mail-ed1-x543.google.com with SMTP id b15so14574637edy.7; Mon, 13 Jul 2020 11:32:15 -0700 (PDT) Received: from x1w.redhat.com (138.red-83-57-170.dynamicip.rima-tde.net. [83.57.170.138]) by smtp.gmail.com with ESMTPSA id ce12sm4353148edb.4.2020.07.13.11.32.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2020 11:32: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=uyp96aoYkkNgfFwZ8UhO6hrlMhJXRb1SNh8r9bSD384=; b=oGNSLeFYoy0wqXyj6T1ho54TK4QAUEASzjT1eBk64HZhgkvf3HYMfQS1A+bmxVdFb2 26ttJPWIu5pN2JQMju3b9Iagm44CSd45huqXmLTckZy3eALson1eYmaa8Ndh5KbXk3W4 O58cPCVO+Af6O7FPsTVXzX4G5OTzCECZ9VsGzKlFywmFoQu44yGgFnLLa41prkduULTx 4hLcUnp+uUQMRdHSiatQX/8BFwzfCIG7+umYDVchpiqF7N+/H5JNqEc6LD0nFYXdKy0e 9Q0lMYToSxRJDufkXY/eoajbSVZwTGNjrd4zgitf+3GSRxQtYbg/s4GwHz/F7d+NoKr+ rX2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=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=uyp96aoYkkNgfFwZ8UhO6hrlMhJXRb1SNh8r9bSD384=; b=g2KAE6pLVmqnUGBGmdsYPQ1rhfRiI44Qopthujt7Tnwb9UdRL8ZSsasweYuHopLm59 f2jFT7bYlNIqrMCFz7WmfD1NYk06M6obYlf3bv+D3QFgvZKBwTrKZjQ6+G1Yp6q7TODJ amuylfK4ZWw6QTf9oYHRFHPeM0DgqUNvCtQP8mzFLpR+55kgN8gGNFqFCnQEdoIoWJsL QQnB9JU2Hlu2bkRSxANPDH/wvoVbTtJQ0fLR6RewbSa70Ic0c9euCcuPM9/KNU4fBqtH levJbk6530ipIzzXbwrfc7a6ZD+qvoTN3i/EAlRRAeMeWdkzsNbyolq7kcO+6pUBdz6w pD2A== X-Gm-Message-State: AOAM5335FRltlL14qDAvmJhMyGJK8im2Ge4J2iJZVXJEyK0vUkd58M7V FpuB36WIeV9pA8cS3A/HL5ZbyZxXqF8= X-Google-Smtp-Source: ABdhPJxkG8aBXH5nMHTp8bVR/0bi+rXLij8SDEfXvTpkanubvbT5pHQtYuVRgqe77E20/ZfyyV4Suw== X-Received: by 2002:aa7:c54e:: with SMTP id s14mr715323edr.81.1594665134253; Mon, 13 Jul 2020 11:32:14 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 2/9] docs/orangepi: Add instructions for resizing SD image to power of two Date: Mon, 13 Jul 2020 20:32:02 +0200 Message-Id: <20200713183209.26308-3-f4bug@amsat.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200713183209.26308-1-f4bug@amsat.org> References: <20200713183209.26308-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::543; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ed1-x543.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=no autolearn_force=no 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 , Prasad J Pandit , qemu-block@nongnu.org, Alistair Francis , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Wainer dos Santos Moschetta , Alexander Bulekov , Niek Linnenbank , Cleber Rosa , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Niek Linnenbank SD cards need to have a size of a power of two. Update the Orange Pi machine documentation to include instructions for resizing downloaded images using the qemu-img command. Signed-off-by: Niek Linnenbank Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20200712183708.15450-1-nieklinnenbank@gmail.com> Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alistair Francis --- docs/system/arm/orangepi.rst | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/docs/system/arm/orangepi.rst b/docs/system/arm/orangepi.rst index c41adad488..6f23907fb6 100644 --- a/docs/system/arm/orangepi.rst +++ b/docs/system/arm/orangepi.rst @@ -127,6 +127,16 @@ can be downloaded from: Alternatively, you can also choose to build you own image with buildroot using the orangepi_pc_defconfig. Also see https://buildroot.org for more i= nformation. =20 +When using an image as an SD card, it must be resized to a power of two. T= his can be +done with the qemu-img command. It is recommended to only increase the ima= ge size +instead of shrinking it to a power of two, to avoid loss of data. For exam= ple, +to prepare a downloaded Armbian image, first extract it and then increase +its size to one gigabyte as follows: + +.. code-block:: bash + + $ qemu-img resize Armbian_19.11.3_Orangepipc_bionic_current_5.3.9.img 1G + You can choose to attach the selected image either as an SD card or as USB= mass storage. For example, to boot using the Orange Pi PC Debian image on SD card, simpl= y add the -sd argument and provide the proper root=3D kernel parameter: @@ -213,12 +223,12 @@ Next, unzip the NetBSD image and write the U-Boot bin= ary including SPL using: $ dd if=3D/path/to/u-boot-sunxi-with-spl.bin of=3Darmv7.img bs=3D1024 se= ek=3D8 conv=3Dnotrunc =20 Finally, before starting the machine the SD image must be extended such -that the NetBSD kernel will not conclude the NetBSD partition is larger th= an -the emulated SD card: +that the size of the SD image is a power of two and that the NetBSD kernel +will not conclude the NetBSD partition is larger than the emulated SD card: =20 .. code-block:: bash =20 - $ dd if=3D/dev/zero bs=3D1M count=3D64 >> armv7.img + $ qemu-img resize armv7.img 2G =20 Start the machine using the following command: =20 --=20 2.21.3 From nobody Sat May 11 07:32:29 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1594665312; cv=none; d=zohomail.com; s=zohoarc; b=KygD0VYTVlerMBLa380px32M0Fp90EllPQThchL7kY9R3AaU+P3bacVMsIkYCELC1Jy/nZlj1B76ReKPM1BA8w/ZF9slinJZ7Td4SlJDUKp7arNb5cgPDwPB5l7LkLPoUzkLEVxpnlst/0jv6dOOw2BmO0OUntNrNYOQZW8+FFM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594665312; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=JAR9oox63Wn3FnDmGAuJvp7q5cpJDHy+VCBHheQotfo=; b=i/oITx6jV9aC9DZ8VkepCx5XXIHCtXUOe+HF4mmBLK78lBCyNE4JWA/vp4WXJFP2FxS+PgXSrdstMoS+AdzJJpp+hfOV9Pir/NNTynS2HHSC2/yPIdJUw7c0o7SWIG8ALhstWGwApk7+pOvFaXvt1hDA1RADRX9KAKg9CQwNIBk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1594665312798323.18706925279025; Mon, 13 Jul 2020 11:35:12 -0700 (PDT) Received: from localhost ([::1]:55372 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jv3IF-0007Al-Jr for importer@patchew.org; Mon, 13 Jul 2020 14:35:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40258) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jv3FT-00020M-Hx; Mon, 13 Jul 2020 14:32:19 -0400 Received: from mail-ej1-x643.google.com ([2a00:1450:4864:20::643]:41452) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jv3FR-0004G8-Ck; Mon, 13 Jul 2020 14:32:19 -0400 Received: by mail-ej1-x643.google.com with SMTP id dp18so18410471ejc.8; Mon, 13 Jul 2020 11:32:16 -0700 (PDT) Received: from x1w.redhat.com (138.red-83-57-170.dynamicip.rima-tde.net. [83.57.170.138]) by smtp.gmail.com with ESMTPSA id ce12sm4353148edb.4.2020.07.13.11.32.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2020 11:32:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JAR9oox63Wn3FnDmGAuJvp7q5cpJDHy+VCBHheQotfo=; b=EjMoJMtm7RgLdr5ivo5D66D4hFKpZ4/B+NVZ0vyD+8uTyCp9HSFkbm4swtTzPyxcTP HSRdXAut6yk5UQNmDS8Cc7eKqLfkcQeqGT3cb73GPljQuaWHB1TvqJLRuSKaKNtEQwgM 5gCC+DMrocSyR8WVFD55UxQDmtswXpvZuGutKl6oJMXUElmCM2wcTAFD9TJjaHiwjZ3Q KTpWj2Jiqqwh9fSyJMg6V2PZ5SSOWBjBstUt/8ano8h97ka7LL5S2QQW3xiX7MJ6KJml 8b85SOFfelB/gnZ232Fl+2haaerZtZFvZzdN+tV/CPPw9LvMW73mNKNqAjT5kCDXKojV 8fag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=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=JAR9oox63Wn3FnDmGAuJvp7q5cpJDHy+VCBHheQotfo=; b=swh4156SJ1se916hLHEq2lBohi1WD+9a9bddBShJ54c7kpWx4wtD1oZ1XE19tmjvg+ 2gyPejYlZ1fBti493v/PIbCybtFrIBK5fMwE4+L4ao35+QBw5rS7zZfnxj//Jplrotg2 Qq7bJFGoL0Dr1GMCIRCJZz1wXH61aPMaWNaRwjv8kmvUJwm60WdbTyAFDRTFUACe6iiS 36NJX27K6XKva0N4wilxF+oNcIwD7fUVyeDR9xoQoXZMq0+sZ41EnVud9Ao8BQ7rF4UD MIZoDSyhwinEx2xkDx5HRySFwBbF60rCQLFZFyKY+Wnv8MWzjjTJNQTIjkn4uvn8S6eK LCiw== X-Gm-Message-State: AOAM531IAZIL1XkyNlfiNubFr9ntW4ydT7245aAi3WGOGwGReOokmmMh Rbt2Hn6F+RhoK6/e7nHSxuNe0P1XmZM= X-Google-Smtp-Source: ABdhPJyFLkbgvGN8bwS7sD20H/6L7iExHZScKHX4jAParnUbHNSk7nvm627mWuW07ZNJYBLZc3Ye2w== X-Received: by 2002:a17:907:1051:: with SMTP id oy17mr1051861ejb.394.1594665135563; Mon, 13 Jul 2020 11:32:15 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 3/9] tests/acceptance/boot_linux: Tag tests using a SD card with 'device:sd' Date: Mon, 13 Jul 2020 20:32:03 +0200 Message-Id: <20200713183209.26308-4-f4bug@amsat.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200713183209.26308-1-f4bug@amsat.org> References: <20200713183209.26308-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::643; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ej1-x643.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=no autolearn_force=no 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 , Prasad J Pandit , qemu-block@nongnu.org, Alistair Francis , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Wainer dos Santos Moschetta , Alexander Bulekov , Niek Linnenbank , Cleber Rosa , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Avocado tags are handy to automatically select tests matching the tags. Since these tests use a SD card, tag them. We can run all the tests using a SD card at once with: $ avocado --show=3Dapp run -t u-boot tests/acceptance/ $ AVOCADO_ALLOW_LARGE_STORAGE=3Dok \ avocado --show=3Dapp \ run -t device:sd tests/acceptance/ Fetching asset from tests/acceptance/boot_linux_console.py:BootLinuxConso= le.test_arm_orangepi_sd Fetching asset from tests/acceptance/boot_linux_console.py:BootLinuxConso= le.test_arm_orangepi_bionic Fetching asset from tests/acceptance/boot_linux_console.py:BootLinuxConso= le.test_arm_orangepi_uboot_netbsd9 (1/3) tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_arm_o= rangepi_sd: PASS (19.56 s) (2/3) tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_arm_o= rangepi_bionic: PASS (49.97 s) (3/3) tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_arm_o= rangepi_uboot_netbsd9: PASS (20.06 s) RESULTS : PASS 3 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | = CANCEL 0 JOB TIME : 90.02 s Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alistair Francis Reviewed-by: Cleber Rosa Tested-by: Cleber Rosa --- tests/acceptance/boot_linux_console.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot= _linux_console.py index 3d02519660..b7e8858c2d 100644 --- a/tests/acceptance/boot_linux_console.py +++ b/tests/acceptance/boot_linux_console.py @@ -620,6 +620,7 @@ def test_arm_orangepi_sd(self): """ :avocado: tags=3Darch:arm :avocado: tags=3Dmachine:orangepi-pc + :avocado: tags=3Ddevice:sd """ deb_url =3D ('https://apt.armbian.com/pool/main/l/' 'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.de= b') @@ -669,6 +670,7 @@ def test_arm_orangepi_bionic(self): """ :avocado: tags=3Darch:arm :avocado: tags=3Dmachine:orangepi-pc + :avocado: tags=3Ddevice:sd """ =20 # This test download a 196MB compressed image and expand it to 932= MB... @@ -710,6 +712,7 @@ def test_arm_orangepi_uboot_netbsd9(self): """ :avocado: tags=3Darch:arm :avocado: tags=3Dmachine:orangepi-pc + :avocado: tags=3Ddevice:sd """ # This test download a 304MB compressed image and expand it to 1.3= GB... deb_url =3D ('http://snapshot.debian.org/archive/debian/' --=20 2.21.3 From nobody Sat May 11 07:32:29 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1594665318; cv=none; d=zohomail.com; s=zohoarc; b=QYW9mNMnaO5LekKYe5lpsa4KHeVRQxF7eLPj39l/urIYX/kWYd/JZ+D3Y37S5abwaJg0IhGBtRFfsQOPNYy6ltn6o1EAL4/lW9v+M140uKhhqkRxqSW9q6wHw30O90wLu55fdJIgpV1AbBYyJGEnv4Lm36AZaNLlLXKIQa4e9Rc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594665318; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=nhs5ynfW5eDBEuVG49jlv4iF3aFNW3dwv+4Ev+duU34=; b=KpYYA+aUDHxi+t/PMtf4vw4qz+AVNWPsvVSL3Jfp/reUsbiQjKUYgkSSQipMfWU+p6WO5FFCbCLADEO3BeTa6NlR91AsfpJoyE8+3TbUyD9Hz5Nd3MWN+I8Z6VzcRih5oXgJDJHppdfETVuxxBoiuGAPqmTDJ/I6gNKidN4QOeg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1594665318491167.81142984732605; Mon, 13 Jul 2020 11:35:18 -0700 (PDT) Received: from localhost ([::1]:55926 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jv3IL-0007OH-5A for importer@patchew.org; Mon, 13 Jul 2020 14:35:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40280) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jv3FU-00023Z-SE; Mon, 13 Jul 2020 14:32:20 -0400 Received: from mail-ej1-x62e.google.com ([2a00:1450:4864:20::62e]:40918) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jv3FT-0004Gb-0Y; Mon, 13 Jul 2020 14:32:20 -0400 Received: by mail-ej1-x62e.google.com with SMTP id o18so18423579eje.7; Mon, 13 Jul 2020 11:32:18 -0700 (PDT) Received: from x1w.redhat.com (138.red-83-57-170.dynamicip.rima-tde.net. [83.57.170.138]) by smtp.gmail.com with ESMTPSA id ce12sm4353148edb.4.2020.07.13.11.32.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2020 11:32:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nhs5ynfW5eDBEuVG49jlv4iF3aFNW3dwv+4Ev+duU34=; b=WUE4NAkmAlOifZiMBxX5My0GMHicjoD8ZRZ8sqc+PRKD/069odhAiCx+ay2wA/ft+J rA2OgepZapgR9blqpIwT3UP2M0AbEJzkpKvFgtzvUI1dIh5DwrS3ewvKFGlA/5UciIpv 5OA+CQqEp05Y2tF7B2HttpzdtwZB4ecxv0QRoiGubkLiRuWWXOOOm+vsph6Y1uOMizez 0MJrcoBBOcQ/+48NXuQzt4Mm482f1OuJ2SNjZtcyPfS0ZWyd4cYa/BYZaNAQsX9wJtlR 1TmDyZgESg4pc3rwoS8sbcCi9IZOX5ci8w68/G+AXMgomkhVcbO73rExLWpPJso3+ZYj IOxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=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=nhs5ynfW5eDBEuVG49jlv4iF3aFNW3dwv+4Ev+duU34=; b=oA+mfF+dS2s9ZpoPGIMNO8MFfKemopi6u174j/iuV3bpwTuN2JVesn05rAgQcNnITs WHJxEjnmneWlhL+l2RSijfN+pXkCaumX/f8mte06ljHy5LvcTjDFc+Y5H7d0HEv90rMY CzfxtKnoaO9NXY5TfwV8zO+Qf0ocpeYbAUvadpTK9X5FfKiLEmp2pWVPL5V5MA04Cks9 AtM7ZklhIDmxd2/21B+iEFfs7FtOOeZaw1JEFVUquMjZA/i/MRJ130XiikKjZZioypXg KkYECFhlhFTlVNKtq1du5lTzt6qe4sa/TlnqSL6niVgiVex5U4jVquPU192VtOhxErFn EZ0w== X-Gm-Message-State: AOAM533lXU1wL/VVc4/6oHkGNE74WQJBhNqZ34eUv1w0MYs/gLLzD4IL kJBrwpWMAx/on1IBoD/I6Y98AxTl3Xs= X-Google-Smtp-Source: ABdhPJxydMgwoAoprxteI6j0mm8uut16kwy5azGZOq1xng4INmyxdQxNqE4GT2cJ/lbgxmpc+RpbmQ== X-Received: by 2002:a17:906:c56:: with SMTP id t22mr1090312ejf.50.1594665137027; Mon, 13 Jul 2020 11:32:17 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 4/9] tests/acceptance/boot_linux: Expand SD card image to power of 2 Date: Mon, 13 Jul 2020 20:32:04 +0200 Message-Id: <20200713183209.26308-5-f4bug@amsat.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200713183209.26308-1-f4bug@amsat.org> References: <20200713183209.26308-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::62e; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ej1-x62e.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=no autolearn_force=no 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 , Prasad J Pandit , qemu-block@nongnu.org, Alistair Francis , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Wainer dos Santos Moschetta , Alexander Bulekov , Niek Linnenbank , Cleber Rosa , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) In few commits we won't allow SD card images with invalid size (not aligned to a power of 2). Prepare the tests: add the pow2ceil() and image_pow2ceil_expand() methods and resize the images (expanding) of the tests using SD cards. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alistair Francis Reviewed-by: Cleber Rosa --- Since v1: Addressed review comments - truncate -> expand reword (Alistair Francis) - expand after uncompress (Niek Linnenbank) --- tests/acceptance/boot_linux_console.py | 27 +++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot= _linux_console.py index b7e8858c2d..8f2a6aa8a4 100644 --- a/tests/acceptance/boot_linux_console.py +++ b/tests/acceptance/boot_linux_console.py @@ -28,6 +28,18 @@ except CmdNotFoundError: P7ZIP_AVAILABLE =3D False =20 +# round up to next power of 2 +def pow2ceil(x): + return 1 if x =3D=3D 0 else 2**(x - 1).bit_length() + +# expand file size to next power of 2 +def image_pow2ceil_expand(path): + size =3D os.path.getsize(path) + size_aligned =3D pow2ceil(size) + if size !=3D size_aligned: + with open(path, 'ab+') as fd: + fd.truncate(size_aligned) + class LinuxKernelTest(Test): KERNEL_COMMON_COMMAND_LINE =3D 'printk.time=3D0 ' =20 @@ -636,6 +648,7 @@ def test_arm_orangepi_sd(self): rootfs_path_xz =3D self.fetch_asset(rootfs_url, asset_hash=3Drootf= s_hash) rootfs_path =3D os.path.join(self.workdir, 'rootfs.cpio') archive.lzma_uncompress(rootfs_path_xz, rootfs_path) + image_pow2ceil_expand(rootfs_path) =20 self.vm.set_console() kernel_command_line =3D (self.KERNEL_COMMON_COMMAND_LINE + @@ -673,7 +686,7 @@ def test_arm_orangepi_bionic(self): :avocado: tags=3Ddevice:sd """ =20 - # This test download a 196MB compressed image and expand it to 932= MB... + # This test download a 196MB compressed image and expand it to 1GB image_url =3D ('https://dl.armbian.com/orangepipc/archive/' 'Armbian_19.11.3_Orangepipc_bionic_current_5.3.9.7z') image_hash =3D '196a8ffb72b0123d92cea4a070894813d305c71e' @@ -681,6 +694,7 @@ def test_arm_orangepi_bionic(self): image_name =3D 'Armbian_19.11.3_Orangepipc_bionic_current_5.3.9.im= g' image_path =3D os.path.join(self.workdir, image_name) process.run("7z e -o%s %s" % (self.workdir, image_path_7z)) + image_pow2ceil_expand(image_path) =20 self.vm.set_console() self.vm.add_args('-drive', 'file=3D' + image_path + ',if=3Dsd,form= at=3Draw', @@ -714,7 +728,7 @@ def test_arm_orangepi_uboot_netbsd9(self): :avocado: tags=3Dmachine:orangepi-pc :avocado: tags=3Ddevice:sd """ - # This test download a 304MB compressed image and expand it to 1.3= GB... + # This test download a 304MB compressed image and expand it to 2GB deb_url =3D ('http://snapshot.debian.org/archive/debian/' '20200108T145233Z/pool/main/u/u-boot/' 'u-boot-sunxi_2020.01%2Bdfsg-1_armhf.deb') @@ -731,8 +745,9 @@ def test_arm_orangepi_uboot_netbsd9(self): image_hash =3D '2babb29d36d8360adcb39c09e31060945259917a' image_path_gz =3D self.fetch_asset(image_url, asset_hash=3Dimage_h= ash) image_path =3D os.path.join(self.workdir, 'armv7.img') - image_drive_args =3D 'if=3Dsd,format=3Draw,snapshot=3Don,file=3D' = + image_path archive.gzip_uncompress(image_path_gz, image_path) + image_pow2ceil_expand(image_path) + image_drive_args =3D 'if=3Dsd,format=3Draw,snapshot=3Don,file=3D' = + image_path =20 # dd if=3Du-boot-sunxi-with-spl.bin of=3Darmv7.img bs=3D1K seek=3D= 8 conv=3Dnotrunc with open(uboot_path, 'rb') as f_in: @@ -740,12 +755,6 @@ def test_arm_orangepi_uboot_netbsd9(self): f_out.seek(8 * 1024) shutil.copyfileobj(f_in, f_out) =20 - # Extend image, to avoid that NetBSD thinks the partition - # inside the image is larger than device size itself - f_out.seek(0, 2) - f_out.seek(64 * 1024 * 1024, 1) - f_out.write(bytearray([0x00])) - self.vm.set_console() self.vm.add_args('-nic', 'user', '-drive', image_drive_args, --=20 2.21.3 From nobody Sat May 11 07:32:29 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1594665337; cv=none; d=zohomail.com; s=zohoarc; b=JiEHYQvuggNFkjyN/w7KDqg6KfIYIEhAl8sHkfLHasMKEbP421yFgBd4hvroyFthmFYq7tU+SnRaT7VKnZk1ARg57/a6YnLxSR0TMAEU/KWN4ZBfvwVxLovby2KxdjniORbhCIYU0ghoZL0cEt5bP0LVUNx1lvZVNZUpqdbv8y4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594665337; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=SN1q0PMCO1/b3G/yTwrOsu/XAVNUpaToYvO1YyH52/o=; b=fR/dzL8CNDLqhv6uxIdskmgVPjgRQnaRCUOPL2XdwPsvQ7zcT81wF5PvrBfCDfTP6AeYOHcn0jU8BlNIn5o0QuY0oIZGFZJT00pS3vL1ceOaISUH7zVYO1bNZjOapqlH7pInJJ3yH6mN4Kpy2xu13awt7KZ8oBLoeRGITZBTCUo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1594665337560835.428352297841; Mon, 13 Jul 2020 11:35:37 -0700 (PDT) Received: from localhost ([::1]:56612 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jv3Ie-0007eu-By for importer@patchew.org; Mon, 13 Jul 2020 14:35:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40316) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jv3FW-00027p-Mj; Mon, 13 Jul 2020 14:32:22 -0400 Received: from mail-ej1-x644.google.com ([2a00:1450:4864:20::644]:40261) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jv3FU-0004HB-Fe; Mon, 13 Jul 2020 14:32:22 -0400 Received: by mail-ej1-x644.google.com with SMTP id o18so18423687eje.7; Mon, 13 Jul 2020 11:32:19 -0700 (PDT) Received: from x1w.redhat.com (138.red-83-57-170.dynamicip.rima-tde.net. [83.57.170.138]) by smtp.gmail.com with ESMTPSA id ce12sm4353148edb.4.2020.07.13.11.32.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2020 11:32:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SN1q0PMCO1/b3G/yTwrOsu/XAVNUpaToYvO1YyH52/o=; b=Xejc1Pr7KYGOXiEWoif+Zso7A5D77D4/ExAVGk/jqOVZLeV2GpdLynJZm6yiObHN3f pqRCwJuZhrXleP2cIV6GxR9y1zYWYD9zoafaZd6/ejWLZZm+XbuN3KuP/UOnqWvPIyHL aAcdjKDM2rZQmdhzSxEZ+J63K/+giTaPZc+V8NY3Vb3X4+MgIq1Lvh3vl48xBfgcC1EG 7jWICq8f61zeQ9BW0nm27rb1eELx2ZGIox3SwoHLINtO/naiLIU1bdRlFWzcandkxjCy FJOAkEWV57KUdg3YUW4XWeHgLBKG3J6/5raPhQq9tR62xmCy+AeCua0wumZLMho/Jq6+ fI9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=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=SN1q0PMCO1/b3G/yTwrOsu/XAVNUpaToYvO1YyH52/o=; b=Mc02/CZcHyDbxGYQESA+KT0m8kA+jBkh7bWQ9cv2hfc9EQ+7Tb94qVZ6X9ZrdcdgZE EQG3dQ73JXXCnVYckT1VQ7wzzR51qigW2+Im5bb8CGhZ8p8XoIKhNfbRRGfyhZ0/whUe GfzWwiFTdxNJshHS3WFIulDrUPPDkqIxn53E6QoD/9BOtL+QGmN7kuyKHbdFWnPyi2lp T47XYd2jqXFrm50Q81xOo9JhPMiSI97Pwnl/rufOQm6gLwWwCY8x7KwjC2wQY+z5ix2h 7WkAD/BludPy/nvWiZ6nryZVKQIjNPdEl6/15MBJNWb82emfiyOwzCUO7SGYBwPAE+WA lRqw== X-Gm-Message-State: AOAM533PWeR0CEhuFMqoPyAgZMppzuIBBSotyskLKTVPw36+EVlgzTxt tNFWQiVaSLbUg68MI0EqR4b8ZC2qWK8= X-Google-Smtp-Source: ABdhPJxE6OxkdisEP4bvRpUfZ85Uto0+Rvw9utbKVHtqJtVJCKMPmwjBbgusrC3TFD2InzFEpAy5zA== X-Received: by 2002:a17:906:191a:: with SMTP id a26mr1006282eje.315.1594665138603; Mon, 13 Jul 2020 11:32:18 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 5/9] hw/sd/sdcard: Restrict Class 6 commands to SCSD cards Date: Mon, 13 Jul 2020 20:32:05 +0200 Message-Id: <20200713183209.26308-6-f4bug@amsat.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200713183209.26308-1-f4bug@amsat.org> References: <20200713183209.26308-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::644; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ej1-x644.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=no autolearn_force=no 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 , Prasad J Pandit , qemu-block@nongnu.org, Alistair Francis , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Wainer dos Santos Moschetta , Alexander Bulekov , Niek Linnenbank , Alistair Francis , Cleber Rosa , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Only SCSD cards support Class 6 (Block Oriented Write Protection) commands. "SD Specifications Part 1 Physical Layer Simplified Spec. v3.01" 4.3.14 Command Functional Difference in Card Capacity Types * Write Protected Group SDHC and SDXC do not support write-protected groups. Issuing CMD28, CMD29 and CMD30 generates the ILLEGAL_COMMAND error. Reviewed-by: Peter Maydell Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alistair Francis Message-Id: <20200630133912.9428-7-f4bug@amsat.org> --- hw/sd/sd.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 5137168d66..1cc16bfd31 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -920,6 +920,11 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SD= Request req) sd->multi_blk_cnt =3D 0; } =20 + if (sd_cmd_class[req.cmd] =3D=3D 6 && FIELD_EX32(sd->ocr, OCR, CARD_CA= PACITY)) { + /* Only Standard Capacity cards support class 6 commands */ + return sd_illegal; + } + switch (req.cmd) { /* Basic commands (Class 0 and Class 1) */ case 0: /* CMD0: GO_IDLE_STATE */ --=20 2.21.3 From nobody Sat May 11 07:32:29 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1594665441; cv=none; d=zohomail.com; s=zohoarc; b=hKlHEdmR86B+DE5RDNKMfpzdyOLGuYGrhSwPFSTyGA9sCZ2ZV4fayDen8A2hlppGA4bzJHu62uWWb7Dx9dDgfzNuWWp1KXrQb5QMmGQj/IjVcxVdfiaptIZnkzmCNdCnSpsPVXw4l0gVT2msjq5DV9nNlx7V2KfLC5A/pIVJmNA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594665441; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=NesnoNVp8mV726mwx9/wPWtnd6LQdD+PlLDlGLZ9HWI=; b=Gka9jHisMfiBMsUQ7jB+VdjabM9t/ZzDlDfMyBZi9af6AdGCoi7LUsSr4rt/o6v9Be4Tx3gKLdnmJWKHhCM0kosLVKaWlOo/eYgGzyUFVpetTg8v4MpebDqTn/VvXvDF2ZwZQzsQncM2ZYHyuyboNIEJWEgfGM/6L9APy2eGOzE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1594665441079903.1688465408273; Mon, 13 Jul 2020 11:37:21 -0700 (PDT) Received: from localhost ([::1]:35978 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jv3KJ-0002Y9-Tl for importer@patchew.org; Mon, 13 Jul 2020 14:37:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40340) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jv3FX-0002As-TM; Mon, 13 Jul 2020 14:32:23 -0400 Received: from mail-ej1-x62d.google.com ([2a00:1450:4864:20::62d]:39006) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jv3FW-0004Hm-8U; Mon, 13 Jul 2020 14:32:23 -0400 Received: by mail-ej1-x62d.google.com with SMTP id w6so18425359ejq.6; Mon, 13 Jul 2020 11:32:21 -0700 (PDT) Received: from x1w.redhat.com (138.red-83-57-170.dynamicip.rima-tde.net. [83.57.170.138]) by smtp.gmail.com with ESMTPSA id ce12sm4353148edb.4.2020.07.13.11.32.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2020 11:32: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=NesnoNVp8mV726mwx9/wPWtnd6LQdD+PlLDlGLZ9HWI=; b=rOYJFU2RGFhHMsYarEeYkwV6i2BnjZ4R/9zefMmzON2/jxgmkY9mvXdG3okNQOsxx7 Ow64FiMyWiOqn7YkM6jdMWJrkrUHeIet8gepIlQ1lU4RljejuDwpvqUdQFrcR0Bz9aYq TS0aggWkXDP7HzCLUar9B9WXSmnWICmcDnzNTbfFJY2emOXDW6zQGt6jz7HhQBCEtMuC ULj+It4Lc7Gxm2sXi8YCzUjq7cTH4afUgmdPRkZdlFvdxRBHcava6omoqzxZpmS8xIjM t9ZfQBuDQ+QmO79e3bn5vLsB2bpP7gG0m0LgTMhEkF8hTyFpGJERNbjvsP4hhsZ3s6Gk w0zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=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=NesnoNVp8mV726mwx9/wPWtnd6LQdD+PlLDlGLZ9HWI=; b=p+qDCT5GKLnynl7WRvR8IGBTLQV0EYDmwR76a7gatbVZc//g3+hr6OScivn7xkWiKA 1Wb79EXGkBEZ/ImZwFBsRwnFs28EJTiNThwEMeda+i1HKHxJWXH3tLMPh/3a+Am5a3DZ 5p/9jkBXxgffiKBYmudAGdU6GBGR5tg4E4fcx91Er89ZeGz/aRHVF0AjU5h62gTwh/SZ Tb/4bJb7KEb/DpUV7aKKatXgBi9PCzalYqafdP39cFEDLY3Y+xjOuNfpE7KoP0j2iW/s KfNmXLsAm4m5b+HTn4zYrrBbrtg63k9Cdun4kcv4xky/t38TNCFf3vMhymxWCoH5N/1B 10vA== X-Gm-Message-State: AOAM531WBqdyCtIn5KZDxymXLat3Q11o82w5wxucyKM56rg2DwuIwo28 4ygDcXV/954/nMr7hVNLPg6QEw7KRMI= X-Google-Smtp-Source: ABdhPJwTWTfC0FfKrws8ySY0SAa3FrmHcfKJgKroe1DsIXEwZ1f/NoSNqIBoESPRq4osKsWPNMycOQ== X-Received: by 2002:a17:907:1114:: with SMTP id qu20mr1024365ejb.41.1594665140185; Mon, 13 Jul 2020 11:32:20 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 6/9] hw/sd/sdcard: Simplify realize() a bit Date: Mon, 13 Jul 2020 20:32:06 +0200 Message-Id: <20200713183209.26308-7-f4bug@amsat.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200713183209.26308-1-f4bug@amsat.org> References: <20200713183209.26308-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::62d; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ej1-x62d.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=no autolearn_force=no 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 , Prasad J Pandit , qemu-block@nongnu.org, Alistair Francis , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Wainer dos Santos Moschetta , Alexander Bulekov , Niek Linnenbank , Alistair Francis , Cleber Rosa , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) We don't need to check if sd->blk is set twice. Reviewed-by: Peter Maydell Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alistair Francis Message-Id: <20200630133912.9428-18-f4bug@amsat.org> --- hw/sd/sd.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 1cc16bfd31..edd60a09c0 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -2105,12 +2105,12 @@ static void sd_realize(DeviceState *dev, Error **er= rp) return; } =20 - if (sd->blk && blk_is_read_only(sd->blk)) { - error_setg(errp, "Cannot use read-only drive as SD card"); - return; - } - if (sd->blk) { + if (blk_is_read_only(sd->blk)) { + error_setg(errp, "Cannot use read-only drive as SD card"); + return; + } + ret =3D blk_set_perm(sd->blk, BLK_PERM_CONSISTENT_READ | BLK_PERM_= WRITE, BLK_PERM_ALL, errp); if (ret < 0) { --=20 2.21.3 From nobody Sat May 11 07:32:29 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=amsat.org ARC-Seal: i=1; a=rsa-sha256; t=1594665276; cv=none; d=zohomail.com; s=zohoarc; b=ik2gXZcaeVi2OlaDXtAv2hyrpv5OF8oG4qLSh10h/5UiZ0thsKLNxYiZ2DR7urssUDlneBmUPS9kMixU0HKx1YyutT/i+dTjrJAsbK6tMUz7QgGxaceqWnZjdhk0o0tqnjIbW9hv8gqfXzseYWjY4p7iCT36utQJeiSNbNnJDq0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594665276; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=A45CZTNPoBUm1W95oEJT02xG5DfWi0IK+venM/Qt9bs=; b=CftObGd9WnMRyaBCObEs8TPRhsVKMmITJZ9sL1Y8M7J5nsJYH2kdrhomBh1zr+aGfHnwZJmqaxIfGL4iCyaDNfUgJ9MsxF+4URtTU/dqP8flPHPJni8f4/TJ5xDZXPQ2OzrS42/j5o9yxJdM2kzC8MdtCI7ofNiCQLdoV9isHyw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1594665276801541.5680129286965; Mon, 13 Jul 2020 11:34:36 -0700 (PDT) Received: from localhost ([::1]:51612 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jv3Hf-0005dA-5e for importer@patchew.org; Mon, 13 Jul 2020 14:34:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40370) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jv3FZ-0002Fx-GA; Mon, 13 Jul 2020 14:32:25 -0400 Received: from mail-ej1-x629.google.com ([2a00:1450:4864:20::629]:41885) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jv3FX-0004IV-P0; Mon, 13 Jul 2020 14:32:25 -0400 Received: by mail-ej1-x629.google.com with SMTP id dp18so18410911ejc.8; Mon, 13 Jul 2020 11:32:22 -0700 (PDT) Received: from x1w.redhat.com (138.red-83-57-170.dynamicip.rima-tde.net. [83.57.170.138]) by smtp.gmail.com with ESMTPSA id ce12sm4353148edb.4.2020.07.13.11.32.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2020 11:32: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=A45CZTNPoBUm1W95oEJT02xG5DfWi0IK+venM/Qt9bs=; b=RrTzR7+0l7YaevPSpaniWmb86Wlj4IrrZlKRLeAhQ6KZAG3sski4737esWwL5su6Pp Ce3l1UH/qBNR+ynPijOSaUcCEK+Lk0GI/gPp1slF2LjS79HcHNnWwPDBBJqZuH94tYt4 CikzDbl0L1RZJ2prXPK06kqm5YjCHy8oFoJqBUgGLGgIEY0JXumZeY+vxssK4u3/SjUF XRGYnPAmgqjuaLt9Qa9mUmnqX2yjDv6iNRYN1ueAjde0GFW+Az5Ykxalo0DN8Rh8kWwQ gZ9xflMSO6vAArf4ulsQ1qf4P6/opS1i2PuXT/0ALg3pL3L0HbZ6gDbnD0ipiLHA/wI0 3IVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=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=A45CZTNPoBUm1W95oEJT02xG5DfWi0IK+venM/Qt9bs=; b=giWewntv2U9q831HP0bffGFOs42DWtygnoIrXe4EV+kdKPgV/JSGi8I3hg5HK/9U3H ci5V51O3vOppTG0piKWYczgu1uC80biYu40sR5SaR9SbE3LPXHssWq3Us7yOO3RYRaWM f7ijlL9Qg00ZNg/cT+ZiQ27x5zQqUWdEh2LgdRd8JMX4TLypos8ZEVte5b9aNh7fbZuV pSyRdTO8zThgj/f3P5A0BJoykIqObRBrgMzBGYfZmgpedZ3chIZjfz0o2M6Sx26yZaoO YuTK/ZYMe6nQAY4LLWYtO69QwXNtqgAxieSO8/nc1mFetsKxjNZeBARZjRX55LCfUAkN CzLA== X-Gm-Message-State: AOAM5326NujSmeDX1UBDuJX4oYj6phAw2X1pwjGk0KGT1yBCspFHVLBI ke2A0ZyUb38jwbrMHfAEUaZtTmJ0iqA= X-Google-Smtp-Source: ABdhPJz0Qw8SlxeFe9OpDRbyHyGFrAh21kTo5G35ARfVjmG9nKS4QXR+N8grcx7i+gAD69uapIJ+iQ== X-Received: by 2002:a17:907:20d1:: with SMTP id qq17mr1032942ejb.214.1594665141592; Mon, 13 Jul 2020 11:32:21 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 7/9] hw/sd/sdcard: Do not allow invalid SD card sizes Date: Mon, 13 Jul 2020 20:32:07 +0200 Message-Id: <20200713183209.26308-8-f4bug@amsat.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200713183209.26308-1-f4bug@amsat.org> References: <20200713183209.26308-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::629; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ej1-x629.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=no autolearn_force=no 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 , Prasad J Pandit , qemu-block@nongnu.org, Alistair Francis , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Wainer dos Santos Moschetta , Alexander Bulekov , Niek Linnenbank , Cleber Rosa , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) QEMU allows to create SD card with unrealistic sizes. This could work, but some guests (at least Linux) consider sizes that are not a power of 2 as a firmware bug and fix the card size to the next power of 2. While the possibility to use small SD card images has been seen as a feature, it became a bug with CVE-2020-13253, where the guest is able to do OOB read/write accesses past the image size end. In a pair of commits we will fix CVE-2020-13253 as: Read command is rejected if BLOCK_LEN_ERROR or ADDRESS_ERROR occurred and no data transfer is performed. Write command is rejected if BLOCK_LEN_ERROR or ADDRESS_ERROR occurred and no data transfer is performed. WP_VIOLATION errors are not modified: the error bit is set, we stay in receive-data state, wait for a stop command. All further data transfer is ignored. See the check on sd->card_status at the beginning of sd_read_data() and sd_write_data(). While this is the correct behavior, in case QEMU create smaller SD cards, guests still try to access past the image size end, and QEMU considers this is an invalid address, thus "all further data transfer is ignored". This is wrong and make the guest looping until eventually timeouts. Fix by not allowing invalid SD card sizes (suggesting the expected size as a hint): $ qemu-system-arm -M orangepi-pc -drive file=3Drootfs.ext2,if=3Dsd,format= =3Draw qemu-system-arm: Invalid SD card size: 60 MiB SD card size has to be a power of 2, e.g. 64 MiB. You can resize disk images with 'qemu-img resize ' (note that this will lose data if you make the image smaller than it curr= ently is). Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alistair Francis Reviewed-by: Peter Maydell --- Since v1: Addressed Alistair & Peter comments (error_append_hint message) --- hw/sd/sd.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index edd60a09c0..5ab945dade 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -32,6 +32,7 @@ =20 #include "qemu/osdep.h" #include "qemu/units.h" +#include "qemu/cutils.h" #include "hw/irq.h" #include "hw/registerfields.h" #include "sysemu/block-backend.h" @@ -2106,11 +2107,35 @@ static void sd_realize(DeviceState *dev, Error **er= rp) } =20 if (sd->blk) { + int64_t blk_size; + if (blk_is_read_only(sd->blk)) { error_setg(errp, "Cannot use read-only drive as SD card"); return; } =20 + blk_size =3D blk_getlength(sd->blk); + if (blk_size > 0 && !is_power_of_2(blk_size)) { + int64_t blk_size_aligned =3D pow2ceil(blk_size); + char *blk_size_str; + + blk_size_str =3D size_to_str(blk_size); + error_setg(errp, "Invalid SD card size: %s", blk_size_str); + g_free(blk_size_str); + + blk_size_str =3D size_to_str(blk_size_aligned); + error_append_hint(errp, + "SD card size has to be a power of 2, e.g. %= s.\n" + "You can resize disk images with " + "'qemu-img resize '\n" + "(note that this will lose data if you make = the " + "image smaller than it currently is).\n", + blk_size_str); + g_free(blk_size_str); + + return; + } + ret =3D blk_set_perm(sd->blk, BLK_PERM_CONSISTENT_READ | BLK_PERM_= WRITE, BLK_PERM_ALL, errp); if (ret < 0) { --=20 2.21.3 From nobody Sat May 11 07:32:29 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1594665433; cv=none; d=zohomail.com; s=zohoarc; b=O9MOPMx1D44R5re8IXLCz8KBZ2TEAdntcAdkVLR1wrE2C/J4RkiAwfAL4WlN213egZ+Y9A0UoiramCPkvleB3TlNc8TYwk8qzDmAOtATeN7SGvtmfgU9VUDGsPxaJwI2OIKDC8XHmvcepMvspKfWaim+8tacw8i2fOTqPs5wXok= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594665433; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=RNEJrJvPidmgDJjxfdasYseF7s4TQEUs2Z1zglor56c=; b=GrV48NlO+CZbORR/7JTLvg6WWD+S780eGwvZOXcfUvAMWvVEF6NphY2r28vBxj3oDR0vN4sVtIoyjb70XlAoMWC+zEmcyTHR5cB/XcXo4yc7ivCmuJVxR2VmY61R4mQlhC6GIYAeJ6gTGTJQkwg2v/ezId4O9ufioShXRdGRKM8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1594665433067106.27944366524241; Mon, 13 Jul 2020 11:37:13 -0700 (PDT) Received: from localhost ([::1]:35176 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jv3KB-0002Cz-Gl for importer@patchew.org; Mon, 13 Jul 2020 14:37:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40396) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jv3Fa-0002J9-TC; Mon, 13 Jul 2020 14:32:26 -0400 Received: from mail-ej1-x643.google.com ([2a00:1450:4864:20::643]:37502) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jv3FY-0004J2-Vg; Mon, 13 Jul 2020 14:32:26 -0400 Received: by mail-ej1-x643.google.com with SMTP id lx13so18439483ejb.4; Mon, 13 Jul 2020 11:32:24 -0700 (PDT) Received: from x1w.redhat.com (138.red-83-57-170.dynamicip.rima-tde.net. [83.57.170.138]) by smtp.gmail.com with ESMTPSA id ce12sm4353148edb.4.2020.07.13.11.32.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2020 11:32: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=RNEJrJvPidmgDJjxfdasYseF7s4TQEUs2Z1zglor56c=; b=YVLko8msUdGheg7RY9oXfOeLZgc7uL4Uz4Wrru6Xd0d87dW5ujmQelVlJAcdniXxhf 9ihHnz1VLUgxZPfV52URIWBQWeTzd53PfBnhdpCc9omiimfLwVFbkhoLUwom0dqMrF6D uBQNQFFIwdnLGo6lYJWFdPcwgA4gd6U3iWSeWSYbwfpQT9VVEthOK99ctaE04giDVBj5 gk+OsyXZf7er8R+yw+wbZs/vgJF9JnnI7CMZNh7+HNAsmBenIkP5C+cglZwwAvMJpM2y a4q9/ybpZslVGRmmnCxNuF/j9ZA3tuGa9xWtXXNF8MvYWz6ZVmKEat5QJOWkUQ45HuZe sa/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=RNEJrJvPidmgDJjxfdasYseF7s4TQEUs2Z1zglor56c=; b=t+aOdlDrX2z62oAWNyoKcsSYYsKQ8Kd9JxG01guqrPaJI0lBXG1ZERdocB+hFIDqRi NZ3wtCW2iSm8aM0BuVx5wJhd2F8Busnr3EQe2CsWPDyXUPfOjlB7yxsCT9ZPNnX2SCfO U7puWCKpUKoyEaySz9mn15AWaByNT49sA+ezdLKictTf85iiaXgJ9QXGjANT5G5A8b/f vR/vKFc4OsBOlRo4MXut/rL+R9XapI/M3Aod4RK0QVNoLa0xRBABVfnA1TwRVPx5CX4Y OjVkQNDqX3fL2KcfcSy9VWPnCYZ1YF16mE521uXONkJde+qQBFNZ7nYh6DTX52BUa+kt Y3cw== X-Gm-Message-State: AOAM530ZBY7mWLnWPjVKPmZJhw+SU3LQ19NikZ2zeBHIX0aNenU8HH4z BA8n1AQy8O1NktolfgrelUGgRA2YBk0= X-Google-Smtp-Source: ABdhPJz5ArDouIhMLjCuRWJ7RRoTXJRQan6O/iH4wQTPEcagdzq9yaIV5qU2camZqZnOgtxKffXNDg== X-Received: by 2002:a17:906:2bc7:: with SMTP id n7mr1070705ejg.96.1594665143021; Mon, 13 Jul 2020 11:32:23 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 8/9] hw/sd/sdcard: Update coding style to make checkpatch.pl happy Date: Mon, 13 Jul 2020 20:32:08 +0200 Message-Id: <20200713183209.26308-9-f4bug@amsat.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200713183209.26308-1-f4bug@amsat.org> References: <20200713183209.26308-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::643; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ej1-x643.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=no autolearn_force=no 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 , Prasad J Pandit , qemu-block@nongnu.org, Alistair Francis , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Wainer dos Santos Moschetta , Alexander Bulekov , Niek Linnenbank , Alistair Francis , Cleber Rosa , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) To make the next commit easier to review, clean this code first. Reviewed-by: Peter Maydell Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alistair Francis Message-Id: <20200630133912.9428-3-f4bug@amsat.org> Reviewed-by: Alexander Bulekov --- hw/sd/sd.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 5ab945dade..0f048358ab 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1175,8 +1175,9 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, S= DRequest req) sd->data_start =3D addr; sd->data_offset =3D 0; =20 - if (sd->data_start + sd->blk_len > sd->size) + if (sd->data_start + sd->blk_len > sd->size) { sd->card_status |=3D ADDRESS_ERROR; + } return sd_r1; =20 default: @@ -1191,8 +1192,9 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, S= DRequest req) sd->data_start =3D addr; sd->data_offset =3D 0; =20 - if (sd->data_start + sd->blk_len > sd->size) + if (sd->data_start + sd->blk_len > sd->size) { sd->card_status |=3D ADDRESS_ERROR; + } return sd_r1; =20 default: @@ -1237,12 +1239,15 @@ static sd_rsp_type_t sd_normal_command(SDState *sd,= SDRequest req) sd->data_offset =3D 0; sd->blk_written =3D 0; =20 - if (sd->data_start + sd->blk_len > sd->size) + if (sd->data_start + sd->blk_len > sd->size) { sd->card_status |=3D ADDRESS_ERROR; - if (sd_wp_addr(sd, sd->data_start)) + } + if (sd_wp_addr(sd, sd->data_start)) { sd->card_status |=3D WP_VIOLATION; - if (sd->csd[14] & 0x30) + } + if (sd->csd[14] & 0x30) { sd->card_status |=3D WP_VIOLATION; + } return sd_r1; =20 default: @@ -1261,12 +1266,15 @@ static sd_rsp_type_t sd_normal_command(SDState *sd,= SDRequest req) sd->data_offset =3D 0; sd->blk_written =3D 0; =20 - if (sd->data_start + sd->blk_len > sd->size) + if (sd->data_start + sd->blk_len > sd->size) { sd->card_status |=3D ADDRESS_ERROR; - if (sd_wp_addr(sd, sd->data_start)) + } + if (sd_wp_addr(sd, sd->data_start)) { sd->card_status |=3D WP_VIOLATION; - if (sd->csd[14] & 0x30) + } + if (sd->csd[14] & 0x30) { sd->card_status |=3D WP_VIOLATION; + } return sd_r1; =20 default: --=20 2.21.3 From nobody Sat May 11 07:32:29 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=amsat.org ARC-Seal: i=1; a=rsa-sha256; t=1594665448; cv=none; d=zohomail.com; s=zohoarc; b=aQgyk4jnNZzhCxYR9wK/IcBZXQb2hUHKMhE6WiQKXa00yoKuMbKe099az8DVga8L3Gp4RHDUmo3krmzhGfkWcCFHLZ3UsfZDYU4KzrOtVBfs+6EbnGPX0w51uqz2n66w1Qep+E1mm2YtcWF2B+lYCBL7iGtyKw9OaKkJPDMAyVs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594665448; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=qazA0VGXkxiPG2O5k0zj3oJOG8OveMdhu7VGjKLmSlU=; b=LuftiZe6cbKVtKZ8Y8UgyM+JwPMHhtVIZHQI75Z3xYnZD/Na3fNcDuV2f/oZw8r8LpgVNrDa007RoH5eJr3wxDlt5VV271wd4PEfU2XzDuTfw0o4UTte4Dsq9IMzYkX3xM71hGeYDFwk+UHDhCNs1EPXsT9Mx+npRL/rTgUFZ/k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1594665448605736.2023752121511; Mon, 13 Jul 2020 11:37:28 -0700 (PDT) Received: from localhost ([::1]:36580 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jv3KR-0002pc-E5 for importer@patchew.org; Mon, 13 Jul 2020 14:37:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40418) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jv3Fc-0002O1-Lb; Mon, 13 Jul 2020 14:32:28 -0400 Received: from mail-ej1-x643.google.com ([2a00:1450:4864:20::643]:38641) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jv3Fa-0004LC-UV; Mon, 13 Jul 2020 14:32:28 -0400 Received: by mail-ej1-x643.google.com with SMTP id br7so4611463ejb.5; Mon, 13 Jul 2020 11:32:26 -0700 (PDT) Received: from x1w.redhat.com (138.red-83-57-170.dynamicip.rima-tde.net. [83.57.170.138]) by smtp.gmail.com with ESMTPSA id ce12sm4353148edb.4.2020.07.13.11.32.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2020 11:32:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qazA0VGXkxiPG2O5k0zj3oJOG8OveMdhu7VGjKLmSlU=; b=h6Nyb/ugU5YAfZlJvJLDLyPSZeJipUn7NVdjSe9cwbY6qE4Z7QcAr9AEStzYyAPbDf EvyGzgEkyzyGO/ZpD0/YTbRNzNK1aKzYVR3U4kpM1kLOVGUYWjPWlnGkj5J1kOTPgZ0i q2Js3UIgGqlbOstLWjRw5+5a6q5u/K50FVx2DgBN824y/IRS01sbxiPRGSirBXeiZhVj EJv0mfeDuehSd8z7CB340zMGr8RXKqmzIgJhejfJRBMz8a+0MM+R642bvtXuqGNXZ5wK BzN3LO91P5v3DjKB8D8T1xIepTOGGANuNDCRvhx5VlRwiBz050n9Hj1eYKwVrcQpQJ38 4k8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=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=qazA0VGXkxiPG2O5k0zj3oJOG8OveMdhu7VGjKLmSlU=; b=aMiWkB6ZDanbaGQDrSJlpoZUHlh+XtridF+btB6Bp9fKsqUpKOFxi+YLRvZCqiIJJ/ 9pknlAS0QZdj3HvWkHRMmS1Dk4VGmVIgHXUXCoMccpsY31Z8CalHueJiABdWEPTYfvwc ZcOZ0z6UBExGWf6hH2QtnYmOfO8TV9gemiNymOM+D+vtpR6j8sssEGGnARnhquoz33Di IerVUiwilZvh5G3fHQiCo14c5AXfmXFi+gFu53aSgTkmOvMWusx05qeyzOvksXUVT2CZ vuvMzvWUoXSyfDtBg5OYXHsMdv99rwv4i+WbNErX85zzjDtdzPjJ8Fw3saM4nh+15WSM CzUA== X-Gm-Message-State: AOAM531P3U0uIDaZVlfEBxLVbcKDGzza7xTjc4c3PbMWTpXRSDAQtKm/ eGkPK+q/Qjg2khUW+vr+gf4EVQslgKY= X-Google-Smtp-Source: ABdhPJyx1QwwCG/gRXM+pknynv9HTuIyCTNS3t78xO9a7sWgHTXzhFwoUqsRoLpzGvY6u/wBHRbZOA== X-Received: by 2002:a17:906:2654:: with SMTP id i20mr1087142ejc.80.1594665144798; Mon, 13 Jul 2020 11:32:24 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 9/9] hw/sd/sdcard: Do not switch to ReceivingData if address is invalid Date: Mon, 13 Jul 2020 20:32:09 +0200 Message-Id: <20200713183209.26308-10-f4bug@amsat.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200713183209.26308-1-f4bug@amsat.org> References: <20200713183209.26308-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::643; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ej1-x643.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=no autolearn_force=no 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 , Prasad J Pandit , qemu-block@nongnu.org, Alistair Francis , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Wainer dos Santos Moschetta , Alexander Bulekov , Niek Linnenbank , Alistair Francis , Cleber Rosa , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Only move the state machine to ReceivingData if there is no pending error. This avoids later OOB access while processing commands queued. "SD Specifications Part 1 Physical Layer Simplified Spec. v3.01" 4.3.3 Data Read Read command is rejected if BLOCK_LEN_ERROR or ADDRESS_ERROR occurred and no data transfer is performed. 4.3.4 Data Write Write command is rejected if BLOCK_LEN_ERROR or ADDRESS_ERROR occurred and no data transfer is performed. WP_VIOLATION errors are not modified: the error bit is set, we stay in receive-data state, wait for a stop command. All further data transfer is ignored. See the check on sd->card_status at the beginning of sd_read_data() and sd_write_data(). Fixes: CVE-2020-13253 Cc: Prasad J Pandit Reported-by: Alexander Bulekov Buglink: https://bugs.launchpad.net/qemu/+bug/1880822 Reviewed-by: Peter Maydell Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alistair Francis Message-Id: <20200630133912.9428-6-f4bug@amsat.org> --- hw/sd/sd.c | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 0f048358ab..29de05f576 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1171,13 +1171,15 @@ static sd_rsp_type_t sd_normal_command(SDState *sd,= SDRequest req) case 17: /* CMD17: READ_SINGLE_BLOCK */ switch (sd->state) { case sd_transfer_state: + + if (addr + sd->blk_len > sd->size) { + sd->card_status |=3D ADDRESS_ERROR; + return sd_r1; + } + sd->state =3D sd_sendingdata_state; sd->data_start =3D addr; sd->data_offset =3D 0; - - if (sd->data_start + sd->blk_len > sd->size) { - sd->card_status |=3D ADDRESS_ERROR; - } return sd_r1; =20 default: @@ -1188,13 +1190,15 @@ static sd_rsp_type_t sd_normal_command(SDState *sd,= SDRequest req) case 18: /* CMD18: READ_MULTIPLE_BLOCK */ switch (sd->state) { case sd_transfer_state: + + if (addr + sd->blk_len > sd->size) { + sd->card_status |=3D ADDRESS_ERROR; + return sd_r1; + } + sd->state =3D sd_sendingdata_state; sd->data_start =3D addr; sd->data_offset =3D 0; - - if (sd->data_start + sd->blk_len > sd->size) { - sd->card_status |=3D ADDRESS_ERROR; - } return sd_r1; =20 default: @@ -1234,14 +1238,17 @@ static sd_rsp_type_t sd_normal_command(SDState *sd,= SDRequest req) /* Writing in SPI mode not implemented. */ if (sd->spi) break; + + if (addr + sd->blk_len > sd->size) { + sd->card_status |=3D ADDRESS_ERROR; + return sd_r1; + } + sd->state =3D sd_receivingdata_state; sd->data_start =3D addr; sd->data_offset =3D 0; sd->blk_written =3D 0; =20 - if (sd->data_start + sd->blk_len > sd->size) { - sd->card_status |=3D ADDRESS_ERROR; - } if (sd_wp_addr(sd, sd->data_start)) { sd->card_status |=3D WP_VIOLATION; } @@ -1261,14 +1268,17 @@ static sd_rsp_type_t sd_normal_command(SDState *sd,= SDRequest req) /* Writing in SPI mode not implemented. */ if (sd->spi) break; + + if (addr + sd->blk_len > sd->size) { + sd->card_status |=3D ADDRESS_ERROR; + return sd_r1; + } + sd->state =3D sd_receivingdata_state; sd->data_start =3D addr; sd->data_offset =3D 0; sd->blk_written =3D 0; =20 - if (sd->data_start + sd->blk_len > sd->size) { - sd->card_status |=3D ADDRESS_ERROR; - } if (sd_wp_addr(sd, sd->data_start)) { sd->card_status |=3D WP_VIOLATION; } --=20 2.21.3