mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-20 12:42:54 +00:00
dm: bzimage loader: get linux bzimage setup_sects from header
According to $(LINUX_SRC)/Documentation/x86/boot.txt, the header of bzimage has setup sector number in offset 0x1f1. We don't need to scan the SETUP_SIG and detect the setup sector number actually which is not documented in x86 boot protocol. Tracked-On: #3619 Signed-off-by: Yin Fengwei <fengwei.yin@intel.com> Acked-by: Yu Wang <yu1.wang@intel.com>
This commit is contained in:
parent
fc3d19bee4
commit
66056c1acb
@ -76,7 +76,8 @@ struct _zeropage {
|
|||||||
uint8_t pad2[0x8]; /* 0x1e9 */
|
uint8_t pad2[0x8]; /* 0x1e9 */
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
uint8_t hdr_pad1[0x1f]; /* 0x1f1 */
|
uint8_t setup_sects; /* 0x1f1 */
|
||||||
|
uint8_t hdr_pad1[0x1e]; /* 0x1f2 */
|
||||||
uint8_t loader_type; /* 0x210 */
|
uint8_t loader_type; /* 0x210 */
|
||||||
uint8_t load_flags; /* 0x211 */
|
uint8_t load_flags; /* 0x211 */
|
||||||
uint8_t hdr_pad2[0x2]; /* 0x212 */
|
uint8_t hdr_pad2[0x2]; /* 0x212 */
|
||||||
@ -103,27 +104,17 @@ static size_t kernel_size;
|
|||||||
static int
|
static int
|
||||||
acrn_get_bzimage_setup_size(struct vmctx *ctx)
|
acrn_get_bzimage_setup_size(struct vmctx *ctx)
|
||||||
{
|
{
|
||||||
uint32_t *tmp, location = 1024, setup_sectors;
|
struct _zeropage *kernel_load = (struct _zeropage *)
|
||||||
int size = -1;
|
(ctx->baseaddr + KERNEL_LOAD_OFF(ctx));
|
||||||
|
|
||||||
tmp = (uint32_t *)(ctx->baseaddr + KERNEL_LOAD_OFF(ctx)) + 1024/4;
|
/* For backwards compatibility, if the setup_sects field
|
||||||
while (*tmp != SETUP_SIG && location < 0x8000) {
|
* is 0, the real value is 4.
|
||||||
tmp++;
|
*/
|
||||||
location += 4;
|
if (kernel_load->hdr.setup_sects == 0) {
|
||||||
|
kernel_load->hdr.setup_sects = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* setup size must be at least 1024 bytes and small than 0x8000 */
|
return (kernel_load->hdr.setup_sects + 1) * 512;
|
||||||
if (location < 0x8000 && location > 1024) {
|
|
||||||
setup_sectors = (location + 511) / 512;
|
|
||||||
size = setup_sectors*512;
|
|
||||||
printf("SW_LOAD: found setup sig @ 0x%08x, "
|
|
||||||
"setup_size is 0x%08x\n",
|
|
||||||
location, size);
|
|
||||||
} else
|
|
||||||
printf("SW_LOAD ERR: could not get setup "
|
|
||||||
"size in kernel %s\n",
|
|
||||||
kernel_path);
|
|
||||||
return size;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
Loading…
Reference in New Issue
Block a user