From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.61]) by mx.groups.io with SMTP id smtpd.web11.8576.1593085271820662626 for ; Thu, 25 Jun 2020 04:41:12 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YZVXXQw+; spf=pass (domain: redhat.com, ip: 205.139.110.61, mailfrom: philmd@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593085271; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=OiTxF0FNVusDctxjR14OEatGz8e8AzmPw9loOT/pUC0=; b=YZVXXQw+pyuhxDXV0DNnX1dWnb9u9+3462A+r56+Vrxb2rjJmdqF8mulIU4IGLNTpoQyvA fPnbpDSwhG8L0e/IejDAGQaGUwE5Y7jWAxQaP146bWsHiWEQaLmuZqgG8hxjYMwgvubELm qqYbpqqNrME44T78oXSQctdHu2GiVaM= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-158-LVAirktlNu2C0MSkP1yldg-1; Thu, 25 Jun 2020 07:41:05 -0400 X-MC-Unique: LVAirktlNu2C0MSkP1yldg-1 Received: by mail-wr1-f71.google.com with SMTP id e11so6664230wrs.2 for ; Thu, 25 Jun 2020 04:41:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=OiTxF0FNVusDctxjR14OEatGz8e8AzmPw9loOT/pUC0=; b=s5/6N65ic2BVeE0RAGM3YpehholI1iStrLftH+37Vmzb3ONJ6FWzVC2xTaQQm0ebhG 0jHkjvRuvZbC5JCQ0okfnJgHvcjYzVVQMQ2iKbf+tCAqnrLtQGtbkbHMNWNDeqMBCxWB vXZrqQhJH85wq59gcgPCBXZjALfIw6Sqa5100IAwGB4gdU2l+TXRKSJkBUvgk61i/X/U h0uEtytYsE5g1e3x8qjLWK+N8jyaR4/xYwSD8qALQGtLRFsmpro5R0+uTk7yBT+xkW1B QDolJoywe5c7qBRBdaZYxQuKaOARYjNE1PPC666MAl4hYyLmqrtqR5p2HimH7ZV8gJ+7 EXFw== X-Gm-Message-State: AOAM531wZdd+7q+AVRKnPyTZqu2KtHjo4b4EBhFcE0vs/N1FNrkRJuvO 9ydBoOQxjr9BmcljkEoTKfdnC70IcIXLMSpIrGzwReGiyXh/gi8Ugxhv+kekA1DrOm6yS2sa7aV J+MeSM4v61X3tfg== X-Received: by 2002:a1c:750e:: with SMTP id o14mr2865386wmc.86.1593085264483; Thu, 25 Jun 2020 04:41:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxtKt66+mrcsat+BLpB+INufae14Iax2fzWIZXlGppfGDrTQ3wXJ/mdgsntA0BMGelhZMD3Bw== X-Received: by 2002:a1c:750e:: with SMTP id o14mr2865349wmc.86.1593085264214; Thu, 25 Jun 2020 04:41:04 -0700 (PDT) Return-Path: Received: from [192.168.1.40] (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id m10sm12813720wru.4.2020.06.25.04.41.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 25 Jun 2020 04:41:03 -0700 (PDT) Subject: Re: [edk2-devel] [PATCH v3 06/15] ArmVirtPkg: Add Kvmtool NOR flash lib To: Ard Biesheuvel , devel@edk2.groups.io, Sami Mujawar Cc: leif@nuviainc.com, lersek@redhat.com, Alexandru.Elisei@arm.com, Andre.Przywara@arm.com, Matteo.Carlini@arm.com, Laura.Moretta@arm.com, nd@arm.com References: <20200624133458.61920-1-sami.mujawar@arm.com> <20200624133458.61920-7-sami.mujawar@arm.com> From: =?UTF-8?B?UGhpbGlwcGUgTWF0aGlldS1EYXVkw6k=?= Autocrypt: addr=philmd@redhat.com; keydata= mQINBDXML8YBEADXCtUkDBKQvNsQA7sDpw6YLE/1tKHwm24A1au9Hfy/OFmkpzo+MD+dYc+7 bvnqWAeGweq2SDq8zbzFZ1gJBd6+e5v1a/UrTxvwBk51yEkadrpRbi+r2bDpTJwXc/uEtYAB GvsTZMtiQVA4kRID1KCdgLa3zztPLCj5H1VZhqZsiGvXa/nMIlhvacRXdbgllPPJ72cLUkXf z1Zu4AkEKpccZaJspmLWGSzGu6UTZ7UfVeR2Hcc2KI9oZB1qthmZ1+PZyGZ/Dy+z+zklC0xl XIpQPmnfy9+/1hj1LzJ+pe3HzEodtlVA+rdttSvA6nmHKIt8Ul6b/h1DFTmUT1lN1WbAGxmg CH1O26cz5nTrzdjoqC/b8PpZiT0kO5MKKgiu5S4PRIxW2+RA4H9nq7nztNZ1Y39bDpzwE5Sp bDHzd5owmLxMLZAINtCtQuRbSOcMjZlg4zohA9TQP9krGIk+qTR+H4CV22sWldSkVtsoTaA2 qNeSJhfHQY0TyQvFbqRsSNIe2gTDzzEQ8itsmdHHE/yzhcCVvlUzXhAT6pIN0OT+cdsTTfif MIcDboys92auTuJ7U+4jWF1+WUaJ8gDL69ThAsu7mGDBbm80P3vvUZ4fQM14NkxOnuGRrJxO qjWNJ2ZUxgyHAh5TCxMLKWZoL5hpnvx3dF3Ti9HW2dsUUWICSQARAQABtDJQaGlsaXBwZSBN YXRoaWV1LURhdWTDqSAoUGhpbCkgPHBoaWxtZEByZWRoYXQuY29tPokCVQQTAQgAPwIbDwYL CQgHAwIGFQgCCQoLBBYCAwECHgECF4AWIQSJweePYB7obIZ0lcuio/1u3q3A3gUCXsfWwAUJ KtymWgAKCRCio/1u3q3A3ircD/9Vjh3aFNJ3uF3hddeoFg1H038wZr/xi8/rX27M1Vj2j9VH 0B8Olp4KUQw/hyO6kUxqkoojmzRpmzvlpZ0cUiZJo2bQIWnvScyHxFCv33kHe+YEIqoJlaQc JfKYlbCoubz+02E2A6bFD9+BvCY0LBbEj5POwyKGiDMjHKCGuzSuDRbCn0Mz4kCa7nFMF5Jv piC+JemRdiBd6102ThqgIsyGEBXuf1sy0QIVyXgaqr9O2b/0VoXpQId7yY7OJuYYxs7kQoXI 6WzSMpmuXGkmfxOgbc/L6YbzB0JOriX0iRClxu4dEUg8Bs2pNnr6huY2Ft+qb41RzCJvvMyu gS32LfN0bTZ6Qm2A8ayMtUQgnwZDSO23OKgQWZVglGliY3ezHZ6lVwC24Vjkmq/2yBSLakZE 6DZUjZzCW1nvtRK05ebyK6tofRsx8xB8pL/kcBb9nCuh70aLR+5cmE41X4O+MVJbwfP5s/RW 9BFSL3qgXuXso/3XuWTQjJJGgKhB6xXjMmb1J4q/h5IuVV4juv1Fem9sfmyrh+Wi5V1IzKI7 RPJ3KVb937eBgSENk53P0gUorwzUcO+ASEo3Z1cBKkJSPigDbeEjVfXQMzNt0oDRzpQqH2vp apo2jHnidWt8BsckuWZpxcZ9+/9obQ55DyVQHGiTN39hkETy3Emdnz1JVHTU0Q== Message-ID: Date: Thu, 25 Jun 2020 13:41:02 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit On 6/25/20 1:19 PM, Ard Biesheuvel wrote: > On 6/25/20 10:45 AM, Philippe Mathieu-Daudé via groups.io wrote: >> Hi Sami, >> >> On 6/24/20 3:34 PM, Sami Mujawar wrote: >>> Kvmtool places the base address of the CFI flash in >>> the device tree it passes to UEFI. This library >>> parses the kvmtool device tree to read the CFI base >>> address and initialise the PCDs use by the NOR flash >>> driver and the variable storage. >>> >>> UEFI takes ownership of the CFI flash hardware, and >>> exposes its functionality through the UEFI Runtime >>> Variable Service. Therefore, disable the device tree >>> node for the CFI flash used for storing the UEFI >>> variables, to prevent the OS from attaching its device >>> driver as well. >>> >>> Signed-off-by: Sami Mujawar >>> Acked-by: Laszlo Ersek >>> --- >>> >>> Notes: >>>      v3: >>>        - ASSERT is sufficient to test Locating                     [Ard] >>>          gFdtClientProtocolGuid as DEPEX ensures that this is >>>          guaranteed to succeed. >>>        - Removed additional error handling based on review         >>> [Sami] >>>          feedback. >>>        - Fix confusion caused by use of macro MAX_FLASH_BANKS.     >>> [Philippe] >>>        - Renamed MAX_FLASH_BANKS to MAX_FLASH_DEVICES.             >>> [Sami] >>>        - Use macro to define block size for flash.                 >>> [Philippe] >>>        - Defined macro KVMTOOL_NOR_BLOCK_SIZE and also configured  >>> [Sami] >>>          to reflect the correct block size 64KB. >>>        - Disable the DT flash node used for UEFI variable storage  >>> [Sami] >>>          as UEFI takes ownership of the flash device. >>>          Ref: https://edk2.groups.io/g/devel/topic/74200914#60341 >>>           v2: >>>        - Library to read CFI flash base address from DT and >>> initialise [Sami] >>>          PCDs used for NOR flash variables. >>> >>>   ArmVirtPkg/Library/NorFlashKvmtoolLib/NorFlashKvmtool.c      | 330 >>> ++++++++++++++++++++ >>>   ArmVirtPkg/Library/NorFlashKvmtoolLib/NorFlashKvmtoolLib.inf |  49 +++ >>>   2 files changed, 379 insertions(+) >>> >>> diff --git a/ArmVirtPkg/Library/NorFlashKvmtoolLib/NorFlashKvmtool.c >>> b/ArmVirtPkg/Library/NorFlashKvmtoolLib/NorFlashKvmtool.c >>> new file mode 100644 >>> index >>> 0000000000000000000000000000000000000000..8e9dcf31691b4b12b9c7bac1ad4ba8d3a534a1d8 >>> >>> --- /dev/null >>> +++ b/ArmVirtPkg/Library/NorFlashKvmtoolLib/NorFlashKvmtool.c >>> @@ -0,0 +1,330 @@ >>> +/** @file >>> +   An instance of the NorFlashPlatformLib for Kvmtool platform. >>> + >>> + Copyright (c) 2020, ARM Ltd. All rights reserved.
>>> + >>> + SPDX-License-Identifier: BSD-2-Clause-Patent >>> + >>> + **/ >>> + >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> + >>> +/** Macro defining the NOR block size configured in Kvmtool. >>> +*/ >>> +#define KVMTOOL_NOR_BLOCK_SIZE  SIZE_64KB >>> + >>> +/** Macro defining the maximum number of Flash devices. >>> +*/ >>> +#define MAX_FLASH_DEVICES       4 >> >> I am sorry but I am still confused... >> >> This is about the QEMU Virt machine, right? >> >> This machine was supposed to have 1 single flash, see QEMU commit >> f5fdcd6e58 ("hw/arm: Add 'virt' platform") from Nov 2013: >> >>    /* Addresses and sizes of our components. >>     * 0..128MB is space for a flash device so we can run bootrom code >> such as UEFI. >>     ... >> >> Due to limitations in the QEMU cfi-flash model, instead of using >> a single flash device (with proper sector/bank protection), two >> devices were added in QEMU commit acf82361c6 ("hw/arm/virt: Provide >> flash devices for boot ROMs") Sep 2014: >> >>      Add two flash devices to the virt board, so that it can be used for >>      running guests which want a bootrom image such as UEFI. We provide >>      two flash devices to make it more convenient to provide both a >>      read-only UEFI image and a read-write place to store guest-set >>      UEFI config variables. The '-bios' command line option is set up >>      to provide an image for the first of the two flash devices. >> >> What do you declare maximum 4 devices? >> > > Kvmtool != QEMU, so whatever QEMU does is irrelevant for this series. > Ah, I feel relieved, thanks :)