Damien Zammit, le mer. 07 janv. 2026 03:08:06 +0000, a ecrit:
> Since apboot_addr is a low 32 bit address

apboot_addr is already less that 0x100000, as asserted by
biosmem_bootstrap_common, so we don't need a truncation.

> ---
>  i386/i386at/model_dep.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/i386/i386at/model_dep.c b/i386/i386at/model_dep.c
> index e713cc8a..fb3c93d4 100644
> --- a/i386/i386at/model_dep.c
> +++ b/i386/i386at/model_dep.c
> @@ -222,8 +222,8 @@ void machine_init(void)
>        * Patch the realmode gdt with the correct offset and the first jmp to
>        * protected mode with the correct target.
>        */
> -     gdt_descr_tmp.linear_base += apboot_addr;
> -     apboot_jmp_offset += apboot_addr;
> +     gdt_descr_tmp.linear_base += (uint32_t)apboot_addr;
> +     apboot_jmp_offset += (uint32_t)apboot_addr;
>  #endif



> and we don't want to write 64 bits to the destination.

> diff --git a/i386/i386at/model_dep.c b/i386/i386at/model_dep.c
> index fb3c93d4..7af08550 100644
> --- a/i386/i386at/model_dep.c
> +++ b/i386/i386at/model_dep.c
> @@ -222,9 +222,16 @@ void machine_init(void)
>        * Patch the realmode gdt with the correct offset and the first jmp to
>        * protected mode with the correct target.
>        */
> +#ifdef __i386__
>       gdt_descr_tmp.linear_base += (uint32_t)apboot_addr;
>       apboot_jmp_offset += (uint32_t)apboot_addr;
>  #endif
> +#ifdef __x86_64__
> +     uintptr_t gdtptr = (uintptr_t)phystokv(&gdt_descr_tmp) + 2;
> +     *(uint32_t *)gdtptr += (uint32_t)apboot_addr;
> +     *(uint32_t *)phystokv(&apboot_jmp_offset) += (uint32_t)apboot_addr;
> +#endif
> +#endif

Why don't we want to write 64bits? Why converting &gdt_descr_tmp (which
is a virtual address) from physical to kv?

I don't see why any of that would be needed.

The apboot template is loaded along the rest of the kernel in virtual
memory, and it's the memcpy that puts it at the apboot_addr place in
physical memory.

Damien Zammit, le mer. 07 janv. 2026 03:08:32 +0000, a ecrit:
> diff --git a/i386/i386/mp_desc.c b/i386/i386/mp_desc.c
> index fff31822..6e13390b 100644
> --- a/i386/i386/mp_desc.c
> +++ b/i386/i386/mp_desc.c
> @@ -284,8 +284,14 @@ start_other_cpus(void)
>         return;
>  
>       //Copy cpu initialization assembly routine
> +#ifdef __x86_64__
> +     memcpy((void*) phystokv(apboot_addr), (void*) phystokv(&apboot),
> +            (uintptr_t)&apbootend - (uintptr_t)&apboot);
> +#endif
> +#ifdef __i386__
>       memcpy((void*) phystokv(apboot_addr), (void*) &apboot,
>              (uintptr_t)&apbootend - (uintptr_t)&apboot);
> +#endif

Again, why converting? &apboot is already a virtual address.

Samuel

Reply via email to