From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) by mx.groups.io with SMTP id smtpd.web11.23520.1682608816600522489 for ; Thu, 27 Apr 2023 08:20:16 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20221208 header.b=Yj0AnjaI; spf=pass (domain: gmail.com, ip: 209.85.210.176, mailfrom: pedro.falcato@gmail.com) Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-64115e652eeso5773083b3a.0 for ; Thu, 27 Apr 2023 08:20:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682608816; x=1685200816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=ZUgaD2Fus8oQFcUCVfrParAMp93mt5FrlgJbTpo2eLQ=; b=Yj0AnjaIY6M2iE3xAcEMtZejLXU26i6CkKiQpyTujNZ/+raigjIaxVEG27f6ZruRGk OY72/wTYVgGiL3MDIw3C3A8o3zG4XxMMox0xhXYbLffjaGyK4ANbhHtZAO1SuE2ioep5 wAWSSyV9PYlSSAuiRBXe2oN3tdC5Uf+0xxLkjDfs27QolEJxxjTu+zZsGUqWqjpW+fEg DVHSO/JJJDfCEBqSvWRMl0jMrwEWH9Rz+eArlmtb2KXChuep32Fpr2bl4H2uctcATHvv tidpwGHTz3eyOjUdcfBpyMzh435qD8OMgteAFInP9ksdakBcxTW3LnVFkwiW6Q040tCF T0+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682608816; x=1685200816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZUgaD2Fus8oQFcUCVfrParAMp93mt5FrlgJbTpo2eLQ=; b=bCjtK5E5QJuIc9KR9tK7KsnWIkWqdh6TaQkbhdP0uVnMerTdEjN5NjtmspbpraLoY7 21msnWd7vMUAWBn9dBCGoz0XsTvLpHuCLnl/Iu5M0qZCBbuVLgKA52tIUJwttOPfxwe8 XZXRgxRwTH0+7jQPXqeDUMP822QHUAbo9ZKhJ9o8LRmg1T106Rvgf2Js41f1JS9FQ0cH sloHeC7Jqn0WRmdON3RDfB1i3sFRdBKwrul5xL73g+OvvJbY369+KOWG1WNP+/Hw9k0I HCY+adh9Cur/PjExQrCKkyIOQSL+p/EPs+KooJJQxYuSdkMnGMA09WcWpIZ3sgFKnImq 51gg== X-Gm-Message-State: AC+VfDxU3KPVL4a/UVeqiZ5HxOZl8WzFJYdI3cIOlct3Rk6xZQiv+i5z F4vMEb7sGTAULFMIXfJCdK+8AkAf065lPZlXgDE= X-Google-Smtp-Source: ACHHUZ5K/dltAtRYV972rVjzOe7YIazKzC1gqkNdzq9i6xXlz5dpuvgC9zCNMS3rIjTsTLOagt+n1AQAm4i7yrtODek= X-Received: by 2002:a17:90a:8a09:b0:247:14ac:4d3a with SMTP id w9-20020a17090a8a0900b0024714ac4d3amr2608190pjn.20.1682608815909; Thu, 27 Apr 2023 08:20:15 -0700 (PDT) MIME-Version: 1.0 References: <26167.1682546049698720608@groups.io> In-Reply-To: <26167.1682546049698720608@groups.io> From: "Pedro Falcato" Date: Thu, 27 Apr 2023 16:20:04 +0100 Message-ID: Subject: Re: [edk2-devel] [PATCH v4 1/1] MdePkg/BaseRngLib: Add a smoketest for RDRAND and check CPUID To: Benjamin Doron Cc: devel@edk2.groups.io Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Apr 26, 2023 at 10:54=E2=80=AFPM Benjamin Doron wrote: > > Hi, > Is there merit to removing the assert statement? When this instance of th= e RngLib class is used, the platform builder says there's RNG support. Asse= rts are a little easier to see than debug prints, especially when they stal= l the platform. I think that leaving it in is better. If asserts don't call= CpuDeadLoop() or are removed from the build entirely, then `ArchIsRngSuppo= rted()` will ensure safe behaviour (but incorrect functionality). Certain platforms may not know if the CPU has rdrand or if it's broken at all. For instance, OVMF (1st case) or firmware for the AMD AM4 mobos (where they had zen1, 2 and 3 with some RDRAND breakage in between). Also, as you mentioned, ASSERTs can be entirely removed from the build. So I don't think asserts are a good idea here. Unless you want to suggest hiding the ASSERT with a PCD, in which case, yuck? > Also, I'm slightly concerned that the check for minimum RDRAND changes wi= ll succeed if it returns 0s, then 1s, then 0s... Though this seems like an = RDRAND broken too conveniently, not a true errata. Ack, I don't think the algorithm is perfect, but it's what Jason wrote for Linux and suggested; I guess it may be adjusted if we so need, but at the moment it definitely detects the egregious AMD breakage. --=20 Pedro