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

Re: [PATCH] xen/riscv: read hart_id and dtb_base passed by bootloader


  • To: Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Fri, 24 Feb 2023 16:04:10 +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=/P2JW8hT5mG4fWX+r20I6j0WMkFT8r2krlr/tKelmZY=; b=K7uMnE5fMHEaM52wRer5zrz7W7sGNEAews+7205+YnEaJ9NYCotVNLJJtSgSavRz5+yXh6zVy0Cus5doXuNHtNAdAqBS83PQhalnL6qDS1S7vIafe7FupNVGWBq1iO0oUH+faAiT4gKzv2T2xY4UgSpgmb+o4eErkP7n0ecfc9DERSZ6DBMtvZ0oVAhVersRkioomWaexw7kjcpdTkHop3q5wedlPnCy1NTtVYhIUkdKDi4fnm087yWILSR7ejUbk3GvxYk8zpc96d9Iqe6hptNM6ZhbPiIgRpdw3im+9jBNi9oSChynmjMR+q5esMlWFzAK3MQ81xAogHlRm1p53Q==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XGdWm5rEJZH3FZGgGWj1KM2T9FvJ7GFXijkmxGLGmm77NdUi6p6GvvGbnW7s2tfap1UZaqU0ljG/CPcTBsJb9mrvWmlFCMZyn4LbxUIIYdnEt9C/ipLA0vRlJ3yPmB+U5GKS+9CQcvtIrx7ZLfqr2mS75um+/5UrjglnFwp5bVGjLs9SERhuXRsYAqTq0DInCLz66GJEhLQskhPpryJB0MxSy4hHFIeo7Y9ZTFwdX6EcoVGIXW04F5TZEW2LTngyPgdH8tZ5h+y4/QENud5eo1+Zktccb0xP51iiSYlXyUGRwOwCKKxWXvwPwgc5JNfKanA4jReHj5rE3oAB9Ol7gw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Gianluca Guida <gianluca@xxxxxxxxxxxx>, Bob Eshleman <bobbyeshleman@xxxxxxxxx>, Alistair Francis <alistair.francis@xxxxxxx>, Connor Davis <connojdavis@xxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Fri, 24 Feb 2023 15:04:22 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 24.02.2023 15:48, Oleksii Kurochko wrote:
> Signed-off-by: Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>
> ---
>  xen/arch/riscv/setup.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/xen/arch/riscv/setup.c b/xen/arch/riscv/setup.c
> index b3f8b10f71..154bf3a0bc 100644
> --- a/xen/arch/riscv/setup.c
> +++ b/xen/arch/riscv/setup.c
> @@ -26,6 +26,18 @@ static void test_macros_from_bug_h(void)
>  
>  void __init noreturn start_xen(void)
>  {
> +    /*
> +     * The following things are passed by bootloader:
> +     *   a0 -> hart_id
> +     *   a1 -> dtb_base
> +    */
> +    register unsigned long hart_id  asm("a0");
> +    register unsigned long dtb_base asm("a1");
> +
> +    asm volatile( "mv %0, a0" : "=r" (hart_id) );
> +
> +    asm volatile( "mv %0, a1" : "=r" (dtb_base) );

Are you sure this (a) works and (b) is what you want? You're inserting
"mov a0, a0" and "mov a1, a1". I suppose as long as the two local
variables aren't used further down in the function, the compiler will
be able to recognize both registers as dead, and hence use them for
argument passing to later functions that you call. But I would expect
that to break once you actually consume either of the variables.

Fundamentally I think this is the kind of thing you want do to in
assembly. However, in the specific case here, can't you simply have

void __init noreturn start_xen(unsigned long hard_id,
                               unsigned long dtb_base)
{
    ...

and all is going to be fine, without any asm()?

Otherwise again a style nit: In the asm statements (not the register
declarations) there is a missing blank each before the opening
parenthesis.

Jan



 


Rackspace

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