xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: Julien Grall <julien@xen.org>
Cc: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
	"Andrew Cooper" <andrew.cooper3@citrix.com>,
	"Wei Liu" <wl@xen.org>, "Roger Pau Monné" <roger.pau@citrix.com>,
	"Volodymyr Babchuk" <volodymyr_babchuk@epam.com>,
	"Henry Wang" <Henry.Wang@arm.com>,
	"Bertrand Marquis" <Bertrand.Marquis@arm.com>,
	"Stefano Stabellini" <sstabellini@kernel.org>
Subject: Re: [PATCH][4.17] EFI: don't convert memory marked for runtime use to ordinary RAM
Date: Thu, 6 Oct 2022 10:39:06 +0200	[thread overview]
Message-ID: <7d152954-4f5a-2833-f974-442c15f4e8b9@suse.com> (raw)
In-Reply-To: <3b3f6e1c-4f41-6b1e-b226-f0dd515d14ca@xen.org>

On 05.10.2022 20:09, Julien Grall wrote:
> Hi Jan,
> 
> On 05/10/2022 12:55, Jan Beulich wrote:
>> On 05.10.2022 12:44, Julien Grall wrote:
>>> On 04/10/2022 16:58, Jan Beulich wrote:
>>>> On 30.09.2022 14:51, Bertrand Marquis wrote:
>>>>>> On 30 Sep 2022, at 09:50, Jan Beulich <jbeulich@suse.com> wrote:
>>>>>>
>>>>>> efi_init_memory() in both relevant places is treating EFI_MEMORY_RUNTIME
>>>>>> higher priority than the type of the range. To avoid accessing memory at
>>>>>> runtime which was re-used for other purposes, make
>>>>>> efi_arch_process_memory_map() follow suit. While on x86 in theory the
>>>>>> same would apply to EfiACPIReclaimMemory, we don't actually "reclaim"
>>>>>> E820_ACPI memory there and hence that type's handling can be left alone.
>>>>>>
>>>>>> Fixes: bf6501a62e80 ("x86-64: EFI boot code")
>>>>>> Fixes: facac0af87ef ("x86-64: EFI runtime code")
>>>>>> Fixes: 6d70ea10d49f ("Add ARM EFI boot support")
>>>>>> Signed-off-by: Jan Beulich <jbeulich@suse.com>
>>>>>
>>>>> Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com> #arm
>>>>
>>>> Thanks. However ...
>>>>
>>>>>> ---
>>>>>> Partly RFC for Arm, for two reasons:
>>>>>>
>>>>>> On Arm I question the conversion of EfiACPIReclaimMemory, in two ways:
>>>>>> For one like on x86 such ranges would likely better be retained, as Dom0
>>>>>> may (will?) have a need to look at tables placed there. Plus converting
>>>>>> such ranges to RAM even if EFI_MEMORY_WB is not set looks suspicious to
>>>>>> me as well. I'd be inclined to make the latter adjustment right here
>>>>>> (while the other change probably would better be separate, if there
>>>>>> aren't actually reasons for the present behavior).
>>>>
>>>> ... any views on this WB aspect at least (also Stefano or Julien)? Would be
>>>> good to know before I send v2.
>>>
>>> I don't quite understand what you are questioning here. Looking at the
>>> code, EfiACPIReclaimMemory will not be converted to RAM but added in a
>>> separate array.
>>>
>>> Furthermore, all the EfiACPIReclaimMemory regions will be passed to dom0
>>> (see acpi_create_efi_mmap_table()).
>>>
>>> So to me the code looks correct.
>>
>> Oh, I've indeed not paid enough attention to the first argument passed
>> to meminfo_add_bank(). I'm sorry for the extra noise. However, the
>> question I wanted to have addressed before sending out v3 was that
>> regarding the present using of memory when EFI_MEMORY_WB is not set.
>> Is that correct for the EfiACPIReclaimMemory case, i.e. is the
>> consumer (Dom0) aware that there might be a restriction?
> 
> Looking at the code, we always set EFI_MEMORY_WB for the reclaimable 
> region and the stage-2 mapping will be cachable.
> 
> So it looks like there would be a mismatch if EFI_MEMORY_WB is not set. 
> However, given the region is reclaimable, shouldn't this imply that the 
> flag is always set?

Possibly (but then again consider [perhaps hypothetical] systems with e.g.
just WT caches, where specifying WB simply wouldn't make sense). In any
event, even if that's the case, being on the safe side and doing

        if ( (desc_ptr->Attribute & EFI_MEMORY_RUNTIME) ||
             !(desc_ptr->Attribute & EFI_MEMORY_WB) )
            /* nothing */;
        else if ( ...

would seem better to me. However, if the mapping you mention above
would be adjusted and ...

>> And would
>> this memory then be guaranteed to never be freed into the general pool
>> of RAM pages?
> 
> The region is not treated as RAM by Xen and not owned by the dom0. 
> Therefore, it should not be possible to free the page because 
> get_page_from_gfn() would not be able to get a reference.

... the space cannot become ordinary RAM, then such a precaution
wouldn't be necessary. After all hiding EfiACPIReclaimMemory from
Dom0 just because it can't be mapped WB wouldn't be very nice
either. I guess I'll submit v2 with this part of the change left
as it was.

Jan


  reply	other threads:[~2022-10-06  8:39 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-30  7:50 [PATCH][4.17] EFI: don't convert memory marked for runtime use to ordinary RAM Jan Beulich
2022-09-30 11:55 ` Bertrand Marquis
2022-09-30 12:47 ` Luca Fancellu
2022-09-30 12:51 ` Bertrand Marquis
2022-10-04 15:58   ` Jan Beulich
2022-10-05 10:44     ` Julien Grall
2022-10-05 11:55       ` Jan Beulich
2022-10-05 18:09         ` Julien Grall
2022-10-06  8:39           ` Jan Beulich [this message]
2022-10-06 14:11             ` Jan Beulich
2022-10-08 19:08               ` Julien Grall
2022-10-10  6:20                 ` Jan Beulich
2022-10-10 23:58                   ` Stefano Stabellini
2022-10-11  7:52                     ` Bertrand Marquis
2022-09-30 12:53 ` Andrew Cooper
2022-09-30 13:07   ` Jan Beulich
2022-09-30 13:35   ` Bertrand Marquis
2022-09-30 14:28 ` Roger Pau Monné
2022-10-04  8:06   ` Jan Beulich
2022-10-04  9:33     ` Roger Pau Monné
2022-10-04 10:23       ` Jan Beulich
2022-10-04 10:38         ` Roger Pau Monné
2022-10-04 10:44           ` Jan Beulich
2022-10-04 10:54             ` Roger Pau Monné
2022-10-04 12:18               ` Jan Beulich
2022-10-04 12:52                 ` Roger Pau Monné
2022-10-04 13:10                   ` Jan Beulich
2022-10-04 14:01                     ` Roger Pau Monné
2022-10-04 14:39                       ` Jan Beulich
2022-10-04 15:20                         ` Roger Pau Monné
2022-10-04 15:55                           ` Jan Beulich
2022-10-04 10:49         ` Andrew Cooper
2022-10-04 11:09           ` Jan Beulich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7d152954-4f5a-2833-f974-442c15f4e8b9@suse.com \
    --to=jbeulich@suse.com \
    --cc=Bertrand.Marquis@arm.com \
    --cc=Henry.Wang@arm.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=julien@xen.org \
    --cc=roger.pau@citrix.com \
    --cc=sstabellini@kernel.org \
    --cc=volodymyr_babchuk@epam.com \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).