On 01/05/2019 12:17, David Woodhouse
wrote:
From: David Woodhouse <dwmw@xxxxxxxxxxxx>
We appear to have implemented a memcpy() in the low-memory trampoline
which we then call into from __start_xen(), for no adequately defined
reason.
Kill it with fire.
Absolutely.
Signed-off-by: David Woodhouse <dwmw@xxxxxxxxxxxx>
With the following fixup folded:
diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index 213a1bd..e607a85 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -673,13 +673,11 @@ static char * __init cmdline_cook(char *p, const char *loader_name)
return p;
}
-static int copy_bios_e820(struct e820entry *map, unsigned int limit)
+static unsigned int copy_bios_e820(struct e820entry *map, unsigned int limit)
{
- unsigned int n = bootsym(bios_e820nr);
- if (n > limit)
- n = limit;
+ unsigned int n = min(bootsym(bios_e820nr), limit);
- if (n)
+ if ( n )
memcpy(map, bootsym(bios_e820map), sizeof(*map) * n);
return n;
Acked-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
Interestingly, the version with min() results in surprisingly better
code:
add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-21 (-21)
Function old new delta
__start_xen 13807 13786 -21
Total: Before=3363289, After=3363268, chg -0.00%