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

Re: [PATCH v1] xen/riscv: make calculation of stack address PC-relative


  • To: Oleksii <oleksii.kurochko@xxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 16 Mar 2023 10:54:43 +0100
  • 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=8r+P83UaUrbAniYYk0RQnRSgsFXiA09yC723Rams+Iw=; b=DR/8MNHRjrA1H3to8xKWIlE3URV8usNvKhJ4+gR3TJZrtZe6eiZQnEAopWPSOzO1ZjdxHiyrTJFH8xybuQTL9QGq05HkJhFSEjNEE9zTw75XpfptvKa4e3fdnvs5kStAcdF2KTlIdB3Vja8ZVxV7JHPYklpxXDxvigmlV1w2fM/kll6m+3iRXxvLn9KG8ugnyROuy2LNS8icZ2Xv2gHN0QB7BMVTUrGNBR14Q5f2urEypzlkgASlYxA+OARHwp7uLloLLI/IDbDfXJ7dc2LleyslXEH4W/EqL8ORjq3yXMZiWc5uGUXqS2oQSLgwUT5MqxEay6M5c8AfyzJAcME5pw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=n3TB3fcNeic2E3mycZ4j6tjb8oIp48QPTyIYnpYPoNR47zj6N9VkVPyCg/w1vN+WwO0RQyl63xBr14qWEeOwePcX6UE9bsQXHYR/P9beezAIzZUzzeTqejDy3POc0Qo4rGcbO4jUozX4EexTEagIk9YDCoqaA1+Rl+yWclb6YJ+oAnIsT8l6z+MPe6LNdOCiEk/xgbEsYTh+gSfR6Mt+yQyD8YyaXQAzu2ZRtcN2IFv76VfhDVPPTc78LePPsbb1fDDYBLCQa7M5z/Fa/72Z9+MWx6ZJOOKtw2xW3nrRm4p9QKu3985tc7zEoGP+RJJwlaSZ4hBuEk+0kHD+S4XK0Q==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Gianluca Guida <gianluca@xxxxxxxxxxxx>, Bob Eshleman <bobbyeshleman@xxxxxxxxx>, Alistair Francis <alistair.francis@xxxxxxx>, Connor Davis <connojdavis@xxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Delivery-date: Thu, 16 Mar 2023 09:54:57 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 16.03.2023 10:52, Oleksii wrote:
>>>
>>> Could you please explain what is x86 section asserts?
>>
>> If you look at the bottom of x86's xen.lds.S you'll find a number of
>> assertions, among them one towards .got being empty. Some of the
>> sections checked there may indeed not be applicable on arbitrary
>> architectures, but I think .got is sufficiently universal. So I agree
>> with Andrew that it may be worthwhile making some of this generic.
> 
> I have question about 'SIZEOF(.got.plt) == 3 * 8':
> 
> #ifndef EFI
> ASSERT(!SIZEOF(.got),      ".got non-empty")
> /*
>  * At least GNU ld 2.30 and earlier fail to discard the generic part of
>  * .got.plt when no actual entries were allocated. Permit this case
> alongside
>  * the section being empty.
>  */
> ASSERT(!SIZEOF(.got.plt) || SIZEOF(.got.plt) == 3 * 8,
>        "unexpected .got.plt size")
> ASSERT(!SIZEOF(.igot.plt), ".igot.plt non-empty")
> ASSERT(!SIZEOF(.iplt),     ".iplt non-empty")
> ASSERT(!SIZEOF(.plt),      ".plt non-empty")
> ASSERT(!SIZEOF(.rela),     "leftover relocations")
> #endif
> 
> I assume that the check 'SIZEOF(.got.plt) == 3 * 8' was added to verify
> the case when no real entries in .got.plt are needed but .got.plt still
> has 3 entries.
> 
> I commented the code where got entries are produced now:
> --- a/xen/arch/riscv/riscv64/head.S
> +++ b/xen/arch/riscv/riscv64/head.S
> @@ -20,6 +20,7 @@ ENTRY(start)
>          csrc    CSR_SSTATUS, t0
>  
>          /* Clear the BSS */
> +/*
>          la      t3, __bss_start
>          la      t4, __bss_end
>  .L_clear_bss:
> @@ -30,5 +31,6 @@ ENTRY(start)
>          la     sp, cpu0_boot_stack
>          li      t0, STACK_SIZE
>          add     sp, sp, t0
> +*/
>  
>          tail    start_xen
> 
> And I can't see .got.plt with 3 entries:
>   $ riscv64-linux-gnu-objdump -x xen/xen-syms | grep -i got
> 
> What am I doing wrong? Or my understanding of the idea of the check is
> wrong?

Did you read the comment next to it as to only older binutils being
affected? I assume you use something newer than 2.30. Furthermore that
specific behavior may very well have been x86-specific in the first
place. So ...

> And I assume that add !SIZEOF(.got) and !SIZEOF(.got.plt) would be
> enough to RISC-V's xen.lds.S?

... quite likely: Yes.

Jan



 


Rackspace

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