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

Re: [PATCH v4 2/2] xen/riscv: introduce identity mapping


  • To: Oleksii <oleksii.kurochko@xxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 26 Jul 2023 13:58:01 +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=1Kv64caLvCUE45jELVeNvwxD26DIDkltWkvIeQWmpBw=; b=J0laxt5eZYAKxdYBkD+3OD2zEuezMrhYIJkQv7D0lYyzWKacdNtj9pLwy+ygTT2lQ+7kM50hEeHnF19yW0/bpm6JFLuiBqngLClU21jF1LdaM2mOOWPFFXSJeg7HUYWW1GxwW7w2ZlbzehfBDn3uEIv6Fj7BNI0xOwEHcY6kd3ExCB2F0XWIEJ+UFtmGY+xM1Wb1oElb4EbpKy10X/+tRO479TDJULawinZi8B4NDiMpp6aRE/I6A1LFkp4hL963E0ShSCb0BcJNF4sMNLbL2ZMki6ZAPgmY8EPxKEQ8HIcWuqyxIdSdCR/ZoKCJc0+CG+L+uJQWfooWXk/gLFs3yA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YrMGus5gezlx8M/UCBw6/fnu3cORow+W+/J8CB6EUR7LWxHLlkGpCXneglLtfayBaz3AmJYmonDHib9/rKnbcCrCYX4eOVkGoSBNAo/nnfPKwhmw4SofuHPA2/Wgy2pI4KU/tnRYaBwVRiLp56aEkY8AGBrIflg1oXcTf7VBNd52y7FYi3073w55WO5smPjXa838rJZTb2vgppEMTV+AbRuHtW4z8O3PTZaasfZAkfYv9ofGMg9E4q9eIGpiOSTNVJQMkyd4bEKWBq3o5u/0czAHsI+nn0/gCMH6Li265CCPSqY0zpMX+7sB9FwxA3ER/PadTSdQZ+xuR9LjlgAyQw==
  • 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: Wed, 26 Jul 2023 11:58:11 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 26.07.2023 13:23, Oleksii wrote:
> I would like to ask for advice on whether it would be easier, less bug-
> provoking ( during identity mapping to remove of whole Xen ) to have a
> separate identity section that won't be more than PAGE_SIZE.

I'm afraid you can't safely do this in C, or at least not without
further checking on what the compiler actually did.

> @@ -264,6 +268,19 @@ void __init enable_mmu(void)
>                RV_STAGE1_MODE << SATP_MODE_SHIFT);
>  }
>  
> +void __attribute__((naked)) __section(".ident") turn_on_mmu(unsigned
> long ra)

Did you read what gcc doc says about "naked"? Extended asm() isn't
supported there. Since ...

> +{
> +    /* Ensure page table writes precede loading the SATP */
> +    sfence_vma();
> +
> +    /* Enable the MMU and load the new pagetable for Xen */
> +    csr_write(CSR_SATP,
> +              PFN_DOWN((unsigned long)stage1_pgtbl_root) |
> +              RV_STAGE1_MODE << SATP_MODE_SHIFT);
> +
> +    asm volatile( "jr %0\n" : : "r"(ra) );
> +}

... none of this really requires C, I think we're at the point where
(iirc) Andrew's and my suggestion wants following, moving this to
assembly code (at which point it doesn't need to be a separate
function). You can still build page tables in C, of course. (Likely
you then also won't need a separate section; some minimal alignment
guarantees ought to suffice to make sure the critical code is
confined to a single page.)

Jan



 


Rackspace

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