Sergey Vlasov
2008-Jul-22 09:46 UTC
[syslinux] [PATCH 1/3] Fix loading of *.lkrn images from gPXE
Attempts to load *.lkrn images were failing with "Not enough memory to load specified image". These images have the su_ramdisk_max header field set to zero, and the code in core/runkernel.inc was limiting MyHighMemSize too early (before the load_high call used to load the main part of the kernel). Signed-off-by: Sergey Vlasov <vsu at altlinux.ru> --- core/runkernel.inc | 13 ++++++------- 1 files changed, 6 insertions(+), 7 deletions(-) diff --git a/core/runkernel.inc b/core/runkernel.inc index 4d62778..c7af6cc 100644 --- a/core/runkernel.inc +++ b/core/runkernel.inc @@ -216,13 +216,6 @@ new_kernel: mov al,[es:su_loadflags] mov [LoadFlags],al - ; Cap the ramdisk memory range if appropriate - mov eax,[RamdiskMax] - cmp eax,[MyHighMemSize] - ja .ok - mov [MyHighMemSize],eax -.ok: - any_kernel: ; @@ -291,6 +284,12 @@ high_load_done: ; if we tried to load initrd using an old kernel ; load_initrd: + ; Cap the ramdisk memory range if appropriate + mov eax,[RamdiskMax] + cmp eax,[MyHighMemSize] + ja .ok + mov [MyHighMemSize],eax +.ok: xor eax,eax cmp [InitRDPtr],ax jz .noinitrd -- 1.5.6.2.305.g2938b
Sergey Vlasov
2008-Jul-22 09:46 UTC
[syslinux] [PATCH 2/3] Fix initrd overwriting the kernel for some kernel sizes
The address in EDI returned by the load_high call used to load the kernel needs to be passed to parse_load_initrd, but the code which clears memory after setup sectors for 1.2.x kernels was corrupting low 16 bits of EDI. In most cases this corruption was not noticed, because with usual setup sizes DI was set to 0xf800, therefore the chance of getting the kernel size such that initrd would actually overwrite the kernel was about 3%. Signed-off-by: Sergey Vlasov <vsu at altlinux.ru> --- core/runkernel.inc | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/core/runkernel.inc b/core/runkernel.inc index c7af6cc..5748b0b 100644 --- a/core/runkernel.inc +++ b/core/runkernel.inc @@ -270,6 +270,7 @@ high_load_done: ; if they see protected-mode kernel data after the setup sectors, so ; clear that memory. ; + push di mov di,[SetupSecs] shl di,9 xor eax,eax @@ -277,6 +278,7 @@ high_load_done: sub cx,di shr cx,2 rep stosd + pop di ; ; Now see if we have an initial RAMdisk; if so, do requisite computation -- 1.5.6.2.305.g2938b
H. Peter Anvin
2008-Jul-22 13:15 UTC
[syslinux] [PATCH 1/3] Fix loading of *.lkrn images from gPXE
Sergey Vlasov wrote:> Attempts to load *.lkrn images were failing with "Not enough memory > to load specified image". These images have the su_ramdisk_max > header field set to zero, and the code in core/runkernel.inc was > limiting MyHighMemSize too early (before the load_high call used to > load the main part of the kernel).Hm. I don't know what *.lkrn images you're referring to (the newer gPXE images?) but that would be a bug in those images. If they don't have any intention of using an initrd it should be set to -1. Doesn't mean it wouldn't be worthwhile to work around this issue, but it's still wrong. -hpa