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

Re: [PATCH v5 2/7] xen/riscv: initialize boot_info structure


  • To: Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 21 Mar 2023 12:27:34 +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=bbQAeUsV36rUNqz9uTU9a3E1pL9/cgy3Ba8/+0SuuVc=; b=adjclk+Bz1ohycSC/VRSdghB5s4S5vCLTYwPkAvulwlhXDbd89Sf9elhFmpFMNAF2tfjli0TjXj//9EtvZUMAMO+FZGkoBPt4ssJQIUXxiKd4/X8Dhqq9LdsO7EXQaa3DHGZgXhxY43LMhn/MTZD/kE/9LlskvYRDguLyaOhzAiWWrtKctHpY24n3ouHwo+uH/ZQZU1zApqPN2ksDKS4ZK9n+Pcd6/aFiOsw3vU+J+YshHrHSgI9qEKmZXxX6kdWZIuhsDCQRFUVg1KjQP4GhRIWwJzs4InfRNG7EaFEZ+LG2TSrPGxAx5DhxwraJIiVJ++3SiKEDbWwG+lhv/zWgQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Zr4+XbpWeWTJRrzAlV1paATsvAHHAGyrPA5E6teJrOjmfGLEVuVrztGucPKl/U3eDN3L2+uJWhk63nN/0eHjPc/cPKfG16DBYOX1vHwwXeTyTGQ4LEET9uzp4nVxZwd24binkxy+3K424gZjEFa1AuT/Izd8pFZrOup7+Ogk0QiySbu2EbidHWDLvU8EsEURPuPdmk3U5AYCKAE1+DRfKHSCDV0iTCy/lz0A9ZHuGWN0r/xE1+rnLg9FEi/i2WEILxiFRF51tcJv9F8OF9wE+Lxm5/56gtSddQtQjMTJrYPEbyF3+ftIoPZgQPmgznvqXN58fjvRm9TOemhJOIlq7g==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Julien Grall <julien@xxxxxxx>, 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: Tue, 21 Mar 2023 11:27:54 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 16.03.2023 15:39, Oleksii Kurochko wrote:
> --- a/xen/arch/riscv/setup.c
> +++ b/xen/arch/riscv/setup.c
> @@ -1,12 +1,16 @@
>  #include <xen/compile.h>
>  #include <xen/init.h>
> +#include <xen/kernel.h>
>  
> +#include <asm/boot-info.h>
>  #include <asm/early_printk.h>
>  
>  /* Xen stack for bringing up the first CPU. */
>  unsigned char __initdata cpu0_boot_stack[STACK_SIZE]
>      __aligned(STACK_SIZE);
>  
> +struct boot_info boot_info = { (unsigned long)&_start, (unsigned long)&_end, 
> 0UL, 0UL };

You add no declaration in a header, in which case this wants to be static.
It may also want to be __initdata, depending on further planned uses. I
would also like to suggest using C99 dedicated initializers and in any
event omit the 0UL initializer values (as that's what the compiler will
use anyway). Yet even then I think the line is still too long and hence
needs wrapping.

> @@ -15,11 +19,19 @@ unsigned char __initdata cpu0_boot_stack[STACK_SIZE]
>   */
>  int dummy_bss __attribute__((unused));
>  
> +static void fill_boot_info(void)

__init?

> +{
> +    boot_info.load_start = (unsigned long)_start;
> +    boot_info.load_end   = (unsigned long)_end;
> +}

I'd like to understand how this is intended to work: _start and _end
are known at compile time, and their value won't change (unless you
process relocations alongside switching from 1:1 mapping to some
other virtual memory layout). Therefore - why can't these be put in
the initializer as well? Guessing that the values derived here are
different because of being calculated in a PC-relative way, I think
this really needs a comment. If, of course, this can be relied upon
in the first place.

Also please be consistent about the use of unary & when taking the
address of arrays (or functions). Personally I prefer the & to be
omitted in such cases, but what I consider relevant is that there
be no mix (in new code at least).

Jan



 


Rackspace

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