[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 2/3] xen/ppc: Relocate kernel to physical address 0 on boot


  • To: Shawn Anastasio <sanastasio@xxxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Mon, 31 Jul 2023 17:46:48 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Nvnn/wqgCCgGq4bR//xeCgvLzQHooa7aIMr8XWnl0DM=; b=KRJIgoxaQ8O1TPIJOutUhW3EdgabYhBLXEipKvfmMxeBDMWxRTIDc9jYYYcRssNA+/Z1dCQd2hDaGmQ/IEdWYGAcqnS6lfl/tPX5XKg7z93dNREhVUE6CkCEKkSvfaHdzmkoh+Q6AWmY0LqiknjIz1jo+wJ77CgHXio7PtfAzMv+b7u1/VsZYDlaKWV9WFAjtgz9BdkHyEuWK3INybVErSE9FolORbDQH6VHloWiEsBb4A6A++jYFKdMiGTYwTjQ8kSJegvJRF3sZBj3SWOGfi8zPqzJl+7YojT1SC45r1W689Vs5TeDzC/hepUXbI9LEsae3TXkefZ96ZYwhMzJ5g==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=db82hSSl1UDEeKTjexjnaVIrIEDHd5gQR+5hhXRK+KPt3ZSF8wZ/oHNGDOP2rEJQpB/TfqoUtzltMGl1hE8QbJG9Jz9QG0AqUhsxV6YQ4au3LhrDWhESFUQ0LUIEhgsxttrAonZ+ritW/7Zq+j1KoKEPCA1feuNhjuRUKt8Ch+vbX0dptTQ42Lz2bX8yCjQ8KaBNR2NMyF50/q/xp4UtQwknqhep3YrpkM77sHvRzlEg/hdUDAr6Go8jctpWmOXNRKV74N6WeonTIbWSBms3HDy6LLZIQn14AtWSKjM2MdKkIRjMOsNyzBwudSdrkCMsADnz1rfLZ4nFhjQdkn1R8Q==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Timothy Pearson <tpearson@xxxxxxxxxxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Mon, 31 Jul 2023 15:47:12 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 29.07.2023 00:21, Shawn Anastasio wrote:
> Introduce a small assembly loop in `start` to copy the kernel to
> physical address 0 before continuing. This ensures that the physical
> address lines up with XEN_VIRT_START (0xc000000000000000) and allows us
> to identity map the kernel when the MMU is set up in the next patch.

So PPC guarantees there's always a reasonable amount of memory at 0,
and that's available for use?

> --- a/xen/arch/ppc/ppc64/head.S
> +++ b/xen/arch/ppc/ppc64/head.S
> @@ -18,6 +18,33 @@ ENTRY(start)
>      addis   %r2, %r12, .TOC.-1b@ha
>      addi    %r2, %r2, .TOC.-1b@l
>  
> +    /*
> +     * Copy Xen to physical address zero and jump to XEN_VIRT_START
> +     * (0xc000000000000000). This works because the hardware will ignore the 
> top
> +     * four address bits when the MMU is off.
> +     */
> +    LOAD_REG_ADDR(%r1, start)

I think you really mean _start here (which is missing from the linker
script), not start. See also Andrew's recent related RISC-V change.

> +    LOAD_IMM64(%r12, XEN_VIRT_START)
> +
> +    /* If we're at the correct address, skip copy */
> +    cmpld   %r1, %r12
> +    beq     .L_correct_address

Can this ever be the case, especially with the MMU-off behavior you
describe in the comment above? Wouldn't you need to ignore the top
four bits in the comparison?

> +    /* Copy bytes until _end */
> +    LOAD_REG_ADDR(%r11, _end)
> +    addi    %r1, %r1, -8
> +    li      %r13, -8
> +.L_copy_xen:
> +    ldu     %r10, 8(%r1)
> +    stdu    %r10, 8(%r13)
> +    cmpld   %r1, %r11
> +    blt     .L_copy_xen
> +
> +    /* Jump to XEN_VIRT_START */
> +    mtctr   %r12
> +    bctr
> +.L_correct_address:

Can the two regions potentially overlap? Looking at the ELF header
it's not clear to me what guarantees there are that this can't
happen.

Jan



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.