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

Re: [PATCH v4 1/2] xen/riscv: introduce function for physical offset calculation


  • To: Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Mon, 24 Jul 2023 15:40:18 +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=v/Dk3H9+KPxVss5y+OP7rpTMAi0oHcbOdrc9bPzf3Jc=; b=Mm+3s4lSTFU684xUmUBQHOTVk17tDhXS4zwuJ/PJbxFAs2Yr7VEY7RIzV7+LtmYlZIPXvbMcC3mC4NA+fDAfTwDA9a93c5Q+kv6c0fZfom2m236K/h+fQFPJzj6hCNu+IX9p6XzLQMMcv3rr1F5hbDEaDPayyIMgCHFFFAUDglltr4EM7jNuNHwlPZob0cH7H0ZEgSSfkj1U31pa235eEdx7qqB/U5d1pWe0BbamlfvXHaHIXfZ13jruLba2q3YzxR8vT1bMT69/mpdo6EeEbZtgWHPgk1Q1foc70xB25eD/VRPNrim8jc5UDbIRVm+b7j+6081FkEIGbL1mhiRC9g==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SQ3Qv8mVUZd+SLBrt74VG7IBnrDs1n/+xm18RLPpGOEshUAwrv2cEJOkeAT39AX/lJPiGp4OTlqTYw7fBcAJyLHJ/9pfvLTpR5bEDTJCf8/UnDCmyyZ8UWPQiyS9bksmrxFBaLtBPaOwNk4ox6UtAr5zhhL7vE5xEUYA8TtbKD0Y8LYgOuMsS8NBql9sLdRzuxtZhEGH7rOXo5z9pIZpmQbxadEuNSHmx4wjX1GJwPICy0OG0SRDI4tKiXgmP3qGdf4FeqQ1jX/rAHclvnW4CrY0TDBvg/SnZ0+tlcbJjyggqMpyBdGI91h3l3j6J3BUzWJ+94gSKchjdQVNdVxTMQ==
  • 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, 24 Jul 2023 13:40:30 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 24.07.2023 11:42, Oleksii Kurochko wrote:
> @@ -19,9 +20,10 @@ struct mmu_desc {
>      pte_t *pgtbl_base;
>  };
>  
> -#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)
> +unsigned long __ro_after_init phys_offset;

While Misra compliance is distant future for RISC-V, there's a
problem here with there not being any declaration for this global
variable. Adding a declaration isn't the only solution though:
Patch 2 also only uses the variable in assembly code. Therefore
the variable here could be made static, with ...

> @@ -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 __init calc_phys_offset(void)
> +{
> +    phys_offset = (unsigned long)start - XEN_VIRT_START;
> +}

... this function (being invoked by the same assembly code
function) returning the value alongside storing it.

FTAOD I wouldn't insist on this being taken care of right away,
so if you get a maintainer ack this way, I'd be happy to commit as
is.

Jan



 


Rackspace

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