This implements a UEFI driver model driver for the VirtIO RNG device.

Changes since v2:
- incorporate feedback from Laszlo (patch #2)
- added patch to wire up the driver in ArmVirtQemu (#3)

Changes since v1:
- validate args rather than ASSERT () their validity
- use a volatile intermediate buffer so the compiler does not optimize the
  access away
- include Laszlo's patch #1 which greatly simplifies the next item
- poke the virtio RNG device as long as we need to satisfy our full request,
  since a single invocation may return less data than we asked for

I have tested the driver with a rate limit of 19 bytes per 1000 ms, with a
file containing a predictable pattern. The RngTest output is below, it took
a minute or so for the full output to appear, but it looks like the repeated
polling of the device is working as expected.

while true; do echo -n 00112233445566778899AABBCCDDEEFF; done | \
  xxd -r -p | dd iflag=fullblock count=2 bs=1M of=/tmp/unrandom

and pass 

        -object rng-random,filename=/tmp/unrandom,id=rng0 \
        -device virtio-rng-pci,rng=rng0,max-bytes=19,period=1000 \
  
on the QEMU command line

Ard Biesheuvel (2):
  OvmfPkg: implement UEFI driver for Virtio RNG devices
  ArmVirtPkg: ArmVirtQemu: add driver for Virtio-RNG device

Laszlo Ersek (1):
  OvmfPkg: VirtioFlush(): return the number of bytes written by the host

 ArmVirtPkg/ArmVirtQemu.dsc            |   1 +
 ArmVirtPkg/ArmVirtQemu.fdf            |   1 +
 OvmfPkg/Include/Library/VirtioLib.h   |  11 +-
 OvmfPkg/Library/VirtioLib/VirtioLib.c |  26 +-
 OvmfPkg/VirtioBlkDxe/VirtioBlk.c      |   3 +-
 OvmfPkg/VirtioRngDxe/VirtioRng.c      | 650 ++++++++++++++++++++
 OvmfPkg/VirtioRngDxe/VirtioRng.h      |  46 ++
 OvmfPkg/VirtioRngDxe/VirtioRng.inf    |  45 ++
 OvmfPkg/VirtioScsiDxe/VirtioScsi.c    |   2 +-
 9 files changed, 779 insertions(+), 6 deletions(-)
 create mode 100644 OvmfPkg/VirtioRngDxe/VirtioRng.c
 create mode 100644 OvmfPkg/VirtioRngDxe/VirtioRng.h
 create mode 100644 OvmfPkg/VirtioRngDxe/VirtioRng.inf

-- 
2.5.0

UEFI RNG Protocol Testing :
----------------------------
 -- Locate UEFI RNG Protocol : [Pass]
 -- Call RNG->GetInfo() interface : 
     >> Supported RNG Algorithm (Count = 1) : 
          0) 09000030-0000-0000-181F-B73801000000
 -- Call RNG->GetRNG() interface : 
     >> RNG with default algorithm : [Pass]
     >> RNG with SP800-90-HMAC-256 : [Fail - Status = Unsupported]
     >> RNG with SP800-90-Hash-256 : [Fail - Status = Unsupported]
     >> RNG with SP800-90-CTR-256 : [Fail - Status = Unsupported]
     >> RNG with X9.31-3DES : [Fail - Status = Unsupported]
     >> RNG with X9.31-AES : [Fail - Status = Unsupported]
     >> RNG with RAW Entropy : [Pass]
 -- Random Number Generation Test with default RNG Algorithm (20 Rounds): 
          01) - 00
          02) - 1122
          03) - 334455
          04) - 66778899
          05) - AABBCCDDEE
          06) - FF0011223344
          07) - 5566778899AABB
          08) - CCDDEEFF00112233
          09) - 445566778899AABBCC
          10) - DDEEFF00112233445566
          11) - 778899AABBCCDDEEFF0011
          12) - 2233445566778899AABBCCDD
          13) - EEFF00112233445566778899AA
          14) - BBCCDDEEFF001122334455667788
          15) - 99AABBCCDDEEFF0011223344556677
          16) - 8899AABBCCDDEEFF0011223344556677
          17) - 8899AABBCCDDEEFF001122334455667788
          18) - 99AABBCCDDEEFF00112233445566778899AA
          19) - BBCCDDEEFF00112233445566778899AABBCCDD
          20) - EEFF00112233445566778899AABBCCDDEEFF0011
 -- RAW Entropy Generation Test (20 Rounds) : 
          01) - 2233445566778899AABBCCDDEEFF00112233445566778899AABBCCDDEEFF0011
          02) - 2233445566778899AABBCCDDEEFF00112233445566778899AABBCCDDEEFF0011
          03) - 2233445566778899AABBCCDDEEFF00112233445566778899AABBCCDDEEFF0011
          04) - 2233445566778899AABBCCDDEEFF00112233445566778899AABBCCDDEEFF0011
          05) - 2233445566778899AABBCCDDEEFF00112233445566778899AABBCCDDEEFF0011
          06) - 2233445566778899AABBCCDDEEFF00112233445566778899AABBCCDDEEFF0011
          07) - 2233445566778899AABBCCDDEEFF00112233445566778899AABBCCDDEEFF0011
          08) - 2233445566778899AABBCCDDEEFF00112233445566778899AABBCCDDEEFF0011
          09) - 2233445566778899AABBCCDDEEFF00112233445566778899AABBCCDDEEFF0011
          10) - 2233445566778899AABBCCDDEEFF00112233445566778899AABBCCDDEEFF0011
          11) - 2233445566778899AABBCCDDEEFF00112233445566778899AABBCCDDEEFF0011
          12) - 2233445566778899AABBCCDDEEFF00112233445566778899AABBCCDDEEFF0011
          13) - 2233445566778899AABBCCDDEEFF00112233445566778899AABBCCDDEEFF0011
          14) - 2233445566778899AABBCCDDEEFF00112233445566778899AABBCCDDEEFF0011
          15) - 2233445566778899AABBCCDDEEFF00112233445566778899AABBCCDDEEFF0011
          16) - 2233445566778899AABBCCDDEEFF00112233445566778899AABBCCDDEEFF0011
          17) - 2233445566778899AABBCCDDEEFF00112233445566778899AABBCCDDEEFF0011
          18) - 2233445566778899AABBCCDDEEFF00112233445566778899AABBCCDDEEFF0011
          19) - 2233445566778899AABBCCDDEEFF00112233445566778899AABBCCDDEEFF0011
          20) - 2233445566778899AABBCCDDEEFF00112233445566778899AABBCCDDEEFF0011
 -- Exit UEFI RNG Protocol Test (Status = Success).
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to