Skip to contentSkip to conversation

[4.17] EFI: don't convert memory marked for runtime use to ordinary RAM

PATCH Superseded Jan Beulich 8 participants 33 messages Sep 30, 2022 – Oct 11, 2022

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 [4.17] EFI: don't convert memory marked for runtime use to ordinary RAM

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")

---
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).

On Arm efi_init_memory() is compiled out, so adjusting Arm code here is perhaps more for consistency (not leaving a trap for someone to later fall into) than a strict requirement. I wonder though how Arm has managed to get away without at least some parts of efi_init_memory() for all the years that ACPI support has been present there. I guess this is connected to most of runtime.c also being compiled out, but that continuing to be the case is another aspect puzzling me.

xen/arch/arm/efi/efi-boot.h +9 -7
@@ -183,13 +183,15 @@ static EFI_STATUS __init efi_process_mem
 
     for ( Index = 0; Index < (mmap_size / desc_size); Index++ )
     {
-        if ( desc_ptr->Attribute & EFI_MEMORY_WB &&
-             (desc_ptr->Type == EfiConventionalMemory ||
-              desc_ptr->Type == EfiLoaderCode ||
-              desc_ptr->Type == EfiLoaderData ||
-              (!map_bs &&
-               (desc_ptr->Type == EfiBootServicesCode ||
-                desc_ptr->Type == EfiBootServicesData))) )
+        if ( desc_ptr->Attribute & EFI_MEMORY_RUNTIME )
+            /* nothing */;
+        else if ( (desc_ptr->Attribute & EFI_MEMORY_WB) &&
+                  (desc_ptr->Type == EfiConventionalMemory ||
+                   desc_ptr->Type == EfiLoaderCode ||
+                   desc_ptr->Type == EfiLoaderData ||
+                   (!map_bs &&
+                    (desc_ptr->Type == EfiBootServicesCode ||
+                     desc_ptr->Type == EfiBootServicesData))) )
         {
             if ( !meminfo_add_bank(&bootinfo.mem, desc_ptr) )
             {
xen/arch/x86/efi/efi-boot.h +3 -1
@@ -185,7 +185,9 @@ static void __init efi_arch_process_memo
             /* fall through */
         case EfiLoaderCode:
         case EfiLoaderData:
-            if ( desc->Attribute & EFI_MEMORY_WB )
+            if ( desc->Attribute & EFI_MEMORY_RUNTIME )
+                type = E820_RESERVED;
+            else if ( desc->Attribute & EFI_MEMORY_WB )
                 type = E820_RAM;
             else
         case EfiUnusableMemory:
#1 lore raw

Hi Jan,

We will review and test the arm part (even though it is modifying some unused
code at the moment) but I wanted to answer you on some questions you have ..

Quoted 24 lines · Jan Beulich

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")

---
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).

Quoted 7 lines

On Arm efi_init_memory() is compiled out, so adjusting Arm code here is perhaps more for consistency (not leaving a trap for someone to later fall into) than a strict requirement. I wonder though how Arm has managed to get away without at least some parts of efi_init_memory() for all the years that ACPI support has been present there. I guess this is connected to most of runtime.c also being compiled out, but that continuing to be the case is another aspect puzzling me.

On arm we only use the boot services in Xen and we do not provide any efi services to dom0. The required info is passed through a simple device tree.
There was a discussion on that subject some weeks ago and it is still an open point to be solved.
Also APCI is officially unsupported on arm.

Cheers
Bertrand

Quoted 39 lines
xen/arch/arm/efi/efi-boot.h +9 -7
@@ -183,13 +183,15 @@ static EFI_STATUS __init efi_process_mem
 
    for ( Index = 0; Index < (mmap_size / desc_size); Index++ )
    {
-        if ( desc_ptr->Attribute & EFI_MEMORY_WB &&
-             (desc_ptr->Type == EfiConventionalMemory ||
-              desc_ptr->Type == EfiLoaderCode ||
-              desc_ptr->Type == EfiLoaderData ||
-              (!map_bs &&
-               (desc_ptr->Type == EfiBootServicesCode ||
-                desc_ptr->Type == EfiBootServicesData))) )
+        if ( desc_ptr->Attribute & EFI_MEMORY_RUNTIME )
+            /* nothing */;
+        else if ( (desc_ptr->Attribute & EFI_MEMORY_WB) &&
+                  (desc_ptr->Type == EfiConventionalMemory ||
+                   desc_ptr->Type == EfiLoaderCode ||
+                   desc_ptr->Type == EfiLoaderData ||
+                   (!map_bs &&
+                    (desc_ptr->Type == EfiBootServicesCode ||
+                     desc_ptr->Type == EfiBootServicesData))) )
        {
            if ( !meminfo_add_bank(&bootinfo.mem, desc_ptr) )
            {
xen/arch/x86/efi/efi-boot.h +3 -1
@@ -185,7 +185,9 @@ static void __init efi_arch_process_memo
            /* fall through */
        case EfiLoaderCode:
        case EfiLoaderData:
-            if ( desc->Attribute & EFI_MEMORY_WB )
+            if ( desc->Attribute & EFI_MEMORY_RUNTIME )
+                type = E820_RESERVED;
+            else if ( desc->Attribute & EFI_MEMORY_WB )
                type = E820_RAM;
            else
        case EfiUnusableMemory:
Reviewed-by Tested-by on v1 1/1
#2 lore raw
In reply to Jan Beulich
Quoted 11 lines · Jan Beulich

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.

Quoted 5 lines
Fixes bf6501a62e80 ("x86-64: EFI boot code")
Fixes facac0af87ef ("x86-64: EFI runtime code")
Fixes 6d70ea10d49f ("Add ARM EFI boot support")

---

Hi Jan,

For the Arm part:

I’ve also tested the EFI+ACPI boot on two arm boards

Reviewed-by on v1 1/1
#3 lore raw
In reply to Jan Beulich

Hi Jan,

Quoted 9 lines · Jan Beulich

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.

Quoted 4 lines
Fixes bf6501a62e80 ("x86-64: EFI boot code")
Fixes facac0af87ef ("x86-64: EFI runtime code")
Fixes 6d70ea10d49f ("Add ARM EFI boot support")

Cheers
Bertrand

Quoted 57 lines

---
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).

On Arm efi_init_memory() is compiled out, so adjusting Arm code here is perhaps more for consistency (not leaving a trap for someone to later fall into) than a strict requirement. I wonder though how Arm has managed to get away without at least some parts of efi_init_memory() for all the years that ACPI support has been present there. I guess this is connected to most of runtime.c also being compiled out, but that continuing to be the case is another aspect puzzling me.

xen/arch/arm/efi/efi-boot.h +9 -7
@@ -183,13 +183,15 @@ static EFI_STATUS __init efi_process_mem
 
    for ( Index = 0; Index < (mmap_size / desc_size); Index++ )
    {
-        if ( desc_ptr->Attribute & EFI_MEMORY_WB &&
-             (desc_ptr->Type == EfiConventionalMemory ||
-              desc_ptr->Type == EfiLoaderCode ||
-              desc_ptr->Type == EfiLoaderData ||
-              (!map_bs &&
-               (desc_ptr->Type == EfiBootServicesCode ||
-                desc_ptr->Type == EfiBootServicesData))) )
+        if ( desc_ptr->Attribute & EFI_MEMORY_RUNTIME )
+            /* nothing */;
+        else if ( (desc_ptr->Attribute & EFI_MEMORY_WB) &&
+                  (desc_ptr->Type == EfiConventionalMemory ||
+                   desc_ptr->Type == EfiLoaderCode ||
+                   desc_ptr->Type == EfiLoaderData ||
+                   (!map_bs &&
+                    (desc_ptr->Type == EfiBootServicesCode ||
+                     desc_ptr->Type == EfiBootServicesData))) )
        {
            if ( !meminfo_add_bank(&bootinfo.mem, desc_ptr) )
            {
xen/arch/x86/efi/efi-boot.h +3 -1
@@ -185,7 +185,9 @@ static void __init efi_arch_process_memo
            /* fall through */
        case EfiLoaderCode:
        case EfiLoaderData:
-            if ( desc->Attribute & EFI_MEMORY_WB )
+            if ( desc->Attribute & EFI_MEMORY_RUNTIME )
+                type = E820_RESERVED;
+            else if ( desc->Attribute & EFI_MEMORY_WB )
                type = E820_RAM;
            else
        case EfiUnusableMemory:
#4 lore raw
Quoted 9 lines · Bertrand Marquis
Quoted 9 lines · Jan Beulich

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.

Quoted 6 lines
Quoted 4 lines
Fixes bf6501a62e80 ("x86-64: EFI boot code")
Fixes facac0af87ef ("x86-64: EFI runtime code")
Fixes 6d70ea10d49f ("Add ARM EFI boot support")

Thanks. However ...

Quoted 10 lines
Quoted 10 lines

---
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.

Jan

#5 lore raw

Hi Jan,

Quoted 30 lines · Jan Beulich
Quoted 9 lines · Bertrand Marquis
Quoted 9 lines · Jan Beulich

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.

Quoted 6 lines
Quoted 4 lines
Fixes bf6501a62e80 ("x86-64: EFI boot code")
Fixes facac0af87ef ("x86-64: EFI runtime code")
Fixes 6d70ea10d49f ("Add ARM EFI boot support")

Thanks. However ...

Quoted 10 lines
Quoted 10 lines

---
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).

Quoted 2 lines

... 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.

Cheers,

Signature · 1 line
Julien Grall
#6 lore raw
Quoted 34 lines · Julien Grall
Quoted 30 lines · Jan Beulich
Quoted 9 lines · Bertrand Marquis
Quoted 9 lines · Jan Beulich

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.

Quoted 6 lines
Quoted 4 lines
Fixes bf6501a62e80 ("x86-64: EFI boot code")
Fixes facac0af87ef ("x86-64: EFI runtime code")
Fixes 6d70ea10d49f ("Add ARM EFI boot support")

Thanks. However ...

Quoted 10 lines
Quoted 10 lines

---
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).

Quoted 2 lines

... any views on this WB aspect at least (also Stefano or Julien)? Would be good to know before I send v2.

Quoted 8 lines

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? And would this memory then be guaranteed to never be freed into the general pool of RAM pages?

Jan

#7 lore raw

Hi Jan,

Quoted 42 lines · Jan Beulich
Quoted 41 lines · Julien Grall
Quoted 30 lines · Jan Beulich
Quoted 9 lines · Bertrand Marquis
Quoted 9 lines · Jan Beulich

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.

Quoted 6 lines
Quoted 4 lines
Fixes bf6501a62e80 ("x86-64: EFI boot code")
Fixes facac0af87ef ("x86-64: EFI runtime code")
Fixes 6d70ea10d49f ("Add ARM EFI boot support")

Thanks. However ...

Quoted 10 lines
Quoted 10 lines

---
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).

Quoted 2 lines

... 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()).

Quoted 8 lines
Quoted 1 line

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?

Quoted 3 lines

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.

Cheers,

Signature · 1 line
Julien Grall
#8 lore raw
Quoted 54 lines · Julien Grall

Hi Jan,

Quoted 42 lines · Jan Beulich
Quoted 41 lines · Julien Grall
Quoted 30 lines · Jan Beulich
Quoted 9 lines · Bertrand Marquis
Quoted 9 lines · Jan Beulich

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.

Quoted 6 lines
Quoted 4 lines
Fixes bf6501a62e80 ("x86-64: EFI boot code")
Fixes facac0af87ef ("x86-64: EFI runtime code")
Fixes 6d70ea10d49f ("Add ARM EFI boot support")

Thanks. However ...

Quoted 10 lines
Quoted 10 lines

---
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).

Quoted 2 lines

... 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()).

Quoted 8 lines
Quoted 1 line

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?

Quoted 6 lines

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 ...

Quoted 7 lines
Quoted 3 lines

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

#9 lore raw
Quoted 82 lines · Jan Beulich
Quoted 54 lines · Julien Grall

Hi Jan,

Quoted 42 lines · Jan Beulich
Quoted 41 lines · Julien Grall
Quoted 30 lines · Jan Beulich
Quoted 9 lines · Bertrand Marquis
Quoted 9 lines · Jan Beulich

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.

Quoted 6 lines
Quoted 4 lines
Fixes bf6501a62e80 ("x86-64: EFI boot code")
Fixes facac0af87ef ("x86-64: EFI runtime code")
Fixes 6d70ea10d49f ("Add ARM EFI boot support")

Thanks. However ...

Quoted 10 lines
Quoted 10 lines

---
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).

Quoted 2 lines

... 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()).

Quoted 8 lines
Quoted 1 line

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?

Quoted 6 lines

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 ...

Quoted 7 lines
Quoted 3 lines

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.

Quoted 5 lines

... 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.

And while already in the process of committing the patch I came to realize that if the WB conditional isn't supposed to move, isn't the change done for Arm then wrong as well? Shouldn't it then be

        if ( !(desc_ptr->Attribute & EFI_MEMORY_RUNTIME) &&
             (desc_ptr->Attribute & EFI_MEMORY_WB) &&
             (desc_ptr->Type == EfiConventionalMemory ||
             ...

leaving the EfiACPIReclaimMemory case entirely unaffected by the change?

Jan

#10 lore raw

Hi Jan,

Quoted 10 lines · Jan Beulich
Quoted 5 lines

... 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.

And while already in the process of committing the patch I came to realize that if the WB conditional isn't supposed to move, isn't the change done for Arm then wrong as well? Shouldn't it then be

Quoted 7 lines
         if ( !(desc_ptr->Attribute & EFI_MEMORY_RUNTIME) &&
              (desc_ptr->Attribute & EFI_MEMORY_WB) &&
              (desc_ptr->Type == EfiConventionalMemory ||
              ...

leaving the EfiACPIReclaimMemory case entirely unaffected by the change?

IIUC, the concern is the region EfiACPIReclaimMemory could have the attribute EFI_MEMORY_RUNTIME. Is that correct?

Given that the memory is reclaimable, I am not sure why it can also have this atribute set (to me it means the opposite). But I guess for hardening purpose it would be better to use the version you just suggested.

Bertrand, Stefano, what do you think?

Cheers,

Signature · 1 line
Julien Grall
#11 lore raw
Quoted 16 lines · Julien Grall
Quoted 15 lines · Jan Beulich
Quoted 5 lines

... 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.

And while already in the process of committing the patch I came to realize that if the WB conditional isn't supposed to move, isn't the change done for Arm then wrong as well? Shouldn't it then be

         if ( !(desc_ptr->Attribute & EFI_MEMORY_RUNTIME) && (desc_ptr->Attribute & EFI_MEMORY_WB) && (desc_ptr->Type == EfiConventionalMemory ||
              ...

Quoted 4 lines
Quoted 2 lines

leaving the EfiACPIReclaimMemory case entirely unaffected by the change?

IIUC, the concern is the region EfiACPIReclaimMemory could have the attribute EFI_MEMORY_RUNTIME. Is that correct?

Yes, ...

Quoted 1 line

Given that the memory is reclaimable, I am not sure why it can also have this atribute set (to me it means the opposite).

... at least on x86 all sorts of strange/bogus type/attribute combinations have been observed.

Jan

Quoted 6 lines

But I guess for hardening purpose it would be better to use the version you just suggested.

Bertrand, Stefano, what do you think?

Cheers,

#12 lore raw
Quoted 20 lines · Jan Beulich
Quoted 19 lines · Julien Grall
Quoted 17 lines · Jan Beulich
Quoted 5 lines

... 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.

And while already in the process of committing the patch I came to realize that if the WB conditional isn't supposed to move, isn't the change done for Arm then wrong as well? Shouldn't it then be

         if ( !(desc_ptr->Attribute & EFI_MEMORY_RUNTIME) && (desc_ptr->Attribute & EFI_MEMORY_WB) && (desc_ptr->Type == EfiConventionalMemory ||
              ...

leaving the EfiACPIReclaimMemory case entirely unaffected by the change?

Quoted 8 lines
Quoted 1 line

IIUC, the concern is the region EfiACPIReclaimMemory could have the attribute EFI_MEMORY_RUNTIME. Is that correct?

Yes, ...

Quoted 1 line

Given that the memory is reclaimable, I am not sure why it can also have this atribute set (to me it means the opposite).

... at least on x86 all sorts of strange/bogus type/attribute combinations have been observed.

Yeah... it is a good idea to be able to cope with strange and bogus firmware tables as it is known to happen

#13 lore raw

Hi,

Quoted 27 lines · Stefano Stabellini
Quoted 24 lines · Jan Beulich
Quoted 16 lines · Julien Grall
Quoted 15 lines · Jan Beulich
Quoted 5 lines

... 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.

And while already in the process of committing the patch I came to realize that if the WB conditional isn't supposed to move, isn't the change done for Arm then wrong as well? Shouldn't it then be

         if ( !(desc_ptr->Attribute & EFI_MEMORY_RUNTIME) &&
              (desc_ptr->Attribute & EFI_MEMORY_WB) &&
              (desc_ptr->Type == EfiConventionalMemory ||
              ...
Quoted 4 lines
Quoted 2 lines

leaving the EfiACPIReclaimMemory case entirely unaffected by the change?

IIUC, the concern is the region EfiACPIReclaimMemory could have the attribute EFI_MEMORY_RUNTIME. Is that correct?

Yes, ...

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Given that the memory is reclaimable, I am not sure why it can also have this atribute set (to me it means the opposite).

... at least on x86 all sorts of strange/bogus type/attribute combinations have been observed.

Yeah... it is a good idea to be able to cope with strange and bogus firmware tables as it is known to happen

I agree with that but if we make an assumption that something is bogus, we should at least warn the user if possible.

Bertrand

#14 lore raw
In reply to Jan Beulich
Quoted 11 lines · Jan Beulich

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")

Isn't this also liable to be the root cause of the crash reported on IRC, where a read-only page was being inserted into the heap?

~Andrew

#15 lore raw
Quoted 8 lines · Andrew Cooper
Quoted 7 lines · Jan Beulich

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.

Quoted 7 lines
Quoted 4 lines
Fixes bf6501a62e80 ("x86-64: EFI boot code")
Fixes facac0af87ef ("x86-64: EFI runtime code")
Fixes 6d70ea10d49f ("Add ARM EFI boot support")

Isn't this also liable to be the root cause of the crash reported on IRC, where a read-only page was being inserted into the heap?

I wouldn't be able to make the connection, I'm afraid. What was asked there was lacking details, though.

Jan

#16 lore raw
In reply to Andrew Cooper

Hi Andrew,

Quoted 10 lines · Andrew Cooper
Quoted 7 lines · Jan Beulich

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.

Quoted 7 lines
Quoted 4 lines
Fixes bf6501a62e80 ("x86-64: EFI boot code")
Fixes facac0af87ef ("x86-64: EFI runtime code")
Fixes 6d70ea10d49f ("Add ARM EFI boot support")

Isn't this also liable to be the root cause of the crash reported on IRC, where a read-only page was being inserted into the heap?

No this should not be related at all.

Cheers
Bertrand

Quoted 2 lines

~Andrew

#17 lore raw
In reply to Jan Beulich
Quoted 6 lines · Jan Beulich

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.

What about dom0? Should it be translated to E820_RESERVED so that dom0 doesn't try to use it either? I guess using E820_RESERVED could also confuse dom0 about ACPI data placement.

Thanks, Roger.

#18 lore raw
Quoted 10 lines · Roger Pau Monné
Quoted 6 lines · Jan Beulich

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.

What about dom0? Should it be translated to E820_RESERVED so that dom0 doesn't try to use it either?

I'm afraid I don't understand the questions. Not the least because I think "it" can't really mean "dom0" from the earlier sentence.

Jan

Quoted 4 lines

I guess using E820_RESERVED
could also confuse dom0 about ACPI data placement.

Thanks, Roger.

#19 lore raw
Quoted 9 lines · Jan Beulich
Quoted 8 lines · Roger Pau Monné
Quoted 6 lines · Jan Beulich

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.

Quoted 5 lines
Quoted 2 lines

What about dom0? Should it be translated to E820_RESERVED so that dom0 doesn't try to use it either?

I'm afraid I don't understand the questions. Not the least because I think "it" can't really mean "dom0" from the earlier sentence.

Sorry, let me try again:

The memory map provided to dom0 will contain E820_ACPI entries for memory ranges with the EFI_MEMORY_RUNTIME attributes in the EFI memory map. Is there a risk from dom0 reclaiming such E820_ACPI ranges, overwriting the data needed for runtime services?

Thanks, Roger.

#20 lore raw
Quoted 16 lines · Roger Pau Monné
Quoted 9 lines · Jan Beulich
Quoted 8 lines · Roger Pau Monné
Quoted 6 lines · Jan Beulich

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.

Quoted 5 lines
Quoted 2 lines

What about dom0? Should it be translated to E820_RESERVED so that dom0 doesn't try to use it either?

I'm afraid I don't understand the questions. Not the least because I think "it" can't really mean "dom0" from the earlier sentence.

Quoted 6 lines

Sorry, let me try again:

The memory map provided to dom0 will contain E820_ACPI entries for memory ranges with the EFI_MEMORY_RUNTIME attributes in the EFI memory map. Is there a risk from dom0 reclaiming such E820_ACPI ranges, overwriting the data needed for runtime services?

How would Dom0 go about doing so? It has no control over what we hand to the page allocator - it can only free pages which were actually allocated to it. E820_ACPI and E820_RESERVED pages are assigned to DomIO - Dom0 can map and access them, but it cannot free them.

Jan

#21 lore raw
Quoted 24 lines · Jan Beulich
Quoted 16 lines · Roger Pau Monné
Quoted 9 lines · Jan Beulich
Quoted 8 lines · Roger Pau Monné
Quoted 6 lines · Jan Beulich

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.

Quoted 5 lines
Quoted 2 lines

What about dom0? Should it be translated to E820_RESERVED so that dom0 doesn't try to use it either?

I'm afraid I don't understand the questions. Not the least because I think "it" can't really mean "dom0" from the earlier sentence.

Quoted 6 lines

Sorry, let me try again:

The memory map provided to dom0 will contain E820_ACPI entries for memory ranges with the EFI_MEMORY_RUNTIME attributes in the EFI memory map. Is there a risk from dom0 reclaiming such E820_ACPI ranges, overwriting the data needed for runtime services?

Quoted 4 lines

How would Dom0 go about doing so? It has no control over what we hand to the page allocator - it can only free pages which were actually allocated to it. E820_ACPI and E820_RESERVED pages are assigned to DomIO - Dom0 can map and access them, but it cannot free them.

Maybe I'm very confused, but what about dom0 overwriting the data there, won't it cause issues to runtime services?

If the memory is reported in the memory map provided to dom0 as E820_ACPI dom0 is free to reclaim the region for it's own usage.

Thanks, Roger.

#22 lore raw
Quoted 25 lines · Roger Pau Monné
Quoted 24 lines · Jan Beulich
Quoted 22 lines · Roger Pau Monné
Quoted 9 lines · Jan Beulich
Quoted 8 lines · Roger Pau Monné
Quoted 6 lines · Jan Beulich

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.

Quoted 5 lines
Quoted 2 lines

What about dom0? Should it be translated to E820_RESERVED so that dom0 doesn't try to use it either?

I'm afraid I don't understand the questions. Not the least because I think "it" can't really mean "dom0" from the earlier sentence.

Sorry, let me try again:

The memory map provided to dom0 will contain E820_ACPI entries for memory ranges with the EFI_MEMORY_RUNTIME attributes in the EFI memory map. Is there a risk from dom0 reclaiming such E820_ACPI ranges, overwriting the data needed for runtime services?

Quoted 7 lines
Quoted 4 lines

How would Dom0 go about doing so? It has no control over what we hand to the page allocator - it can only free pages which were actually allocated to it. E820_ACPI and E820_RESERVED pages are assigned to DomIO - Dom0 can map and access them, but it cannot free them.

Maybe I'm very confused, but what about dom0 overwriting the data there, won't it cause issues to runtime services?

If it overwrites it, of course there are going to be issues. Just like there are going to be problems from anything else Dom0 does wrong.

Quoted 2 lines

If the memory is reported in the memory map provided to dom0 as E820_ACPI dom0 is free to reclaim the region for it's own usage.

Could you outline to me how such a "reclaim" process would look like? For the range to become ordinary RAM, Xen needs to be involved. But there's no hypercall allowing Dom0 to free a page which wasn't allocated to it. And the Dom0 kernel simply re-using the range as if it was RAM is flawed - it would break the latest once Dom0 would try to balloon out such a page.

Jan

#23 lore raw
Quoted 31 lines · Jan Beulich
Quoted 30 lines · Roger Pau Monné
Quoted 28 lines · Jan Beulich
Quoted 16 lines · Roger Pau Monné
Quoted 9 lines · Jan Beulich
Quoted 8 lines · Roger Pau Monné
Quoted 6 lines · Jan Beulich

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.

Quoted 5 lines
Quoted 2 lines

What about dom0? Should it be translated to E820_RESERVED so that dom0 doesn't try to use it either?

I'm afraid I don't understand the questions. Not the least because I think "it" can't really mean "dom0" from the earlier sentence.

Quoted 6 lines

Sorry, let me try again:

The memory map provided to dom0 will contain E820_ACPI entries for memory ranges with the EFI_MEMORY_RUNTIME attributes in the EFI memory map. Is there a risk from dom0 reclaiming such E820_ACPI ranges, overwriting the data needed for runtime services?

How would Dom0 go about doing so? It has no control over what we hand to the page allocator - it can only free pages which were actually allocated to it. E820_ACPI and E820_RESERVED pages are assigned to DomIO - Dom0 can map and access them, but it cannot free them.

Quoted 5 lines
Quoted 2 lines

Maybe I'm very confused, but what about dom0 overwriting the data there, won't it cause issues to runtime services?

If it overwrites it, of course there are going to be issues. Just like there are going to be problems from anything else Dom0 does wrong.

But would dom0 know it's doing something wrong?

The region is just marked as E820_ACPI from dom0 PoV, so it doesn't know it's required by EFI runtime services, and dom0 could legitimately overwrite the region once it considers all ACPI parsing done from it's side.

Thanks, Roger.

#24 lore raw
Quoted 32 lines · Roger Pau Monné
Quoted 31 lines · Jan Beulich
Quoted 30 lines · Roger Pau Monné
Quoted 28 lines · Jan Beulich
Quoted 16 lines · Roger Pau Monné
Quoted 9 lines · Jan Beulich
Quoted 8 lines · Roger Pau Monné
Quoted 6 lines · Jan Beulich

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.

Quoted 5 lines
Quoted 2 lines

What about dom0? Should it be translated to E820_RESERVED so that dom0 doesn't try to use it either?

I'm afraid I don't understand the questions. Not the least because I think "it" can't really mean "dom0" from the earlier sentence.

Quoted 6 lines

Sorry, let me try again:

The memory map provided to dom0 will contain E820_ACPI entries for memory ranges with the EFI_MEMORY_RUNTIME attributes in the EFI memory map. Is there a risk from dom0 reclaiming such E820_ACPI ranges, overwriting the data needed for runtime services?

How would Dom0 go about doing so? It has no control over what we hand to the page allocator - it can only free pages which were actually allocated to it. E820_ACPI and E820_RESERVED pages are assigned to DomIO - Dom0 can map and access them, but it cannot free them.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Maybe I'm very confused, but what about dom0 overwriting the data there, won't it cause issues to runtime services?

If it overwrites it, of course there are going to be issues. Just like there are going to be problems from anything else Dom0 does wrong.

But would dom0 know it's doing something wrong?

Yes. Please also see my reply to Andrew.

Quoted 4 lines

The region is just marked as E820_ACPI from dom0 PoV, so it doesn't know it's required by EFI runtime services, and dom0 could legitimately overwrite the region once it considers all ACPI parsing done from it's side.

PV Dom0 won't ever see E820_ACPI in the relevant E820 map; this type can only appear in the machine E820. In how far PVH Dom0 might need to take special care I can't tell right now (but at least for kexec purposes I expect Linux isn't going to recycle E820_ACPI regions even going forward).

Jan

#25 lore raw
Quoted 48 lines · Jan Beulich
Quoted 32 lines · Roger Pau Monné
Quoted 31 lines · Jan Beulich
Quoted 30 lines · Roger Pau Monné
Quoted 28 lines · Jan Beulich
Quoted 16 lines · Roger Pau Monné
Quoted 9 lines · Jan Beulich
Quoted 8 lines · Roger Pau Monné
Quoted 6 lines · Jan Beulich

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.

Quoted 5 lines
Quoted 2 lines

What about dom0? Should it be translated to E820_RESERVED so that dom0 doesn't try to use it either?

I'm afraid I don't understand the questions. Not the least because I think "it" can't really mean "dom0" from the earlier sentence.

Quoted 6 lines

Sorry, let me try again:

The memory map provided to dom0 will contain E820_ACPI entries for memory ranges with the EFI_MEMORY_RUNTIME attributes in the EFI memory map. Is there a risk from dom0 reclaiming such E820_ACPI ranges, overwriting the data needed for runtime services?

How would Dom0 go about doing so? It has no control over what we hand to the page allocator - it can only free pages which were actually allocated to it. E820_ACPI and E820_RESERVED pages are assigned to DomIO - Dom0 can map and access them, but it cannot free them.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Maybe I'm very confused, but what about dom0 overwriting the data there, won't it cause issues to runtime services?

If it overwrites it, of course there are going to be issues. Just like there are going to be problems from anything else Dom0 does wrong.

But would dom0 know it's doing something wrong?

Yes. Please also see my reply to Andrew.

Quoted 4 lines

The region is just marked as E820_ACPI from dom0 PoV, so it doesn't know it's required by EFI runtime services, and dom0 could legitimately overwrite the region once it considers all ACPI parsing done from it's side.

Quoted 4 lines

PV Dom0 won't ever see E820_ACPI in the relevant E820 map; this type can only appear in the machine E820. In how far PVH Dom0 might need to take special care I can't tell right now (but at least for kexec purposes I expect Linux isn't going to recycle E820_ACPI regions even going forward).

Even if unlikely, couldn't some dom0 OS look at the machine map after processing ACPI and just decide to overwrite the ACPI regions?

Not that it's useful from an OS PoV, but also we have no statement saying that E820_ACPI in the machine memory map shouldn't be overwritten.

Thanks, Roger.

#26 lore raw
Quoted 54 lines · Roger Pau Monné
Quoted 48 lines · Jan Beulich
Quoted 32 lines · Roger Pau Monné
Quoted 31 lines · Jan Beulich
Quoted 30 lines · Roger Pau Monné
Quoted 28 lines · Jan Beulich
Quoted 16 lines · Roger Pau Monné
Quoted 9 lines · Jan Beulich
Quoted 8 lines · Roger Pau Monné
Quoted 6 lines · Jan Beulich

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.

Quoted 5 lines
Quoted 2 lines

What about dom0? Should it be translated to E820_RESERVED so that dom0 doesn't try to use it either?

I'm afraid I don't understand the questions. Not the least because I think "it" can't really mean "dom0" from the earlier sentence.

Quoted 6 lines

Sorry, let me try again:

The memory map provided to dom0 will contain E820_ACPI entries for memory ranges with the EFI_MEMORY_RUNTIME attributes in the EFI memory map. Is there a risk from dom0 reclaiming such E820_ACPI ranges, overwriting the data needed for runtime services?

How would Dom0 go about doing so? It has no control over what we hand to the page allocator - it can only free pages which were actually allocated to it. E820_ACPI and E820_RESERVED pages are assigned to DomIO - Dom0 can map and access them, but it cannot free them.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Maybe I'm very confused, but what about dom0 overwriting the data there, won't it cause issues to runtime services?

If it overwrites it, of course there are going to be issues. Just like there are going to be problems from anything else Dom0 does wrong.

But would dom0 know it's doing something wrong?

Yes. Please also see my reply to Andrew.

Quoted 4 lines

The region is just marked as E820_ACPI from dom0 PoV, so it doesn't know it's required by EFI runtime services, and dom0 could legitimately overwrite the region once it considers all ACPI parsing done from it's side.

Quoted 4 lines

PV Dom0 won't ever see E820_ACPI in the relevant E820 map; this type can only appear in the machine E820. In how far PVH Dom0 might need to take special care I can't tell right now (but at least for kexec purposes I expect Linux isn't going to recycle E820_ACPI regions even going forward).

Quoted 6 lines

Even if unlikely, couldn't some dom0 OS look at the machine map after processing ACPI and just decide to overwrite the ACPI regions?

Not that it's useful from an OS PoV, but also we have no statement saying that E820_ACPI in the machine memory map shouldn't be overwritten.

There are many things we have no statements for, yet we imply certain behavior or restrictions. The machine memory map, imo, clearly isn't intended for this kind of use.

Jan

#27 lore raw
Quoted 58 lines · Jan Beulich
Quoted 57 lines · Roger Pau Monné
Quoted 48 lines · Jan Beulich
Quoted 32 lines · Roger Pau Monné
Quoted 31 lines · Jan Beulich
Quoted 30 lines · Roger Pau Monné
Quoted 28 lines · Jan Beulich
Quoted 16 lines · Roger Pau Monné
Quoted 9 lines · Jan Beulich
Quoted 8 lines · Roger Pau Monné
Quoted 6 lines · Jan Beulich

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.

Quoted 5 lines
Quoted 2 lines

What about dom0? Should it be translated to E820_RESERVED so that dom0 doesn't try to use it either?

I'm afraid I don't understand the questions. Not the least because I think "it" can't really mean "dom0" from the earlier sentence.

Quoted 6 lines

Sorry, let me try again:

The memory map provided to dom0 will contain E820_ACPI entries for memory ranges with the EFI_MEMORY_RUNTIME attributes in the EFI memory map. Is there a risk from dom0 reclaiming such E820_ACPI ranges, overwriting the data needed for runtime services?

How would Dom0 go about doing so? It has no control over what we hand to the page allocator - it can only free pages which were actually allocated to it. E820_ACPI and E820_RESERVED pages are assigned to DomIO - Dom0 can map and access them, but it cannot free them.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Maybe I'm very confused, but what about dom0 overwriting the data there, won't it cause issues to runtime services?

If it overwrites it, of course there are going to be issues. Just like there are going to be problems from anything else Dom0 does wrong.

But would dom0 know it's doing something wrong?

Yes. Please also see my reply to Andrew.

Quoted 4 lines

The region is just marked as E820_ACPI from dom0 PoV, so it doesn't know it's required by EFI runtime services, and dom0 could legitimately overwrite the region once it considers all ACPI parsing done from it's side.

Quoted 4 lines

PV Dom0 won't ever see E820_ACPI in the relevant E820 map; this type can only appear in the machine E820. In how far PVH Dom0 might need to take special care I can't tell right now (but at least for kexec purposes I expect Linux isn't going to recycle E820_ACPI regions even going forward).

Even if unlikely, couldn't some dom0 OS look at the machine map after processing ACPI and just decide to overwrite the ACPI regions?

Quoted 7 lines
Quoted 3 lines

Not that it's useful from an OS PoV, but also we have no statement saying that E820_ACPI in the machine memory map shouldn't be overwritten.

There are many things we have no statements for, yet we imply certain behavior or restrictions. The machine memory map, imo, clearly isn't intended for this kind of use.

There isn't much I can say then. I do feel we are creating rules out of thin air.

I do think the commit message should mention that we rely on dom0 not overwriting the data in the E820_ACPI regions on the machine memory map.

Thanks, Roger.

#28 lore raw
Quoted 67 lines · Roger Pau Monné
Quoted 58 lines · Jan Beulich
Quoted 57 lines · Roger Pau Monné
Quoted 48 lines · Jan Beulich
Quoted 32 lines · Roger Pau Monné
Quoted 31 lines · Jan Beulich
Quoted 30 lines · Roger Pau Monné
Quoted 28 lines · Jan Beulich
Quoted 16 lines · Roger Pau Monné
Quoted 9 lines · Jan Beulich
Quoted 8 lines · Roger Pau Monné
Quoted 6 lines · Jan Beulich

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.

Quoted 5 lines
Quoted 2 lines

What about dom0? Should it be translated to E820_RESERVED so that dom0 doesn't try to use it either?

I'm afraid I don't understand the questions. Not the least because I think "it" can't really mean "dom0" from the earlier sentence.

Quoted 6 lines

Sorry, let me try again:

The memory map provided to dom0 will contain E820_ACPI entries for memory ranges with the EFI_MEMORY_RUNTIME attributes in the EFI memory map. Is there a risk from dom0 reclaiming such E820_ACPI ranges, overwriting the data needed for runtime services?

How would Dom0 go about doing so? It has no control over what we hand to the page allocator - it can only free pages which were actually allocated to it. E820_ACPI and E820_RESERVED pages are assigned to DomIO - Dom0 can map and access them, but it cannot free them.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Maybe I'm very confused, but what about dom0 overwriting the data there, won't it cause issues to runtime services?

If it overwrites it, of course there are going to be issues. Just like there are going to be problems from anything else Dom0 does wrong.

But would dom0 know it's doing something wrong?

Yes. Please also see my reply to Andrew.

Quoted 4 lines

The region is just marked as E820_ACPI from dom0 PoV, so it doesn't know it's required by EFI runtime services, and dom0 could legitimately overwrite the region once it considers all ACPI parsing done from it's side.

Quoted 4 lines

PV Dom0 won't ever see E820_ACPI in the relevant E820 map; this type can only appear in the machine E820. In how far PVH Dom0 might need to take special care I can't tell right now (but at least for kexec purposes I expect Linux isn't going to recycle E820_ACPI regions even going forward).

Even if unlikely, couldn't some dom0 OS look at the machine map after processing ACPI and just decide to overwrite the ACPI regions?

Quoted 7 lines
Quoted 3 lines

Not that it's useful from an OS PoV, but also we have no statement saying that E820_ACPI in the machine memory map shouldn't be overwritten.

There are many things we have no statements for, yet we imply certain behavior or restrictions. The machine memory map, imo, clearly isn't intended for this kind of use.

Quoted 6 lines

There isn't much I can say then. I do feel we are creating rules out of thin air.

I do think the commit message should mention that we rely on dom0 not overwriting the data in the E820_ACPI regions on the machine memory map.

Hmm, am I getting it right that you think I need to add further justification for a change I'm _not_ making? And which, if we wanted to change our behavior, would require a similar change (or perhaps a change elsewhere) in E820 (i.e. non-EFI) handling? The modification I'm making is solely towards Xen's internal memory management. I'm really having a hard time seeing how commenting on expected Dom0 behavior would fit here (leaving aside that I'm still puzzled by both you and Andrew thinking that there's any whatsoever remote indication anywhere that Dom0 recycling E820_ACPI could be an okay thing in a PV Dom0 kernel). The more that marking EfiACPIReclaimMemory anything other than E820_ACPI might, as iirc you did say yourself, also confuse e.g. the ACPI subsystem of Dom0's kernel.

But well, would extending that sentence to "While on x86 in theory the same would apply to EfiACPIReclaimMemory, we don't actually "reclaim" E820_ACPI memory there (and it would be a bug if the Dom0 kernel tried to do so, bypassing Xen's memory management), hence that type's handling can be left alone" satisfy your request?

Jan

#29 lore raw
Quoted 71 lines · Jan Beulich
Quoted 70 lines · Roger Pau Monné
Quoted 58 lines · Jan Beulich
Quoted 57 lines · Roger Pau Monné
Quoted 48 lines · Jan Beulich
Quoted 32 lines · Roger Pau Monné
Quoted 31 lines · Jan Beulich
Quoted 30 lines · Roger Pau Monné
Quoted 28 lines · Jan Beulich
Quoted 16 lines · Roger Pau Monné
Quoted 9 lines · Jan Beulich
Quoted 8 lines · Roger Pau Monné
Quoted 6 lines · Jan Beulich

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.

Quoted 5 lines
Quoted 2 lines

What about dom0? Should it be translated to E820_RESERVED so that dom0 doesn't try to use it either?

I'm afraid I don't understand the questions. Not the least because I think "it" can't really mean "dom0" from the earlier sentence.

Quoted 6 lines

Sorry, let me try again:

The memory map provided to dom0 will contain E820_ACPI entries for memory ranges with the EFI_MEMORY_RUNTIME attributes in the EFI memory map. Is there a risk from dom0 reclaiming such E820_ACPI ranges, overwriting the data needed for runtime services?

How would Dom0 go about doing so? It has no control over what we hand to the page allocator - it can only free pages which were actually allocated to it. E820_ACPI and E820_RESERVED pages are assigned to DomIO - Dom0 can map and access them, but it cannot free them.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Maybe I'm very confused, but what about dom0 overwriting the data there, won't it cause issues to runtime services?

If it overwrites it, of course there are going to be issues. Just like there are going to be problems from anything else Dom0 does wrong.

But would dom0 know it's doing something wrong?

Yes. Please also see my reply to Andrew.

Quoted 4 lines

The region is just marked as E820_ACPI from dom0 PoV, so it doesn't know it's required by EFI runtime services, and dom0 could legitimately overwrite the region once it considers all ACPI parsing done from it's side.

Quoted 4 lines

PV Dom0 won't ever see E820_ACPI in the relevant E820 map; this type can only appear in the machine E820. In how far PVH Dom0 might need to take special care I can't tell right now (but at least for kexec purposes I expect Linux isn't going to recycle E820_ACPI regions even going forward).

Even if unlikely, couldn't some dom0 OS look at the machine map after processing ACPI and just decide to overwrite the ACPI regions?

Quoted 7 lines
Quoted 3 lines

Not that it's useful from an OS PoV, but also we have no statement saying that E820_ACPI in the machine memory map shouldn't be overwritten.

There are many things we have no statements for, yet we imply certain behavior or restrictions. The machine memory map, imo, clearly isn't intended for this kind of use.

There isn't much I can say then. I do feel we are creating rules out of thin air.

Quoted 6 lines
Quoted 3 lines

I do think the commit message should mention that we rely on dom0 not overwriting the data in the E820_ACPI regions on the machine memory map.

Hmm, am I getting it right that you think I need to add further justification for a change I'm _not_ making?

In the commit message you explicitly mentioned 'we don't actually "reclaim" E820_ACPI memory' and I assumed that "we" in the sentence to only include Xen. Now I see that the "we" there seems to include both Xen and the dom0 kernel. This wasn't clear to me at first sight.

Quoted 3 lines

And which, if we wanted
to change our behavior, would require a similar change (or perhaps a change elsewhere) in E820 (i.e. non-EFI) handling?

Why would that be required?

Without EFI dom0 should be fine in overwriting (some?) of the data in E820_ACPI regions once it's finished with all ACPI processing, as a region of type E820_ACPI is reclaimable and Xen won't try to access it once handled to dom0.

Quoted 4 lines

The modification
I'm making is solely towards Xen's internal memory management. I'm really having a hard time seeing how commenting on expected Dom0 behavior would fit here

The type in the e820 memory map also gets propagated to dom0 in the machine memory map hypercall, so it can have effect outside of Xen itself.

Quoted 6 lines

(leaving aside that I'm still puzzled by both
you and Andrew thinking that there's any whatsoever remote indication anywhere that Dom0 recycling E820_ACPI could be an okay thing in a PV Dom0 kernel). The more that marking EfiACPIReclaimMemory anything other than E820_ACPI might, as iirc you did say yourself, also confuse e.g. the ACPI subsystem of Dom0's kernel.

Indeed. There's no good way to convert a region of type EfiACPIReclaimMemory that has the EFI_MEMORY_RUNTIME attribute set, as there's no mapping to an e820 type.

One of the quirks of trying to retrofit an EFI memory map into e820 format.

Quoted 5 lines

But well, would extending that sentence to "While on x86 in theory the same would apply to EfiACPIReclaimMemory, we don't actually "reclaim" E820_ACPI memory there (and it would be a bug if the Dom0 kernel tried to do so, bypassing Xen's memory management), hence that type's handling can be left alone" satisfy your request?

I think that would indeed make it clearer.

Thanks, Roger.

#30 lore raw
Quoted 76 lines · Roger Pau Monné
Quoted 75 lines · Jan Beulich
Quoted 73 lines · Roger Pau Monné
Quoted 58 lines · Jan Beulich
Quoted 57 lines · Roger Pau Monné
Quoted 48 lines · Jan Beulich
Quoted 32 lines · Roger Pau Monné
Quoted 31 lines · Jan Beulich
Quoted 30 lines · Roger Pau Monné
Quoted 28 lines · Jan Beulich
Quoted 16 lines · Roger Pau Monné
Quoted 9 lines · Jan Beulich
Quoted 8 lines · Roger Pau Monné

On Fri, Sep 30, 2022 at 09:50:40AM +0200, Jan Beulich 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.

Quoted 5 lines
Quoted 2 lines

What about dom0? Should it be translated to E820_RESERVED so that
dom0 doesn't try to use it either?

I'm afraid I don't understand the questions. Not the least because I think "it" can't really mean "dom0" from the earlier sentence.

Quoted 6 lines

Sorry, let me try again:

The memory map provided to dom0 will contain E820_ACPI entries for memory ranges with the EFI_MEMORY_RUNTIME attributes in the EFI memory map. Is there a risk from dom0 reclaiming such E820_ACPI ranges, overwriting the data needed for runtime services?

How would Dom0 go about doing so? It has no control over what we hand to the page allocator - it can only free pages which were actually allocated to it. E820_ACPI and E820_RESERVED pages are assigned to DomIO - Dom0 can map and access them, but it cannot free them.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Maybe I'm very confused, but what about dom0 overwriting the data there, won't it cause issues to runtime services?

If it overwrites it, of course there are going to be issues. Just like there are going to be problems from anything else Dom0 does wrong.

But would dom0 know it's doing something wrong?

Yes. Please also see my reply to Andrew.

Quoted 4 lines

The region is just marked as E820_ACPI from dom0 PoV, so it doesn't know it's required by EFI runtime services, and dom0 could legitimately overwrite the region once it considers all ACPI parsing done from it's side.

Quoted 4 lines

PV Dom0 won't ever see E820_ACPI in the relevant E820 map; this type can only appear in the machine E820. In how far PVH Dom0 might need to take special care I can't tell right now (but at least for kexec purposes I expect Linux isn't going to recycle E820_ACPI regions even going forward).

Even if unlikely, couldn't some dom0 OS look at the machine map after processing ACPI and just decide to overwrite the ACPI regions?

Quoted 7 lines
Quoted 3 lines

Not that it's useful from an OS PoV, but also we have no statement saying that E820_ACPI in the machine memory map shouldn't be overwritten.

There are many things we have no statements for, yet we imply certain behavior or restrictions. The machine memory map, imo, clearly isn't intended for this kind of use.

There isn't much I can say then. I do feel we are creating rules out of thin air.

I do think the commit message should mention that we rely on dom0 not overwriting the data in the E820_ACPI regions on the machine memory map.

Quoted 7 lines
Quoted 2 lines

Hmm, am I getting it right that you think I need to add further justification for a change I'm _not_ making?

In the commit message you explicitly mentioned 'we don't actually "reclaim" E820_ACPI memory' and I assumed that "we" in the sentence to only include Xen. Now I see that the "we" there seems to include both Xen and the dom0 kernel. This wasn't clear to me at first sight.

It was clear, actually, as I did mean Xen alone. It didn't even occur to me that one could consider Dom0 potentially trying to do so.

Quoted 5 lines
Quoted 3 lines

And which, if we wanted
to change our behavior, would require a similar change (or perhaps a change elsewhere) in E820 (i.e. non-EFI) handling?

Why would that be required?

Because if EFI can (ab)use that type for other purposes, why couldn't legacy firmware, too?

Quoted 5 lines

Without EFI dom0 should be fine in overwriting (some?) of the data in E820_ACPI regions once it's finished with all ACPI processing, as a region of type E820_ACPI is reclaimable and Xen won't try to access it once handled to dom0.

Quoted 8 lines
Quoted 4 lines

The modification
I'm making is solely towards Xen's internal memory management. I'm really having a hard time seeing how commenting on expected Dom0 behavior would fit here

The type in the e820 memory map also gets propagated to dom0 in the machine memory map hypercall, so it can have effect outside of Xen itself.

If used beyond the very limited intended purposes, yes.

Quoted 14 lines
Quoted 6 lines

(leaving aside that I'm still puzzled by both
you and Andrew thinking that there's any whatsoever remote indication anywhere that Dom0 recycling E820_ACPI could be an okay thing in a PV Dom0 kernel). The more that marking EfiACPIReclaimMemory anything other than E820_ACPI might, as iirc you did say yourself, also confuse e.g. the ACPI subsystem of Dom0's kernel.

Indeed. There's no good way to convert a region of type EfiACPIReclaimMemory that has the EFI_MEMORY_RUNTIME attribute set, as there's no mapping to an e820 type.

One of the quirks of trying to retrofit an EFI memory map into e820 format.

Quoted 7 lines
Quoted 5 lines

But well, would extending that sentence to "While on x86 in theory the same would apply to EfiACPIReclaimMemory, we don't actually "reclaim" E820_ACPI memory there (and it would be a bug if the Dom0 kernel tried to do so, bypassing Xen's memory management), hence that type's handling can be left alone" satisfy your request?

I think that would indeed make it clearer.

Okay, I'll make the adjustment then and submit a v2. This will now need an ack also by Henry anyway.

Jan

#31 lore raw
In reply to Jan Beulich
Quoted 14 lines · Jan Beulich
Quoted 13 lines · Roger Pau Monné
Quoted 12 lines · Jan Beulich
Quoted 9 lines · Roger Pau Monné
Quoted 6 lines · Jan Beulich

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.

What about dom0? Should it be translated to E820_RESERVED so that dom0 doesn't try to use it either?

I'm afraid I don't understand the questions. Not the least because I think "it" can't really mean "dom0" from the earlier sentence.

Quoted 7 lines
Quoted 6 lines

Sorry, let me try again:

The memory map provided to dom0 will contain E820_ACPI entries for memory ranges with the EFI_MEMORY_RUNTIME attributes in the EFI memory map. Is there a risk from dom0 reclaiming such E820_ACPI ranges, overwriting the data needed for runtime services?

How would Dom0 go about doing so?

Zeroing the memory and putting it into its own heap.

You seem to be presuming that some unwritten and unenforced rules exist.

Once dom0 has booted, Xen cannot safety touch any ACPI reclaimable range.  It doesn't go wrong in practice because OSes don't actually reclaim the reclaimable ranges (which is also why Xen HVM guests don't explode either.)

~Andrew

#32 lore raw
Quoted 17 lines · Andrew Cooper
Quoted 16 lines · Jan Beulich
Quoted 15 lines · Roger Pau Monné
Quoted 8 lines · Jan Beulich
Quoted 7 lines · Roger Pau Monné
Quoted 6 lines · Jan Beulich

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.

Quoted 4 lines
Quoted 2 lines

What about dom0? Should it be translated to E820_RESERVED so that dom0 doesn't try to use it either?

I'm afraid I don't understand the questions. Not the least because I think "it" can't really mean "dom0" from the earlier sentence.

Sorry, let me try again:

Quoted 7 lines
Quoted 5 lines
Quoted 4 lines

The memory map provided to dom0 will contain E820_ACPI entries for memory ranges with the EFI_MEMORY_RUNTIME attributes in the EFI memory map. Is there a risk from dom0 reclaiming such E820_ACPI ranges, overwriting the data needed for runtime services?

How would Dom0 go about doing so?

Zeroing the memory and putting it into its own heap.

This makes no sense.

Quoted 1 line

You seem to be presuming that some unwritten and unenforced rules exist.

There's the PV interface. All memory management related functionality has to be based on the E820 map handed to the domain (irrespective of it being Dom0 or DomU). That map has no E820_ACPI entries for PV (and PVH Dom0 is as of yet unsupported). Dom0 is also handed the host E820, but it is supposed to use it only for resource management (e.g. to determine where BARs may be placed, or how to arrange its PFN space).

Quoted 2 lines

Once dom0 has booted, Xen cannot safety touch any ACPI reclaimable range.

I clearly disagree, and I expect existing behavior also disagrees with you.

Jan

Quoted 5 lines

  It doesn't go wrong in practice because OSes don't actually reclaim the reclaimable ranges (which is also why Xen HVM guests don't explode either.)

~Andrew