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

Re: [PATCH v1 4/8] xen/riscv: introduce function for physical offset calculation


  • To: Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Mon, 12 Jun 2023 09:15:55 +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=aw00iNeYQdxK3fbRKFRRTemZezbdy/PhkdqHdw7pCYo=; b=ahr18pfoGFX+gyG3Q2PEMZQBsvgzpPgC5e6w41KrWfBHO+u1nJ17kizHm3gKcs2uM/h1QAntszcNL5tqbb1o2qDLrxXxv+AZrdncZrubGoArGy8mdPvADknyYHnL04cAnd0cNcSxeykh5tU5AHHw4DpagvCFiLMvr1s+YstTBrLAu44/D0A8jcJNz5aTM0hNZWtc+u/EmMcLS+u+PA4ETNTDl7pUruT0gAAMIckYJKQUHhNFgH7f8aw6KfDkhKksO/tbJso+ibexg8BPcuCiW1qVJw6m/DaiBXLIouqih5ljmAD6wtpF8zf9CXHWr1Vm3A5z+2fpd4mah/Ozy1tyvw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iqfjvFak8qKTbm3RCcIHxBwiXassoyvhfsFryHBw7/C7SsSBLYaxWj7ZIX7l4FdhUUgBqtAbNg0isLHNtEPi5+ZUIIUNF+fgTqEGemsXUnm0tKdEzsfxTtukyFFnY+3opQ3FVp7vnlN1+XE612HlkwIwPjBPjXOKu558hA6X1wyBSTKCSLcNkUsVC32wVh4N9ipJx8FIBwQAv5qEVAUtMwK09coHLmyge9WQgBvtEq2aawQbWcklIpUpc4+TVy4vGwttbidwzO1qtJnRbgHnann4J+ts1Zj7l54zc9ggvXw9DmorAkCu+k6vGuAVj+fw5LVRNNqfMgexEevkemlYgg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Bob Eshleman <bobbyeshleman@xxxxxxxxx>, Alistair Francis <alistair.francis@xxxxxxx>, Connor Davis <connojdavis@xxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Mon, 12 Jun 2023 07:16:35 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 06.06.2023 21:55, Oleksii Kurochko wrote:
> The function was introduced to not calculate and save physical
> offset before MMU is enabled because access to start() is
> PC-relative and in case of linker_addr != load_addr it will result
> in incorrect value in phys_offset.

"... to _not_ calculate ..."?

> --- a/xen/arch/riscv/mm.c
> +++ b/xen/arch/riscv/mm.c
> @@ -19,9 +19,11 @@ struct mmu_desc {
>  
>  extern unsigned char cpu0_boot_stack[STACK_SIZE];
>  
> -#define PHYS_OFFSET ((unsigned long)_start - XEN_VIRT_START)
> -#define LOAD_TO_LINK(addr) ((addr) - PHYS_OFFSET)
> -#define LINK_TO_LOAD(addr) ((addr) + PHYS_OFFSET)
> +static unsigned long phys_offset;

__ro_after_init?

> +#define LOAD_TO_LINK(addr) ((unsigned long)(addr) - phys_offset)
> +#define LINK_TO_LOAD(addr) ((unsigned long)(addr) + phys_offset)
> +
>  

Nit: No double blank lines please.

> @@ -273,3 +275,13 @@ void __init noreturn noinline enable_mmu()
>      switch_stack_and_jump((unsigned long)cpu0_boot_stack + STACK_SIZE,
>                            cont_after_mmu_is_enabled);
>  }
> +
> +/*
> + * calc_phys_offset() should be used before MMU is enabled because access to
> + * start() is PC-relative and in case when load_addr != linker_addr 
> phys_offset
> + * will have an incorrect value
> + */
> +void  calc_phys_offset(void)

__init? And nit: No double blanks please.

Jan



 


Rackspace

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