From ad7b5727bcde383957f69ff03a38ade1c82f531d Mon Sep 17 00:00:00 2001 From: Sergii Dmytruk Date: Mon, 28 Apr 2025 01:15:30 +0300 Subject: [PATCH] xen/arch/x86/intel_txt.c: allow to-be-reserved-mem to be unlisted Signed-off-by: Sergii Dmytruk --- xen/arch/x86/intel_txt.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/intel_txt.c b/xen/arch/x86/intel_txt.c index 8dd476026a..0fa4dbf92e 100644 --- a/xen/arch/x86/intel_txt.c +++ b/xen/arch/x86/intel_txt.c @@ -39,11 +39,29 @@ static int __init reserve_e820(struct e820map *e820, uint64_t s, uint64_t e) { uint64_t rs = e820->map[i].addr; uint64_t re = rs + e820->map[i].size; + + /* The entry includes the range. */ if ( s >= rs && e <= re ) break; + + /* The entry intersects the range. */ + if ( e > rs && s < re ) + { + /* Fatal failure. */ + return 0; + } } - if ( i != e820->nr_map && e820->map[i].type == E820_RESERVED ) + /* + * If the range is not included by any entry and no entry intersects it, + * then it's not listed in the memory map. Consider this case as a success + * since we're only preventing RAM from being used and unlisted range should + * not be used. + */ + if ( i == e820->nr_map ) + return 1; + + if ( e820->map[i].type == E820_RESERVED ) { /* Nothing to do, the range is already covered as reserved. */ return 1;