From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mx.groups.io with SMTP id smtpd.web10.15753.1685030021708243899 for ; Thu, 25 May 2023 08:53:41 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mKnOJGwZ; spf=pass (domain: kernel.org, ip: 139.178.84.217, mailfrom: ardb@kernel.org) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4005A614BC for ; Thu, 25 May 2023 15:53:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A3C04C433EF for ; Thu, 25 May 2023 15:53:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685030020; bh=paK1VKBo1faxZQyfpvXf7pRy7aQuvS1V9Ui0o9vkHBc=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=mKnOJGwZMuJ2M0iB0GXXacQSXh6jR2F8mM6+kVJEpVNlgKsL/M12mPM6NxVj7mVGp w38mi7poc1BXKmxJyuaiyjKQeQty1LQDGQmbyao1BO6AhdcXzNiqEoZyr2raBdnUFi 0rTdbjbvrVmAUZWetGwhIrtEhmbaP/mLgMmm2nKzf47bF6LYWG/UNbuHPBwa92ZS+S xQh0spW9OpvZhmSOxiJPZNz0BKLDHfaNxHilEu8WLoQOv8RvigCHbFzyW2F0/6gols fB6IhSYhtQiSKkx1v+efVudVs2F7tbt0bk82WS5/Z+y0CHCTLwCKFndWx8UewTA0/c JpyKjiRREQN5Q== Received: by mail-lj1-f176.google.com with SMTP id 38308e7fff4ca-2b03d3e41fcso9021371fa.0 for ; Thu, 25 May 2023 08:53:40 -0700 (PDT) X-Gm-Message-State: AC+VfDzzkHmK491SdjcMGgSJPfIe1qeFKSVNAnbIS4B93eNM4wThb6Ke x5OuXZBQHFzDYbCPpL3SRq1IWhRF41adM9BYSpI= X-Google-Smtp-Source: ACHHUZ680xBFGFx2dEFqT/Fn7yw/8SXa3saVqfqHXO34eoqa6j+CE+NYT4S5IJ6Jy1a0s2nWyykGxthyV+mFuiVUi3k= X-Received: by 2002:a2e:b16c:0:b0:2af:2786:271d with SMTP id a12-20020a2eb16c000000b002af2786271dmr911823ljm.21.1685030018706; Thu, 25 May 2023 08:53:38 -0700 (PDT) MIME-Version: 1.0 References: <20230502055942.22929-1-kraxel@redhat.com> In-Reply-To: <20230502055942.22929-1-kraxel@redhat.com> From: "Ard Biesheuvel" Date: Thu, 25 May 2023 17:53:27 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 1/1] OvmfPkg/QemuFlashFvbServicesRuntimeDxe: refine flash detection To: Gerd Hoffmann Cc: devel@edk2.groups.io, Pawel Polawski , Jiewen Yao , Ard Biesheuvel , Oliver Steffen , Jordan Justen Content-Type: text/plain; charset="UTF-8" On Tue, 2 May 2023 at 07:59, Gerd Hoffmann wrote: > > Check whenever flash is actually writable. > This is a bit too terse. Could you explain why this is needed, and why this approach is suitable? > Signed-off-by: Gerd Hoffmann > --- > OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.c | 14 +++++++++++--- > 1 file changed, 11 insertions(+), 3 deletions(-) > > diff --git a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.c b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.c > index 54f859de9ff9..a577aea55614 100644 > --- a/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.c > +++ b/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.c > @@ -114,9 +114,17 @@ QemuFlashDetected ( > DEBUG ((DEBUG_INFO, "QemuFlashDetected => FD behaves as RAM\n")); > *Ptr = OriginalUint8; > } else if (ProbeUint8 == CLEARED_ARRAY_STATUS) { > - DEBUG ((DEBUG_INFO, "QemuFlashDetected => FD behaves as FLASH\n")); > - FlashDetected = TRUE; > - *Ptr = READ_ARRAY_CMD; > + *Ptr = WRITE_BYTE_CMD; > + *Ptr = OriginalUint8; > + *Ptr = READ_STATUS_CMD; > + ProbeUint8 = *Ptr; > + *Ptr = READ_ARRAY_CMD; > + if (ProbeUint8 & 0x10 /* programming error */) { > + DEBUG ((DEBUG_INFO, "QemuFlashDetected => FD behaves as FLASH, write-protected\n")); > + } else { > + DEBUG ((DEBUG_INFO, "QemuFlashDetected => FD behaves as FLASH, writable\n")); > + FlashDetected = TRUE; > + } > } > } > > -- > 2.40.0 >