[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 Kurochko <oleksii.kurochko@xxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Tue, 14 Mar 2023 17:09:31 +0000
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.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=1H13SGxzXdJ8ZNWlHRfmycM9ZGuAohEALcooD7APUyg=; b=dJ5mzCAd7OSmAPaZjo2dNiUYMtPKy7o3iqx4v3qgYqI3hMSplU/sblfIOitgv14YGNU3fDpW4TDyMKfLCIZoPwDSvfP+EXNiLoyTbDrsP+I5UJ8kSmqQGs8mpOmQFvMUkog1irPr0xKuP7yYnPY3oG77uhcg2YpOZQtPJubdtc5UFr+6wcHKGyuMGBt0czm2n1LIk8OyanXZkXo/52tmOhivvr3CZZ5Y/tWcndcWx1owR3i+me4I5T+A79hKeivmfcWFAwlZIRo/7iI4GMh87oH97YUdOeOnFxg7qc6hXPx4Pfv1t1iMPs8OH/JzkgEW6qDfS4LPyd1tFrdj2gm5XQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=e4m6D2gXtumHJot/Wi6Yko/kqcAonV4HTbgr/RalYY7nCoh/SihSXqXgYtmwg1FJkroHQnDebQ/vXS6isI8z4pZqfgF0zWMkMSBeb04974zO5uM1AZlNTVWFz7G/8SsUOGdfxkqkxTaRDrAZud47012JlalPRds125rpJ5eattJoxkTLJdQYbMY0628RdEpsC5dBporUr+URjR/s2KqSd+fxZqys9sq5TPd0GcNYm07syghpDZGOBAX0bPI+qdbLdIgqOAyaSP3RM/lD0XpMksv/FJ546egq+IPrf+8uqpGqQ/eCq5mI02WkLUkDNIeRebxTqgR3L9tZ4gRyzGrvWw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Gianluca Guida <gianluca@xxxxxxxxxxxx>, Bob Eshleman <bobbyeshleman@xxxxxxxxx>, Alistair Francis <alistair.francis@xxxxxxx>, Connor Davis <connojdavis@xxxxxxxxx>
  • Delivery-date: Tue, 14 Mar 2023 17:10:21 +0000
  • Ironport-data: A9a23:o8rgTKjHdxK43EKwY9n0NYnqX161+hEKZh0ujC45NGQN5FlHY01je htvX2rTbq3bZzHyKIt0bI/j/ENSsZXdzN82T1BvqHxhEiMb9cadCdqndUqhZCn6wu8v7q5Ex 55HNoSfdpBcolv0/ErF3m3J9CEkvU2wbuOgTrWCYmYpHlUMpB4J0XpLg/Q+jpNjne+3CgaMv cKai8DEMRqu1iUc3lg8sspvkzsy+qWi0N8klgZmP6sT5waCzyN94K83fsldEVOpGuG4IcbiL wrz5OnR1n/U+R4rFuSknt7TGqHdauePVeQmoiM+t5mK2nCulARrukoIHKN0hXNsoyeIh7hMJ OBl7vRcf+uL0prkw4zxWzEAe8130DYvFLXveRBTuuTLp6HKnueFL1yDwyjaMKVBktubD12i+ tRDMDoXQRGTjdiHyZWja+NLisc9KtnkadZ3VnFIlVk1DN4AaLWaGuDmwIEd2z09wMdTAfzZe swVLyJ1awjNaAFOPVFRD48imOCvhT/0dDgwRFC9/PJrpTSMilEuluGzYLI5efTTLSlRtm+eq njL4CLSBRYCOcbE4TGE7mitlqnEmiaTtIc6TeXgqaQ73QLOroAVICEPBUnr4qGHsUGjVOkcC FUY5nUskJFnoSRHSfG4BXVUukWsuRoRWMFREqs59RuKwarX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X2b/dlyurTe2j+1f4jebeawNDzQbL0GIfHNwoCdyfWPk YjNQKDVvmoqHrbFkPFvA==
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 14/03/2023 4:00 pm, Oleksii Kurochko wrote:
> The patch is needed to keep all addresses PC-relative.
>
> Pseudoinstruction 'la' can be transformed to 'auipc/addi' or
> 'auipc/l{w|d}'. It depends on the .option directive: nopic and pic.
>
> Right now, 'la' transforms to 'auipc/l{w|d}', which in case of
> cpu0_boot_stack[] will lead to the usage of _GLOBAL_OFFSET_TABLE_
> where all addresses will be without counting that it might happen
> that linker address != load address.
>
> To be sure that SP is loaded always PC-relative address
> 'la' should be changed to 'lla', which always transforms to
> 'auipc/addi'.
>
> Signed-off-by: Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>
> ---
>  xen/arch/riscv/riscv64/head.S | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/xen/arch/riscv/riscv64/head.S b/xen/arch/riscv/riscv64/head.S
> index 8887f0cbd4..e12d2a7cf3 100644
> --- a/xen/arch/riscv/riscv64/head.S
> +++ b/xen/arch/riscv/riscv64/head.S
> @@ -27,7 +27,7 @@ ENTRY(start)
>          add     t3, t3, __SIZEOF_POINTER__
>          bltu    t3, t4, .L_clear_bss
>  
> -        la      sp, cpu0_boot_stack
> +        lla     sp, cpu0_boot_stack

I don't think this is the appropriate way forward.  It's very much
smells like duct tape hiding the real bug.

~Andrew



 


Rackspace

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