From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F0B95C433FE for ; Wed, 13 Apr 2022 14:21:49 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E806783CE9; Wed, 13 Apr 2022 16:21:47 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="CXOW/Rgf"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DE2A983CE9; Wed, 13 Apr 2022 16:21:46 +0200 (CEST) Received: from mail-wm1-x349.google.com (mail-wm1-x349.google.com [IPv6:2a00:1450:4864:20::349]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 93A4E83C01 for ; Wed, 13 Apr 2022 16:21:44 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=3d9xWYgYKBqQEWGYPPKSSKPI.GSQY-FSSXPMWXW.HIRb.HI@flex--ascull.bounces.google.com Received: by mail-wm1-x349.google.com with SMTP id n17-20020a05600c501100b0038e731cf5e1so853549wmr.2 for ; Wed, 13 Apr 2022 07:21:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:message-id:mime-version:subject:from:to:cc; bh=I2SnhBgUgkvJFBCChhxjgLaszBshcQL9gt/xH68iGWQ=; b=CXOW/RgfjuFBVpJQ9e3Wn5nSpvdkLj4v+yltpL3iWkYWBA7y7ByzSPaff9x0eU3+s5 lNpcEV4tDvnZLJ24MGhRqSJoAXFqjMk5spgze5WQIy8x3PEaUWe96AxP2DLhqP0ft8hX dAcSVd4Mddzg5JLWAO/wV1fTa7Jnk4h/6iLpF2LPQdoZ0fm2LHks8ZkpjIuCgi491fFf OuHmgQ7b86ryQ3g3nEC5ERKCbb1nYtIbh73C5Rv+0rshm1SIk1gBU7I12kN/nTQ/7Ak4 oMYifeSJL7+XiWMTPp9Ti0Ih7BnZJFzKwgKL3pfT/v1u5oVPThlHvQReYP9HHCRkaZUv dpUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=I2SnhBgUgkvJFBCChhxjgLaszBshcQL9gt/xH68iGWQ=; b=eY4R6rpbsTD8gNwbEFQwgCHG6JI12UgpPI8gNGWjHbB04e2J3LZ1xyIxcWQejU8ZpI iA9dKECqu3aDAZTBHxI2emtXQss+grTf93Y9F68mnUwfaCKVhjBuIrO9nh7tw01u53TE 6vJdlmZXgMkBy6IMi1rS1H0sQAwszkD24+JGEuJmpF+QBciukN8lbg31b/8AwlKiqgSl 4HZ2zVZha9pSNjBN+Kneiq4NTAC2AqZMkkgV4paue4/ue8TqOezJTxJTjG/5L3Q/B8MS 1n0fORHsCaIxdr5huglq3J2dAFRMMcbWOtMZPgKaVpBTCe4IjdYMYTqt2bNDli8SfrZP 5MGQ== X-Gm-Message-State: AOAM533o6hdL5D5+GI3FisEhE2A+bPbCbdGKDOf3j9C1sMB373O/78Ua Dfn2mv8yF9YdwENBBwG/Y58/DSiEPS49ESrdms+5/6QsY6KZsD40GzJX0io0flYJx5ZKcdWUpCa K4A2yjDOht5Th9NUrxIAyiWrGn9a5kxqwItXo5Evy4UW7ikCRbwWChEySy2s= X-Google-Smtp-Source: ABdhPJwgA4BOmcXz4uqTJCi9/jlqKpQKt3vnVNycKhUvdprWY6ZgVsD8BoTVa70C5v63YJMxYGn2vZi6PDs= X-Received: from ascull.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:1510]) (user=ascull job=sendgmr) by 2002:a05:600c:2258:b0:38e:bbdc:426 with SMTP id a24-20020a05600c225800b0038ebbdc0426mr8748002wmm.184.1649859703943; Wed, 13 Apr 2022 07:21:43 -0700 (PDT) Date: Wed, 13 Apr 2022 14:21:25 +0000 Message-Id: <20220413142137.560987-1-ascull@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.35.1.1178.g4f1659d476-goog Subject: [PATCH v2 00/12] virtio: Harden and test vring From: Andrew Scull To: u-boot@lists.denx.de Cc: sjg@chromium.org, trini@konsulko.com, Andrew Scull Content-Type: text/plain; charset="UTF-8" X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean Continuing the theme of making the virtio code resilient against corruption of the buffers shared with the device, this series focusses on the vring. It follows the example of Linux by keeping a private copy of the descriptors and metadata for state tracking and only ever writing to the descriptors that are shared with the device. I was able to test these hardening steps in the sandbox by simulating device writes to the queues. >From v1: - Fix build errors on SPL by making dependency on virtio drivers explicit Andrew Scull (12): virtio_ring: Merge identical variables virtio_ring: Add helper to attach vring descriptor virtio_ring: Maintain a shadow copy of descriptors virtio_ring: Check used descriptors are chain heads dm: test: virtio: Test the virtio ring virtio: sandbox: Fix device features bitfield test: dm: virtio: Test notify before del_vqs test: dm: virtio: Split out virtio device tests virtio: sandbox: Bind RNG rather than block device test: dm: virtio: Test virtio device driver probing virtio: rng: Check length before copying test: dm: virtio_rng: Test virtio-rng with faked device drivers/virtio/virtio_ring.c | 90 ++++++++++----- drivers/virtio/virtio_rng.c | 3 + drivers/virtio/virtio_sandbox.c | 4 +- include/virtio_ring.h | 12 ++ test/dm/Makefile | 6 +- test/dm/virtio.c | 99 ---------------- test/dm/virtio_device.c | 195 ++++++++++++++++++++++++++++++++ test/dm/virtio_rng.c | 52 +++++++++ 8 files changed, 328 insertions(+), 133 deletions(-) create mode 100644 test/dm/virtio_device.c create mode 100644 test/dm/virtio_rng.c -- 2.35.1.1178.g4f1659d476-goog