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

Re: [PATCH v1 11/14] xen/riscv: introduce setup_trap_handler()


  • To: Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Andrew Cooper <Andrew.Cooper3@xxxxxxxxxx>
  • Date: Mon, 23 Jan 2023 23:21:30 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.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=9VAQ+PgfRLyqSM3sIrJHXqHBo+yHSLvVHai9VtXAOVc=; b=n0VUAHy8c8kwHB9+v9URprFRjBWK/vsehDLaiTj0zMQsOnQYwFWA7PE5D1GxXo8nY2H0DIf2/5zEixRZXziuuPT74XR5dbvPrxW9JlQNWRX/yH7XKo7RRjVNi1MlO0wKBdgkeMsZwhYVlTmFo8uLlO+2YwSa0z/jBSnSthSRJXx5DGKSMYvXotDRmL/MEbboJGnGbHgGc9q5R14fJdnBPLMePoG7jmw1eAE0SQd1lwqBvCry1FLIPL94ZE4L44UjvSfOCInCOhoM6h2+QHHpUpWCM+7q3R02O8zBK4J/365D4PdtYdV2Rb16YiJEyHQsYeX3aIUri3ZFzw77Q7hAOA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fa5W9EOm8znadrPFHvvqhCeE4XdvNHGlTFNcAQ48Wgl1YRcZEJ3XtVltRncVxxiiaitOP31XHbfX7fbHgP8GT6vn7upI9Qjey7RMJp2oj78yfv+4/vhKYdYUbbz8BO+TJAj7NpQSExnY/y22zpaggieX9nvPCnTjHd2Vw4yho3NePS2Bi0AxHvmBoQgd9016xd6KSH68OsG2sKXW2XLH4pBoKmF0OngP10XCiAul4VwrR21hUjNL8OX6SgjNP1pQRgiJebAYlDLejUGrd1ki1kaP1+GF0qG9cbKGgPJCObkTCaaNWdEPGenmf3ucRTM/+vJOijIjHzxgmrJP3oE33w==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Gianluca Guida <gianluca@xxxxxxxxxxxx>, Bob Eshleman <bobbyeshleman@xxxxxxxxx>, Alistair Francis <alistair.francis@xxxxxxx>, Connor Davis <connojdavis@xxxxxxxxx>
  • Delivery-date: Mon, 23 Jan 2023 23:21:59 +0000
  • Ironport-data: A9a23:i38qt6wZQfdGrZCls/N6t+euxyrEfRIJ4+MujC+fZmUNrF6WrkVWn 2UWWmqHa/mNYGb9LY0lad/kpB9UvZ/QytI3SAE9+yAxQypGp/SeCIXCJC8cHc8wwu7rFxs7s ppEOrEsCOhuExcwcz/0auCJQUFUjP3OHfykTbaeYUidfCc8IA85kxVvhuUltYBhhNm9Emult Mj75sbSIzdJ4RYtWo4vw//F+UwHUMja4mtC5QRnP6sT5jcyqlFOZH4hDfDpR5fHatE88t6SH 47r0Ly/92XFyBYhYvvNfmHTKxBirhb6ZGBiu1IOM0SQqkEqSh8ai87XAME0e0ZP4whlqvgqo Dl7WT5cfi9yVkHEsLx1vxC1iEiSN4UekFPMCSDXXcB+UyQq2pYjqhljJBheAGEWxgp4KXlqq 91IFCwzVxm4tsyvz5OUb7F9gv12eaEHPKtH0p1h5RfwKK98BLX8GeDN79Ie2yosjMdTG/qYf 9AedTdkcBXHZVtIJ0sTD5U92uyvgxETcRUB8A7T+fVxvTaVkFYZPLvFabI5fvSjQ8lPk1nej WXB52njWTkRNcCFyCrD+XWp7gPKtXKgCNxCTO3gnhJsqG2O4UgeCw8MbmX4neWnqVKQVdRac GVBr0LCqoB3riRHVOLVWBm1o2WFv1gfRsBXGO057ymCz6PV50CSAW1sZi5MbpkqudE7QRQu1 0SVhJX5CDp3qrqXRHmBsLCOoluaIjMJJGUPYSsFSwot4NT5pow3yBXVQb5LH6+8iNnoEjjY2 TGUqzM/gb5VhskOv42x+lrNkj+3ppzESwczzgrSV2OhqAh+YeaNboip8kTS7OwGIpyQSFKAp 1Abl8PY5+cLZbmGkyqLR+cBFa+o/N6KNTTdhRhkGJxJyti203uqfIQV5S4kIk5sa5wAYWWxP BWVvh5N7phOOnfsdbVwf4+6F8Uty+7nCMjhUffXKNFJZ/CdaTO6wc2nXmbIt0iFraTmuftX1 UuzGSp0MUsnNA==
  • Ironport-hdrordr: A9a23:Qa8OaKs3iZn4YPxhvrvnmVVZ7skCC4Mji2hC6mlwRA09TyXPrb HIoB19726RtN9xYgBEpTnkAtj/fZqyz/RICOUqUItKGTOGhILLFu9fBPrZsl/d8kTFn4Y36U 4jSchD4bvLYWSS5vyKgzVQfexO/DCvytHUuc7ui1pgSAF0Z7pxqy1+DRuWA1Aefng9OXNALu vh2iM9nUvHRV0nKve2AXQIReqGiMbMkNbPaxQBGxk7rCmC5AnYl4LSIlyq0hASXylMhY0j/G SAuQr/+am5qfmnyhnak0PV8pRKiJ/c0dsrPr30tuElbgbhjQulfoYkYb2OsHQepuax5E0xmM TNpRBlE9t+7G6UXmzdm2qU5yDQlAUj7HLv013du3vvrYjSQjUkB9FajZ9YdByc1ks6sNlwlI JHtljpzKZqMQ==
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHZLOAf2Nb+ieXL2kOG2Uab6ou5Zq6sqRgA
  • Thread-topic: [PATCH v1 11/14] xen/riscv: introduce setup_trap_handler()

On 20/01/2023 2:59 pm, Oleksii Kurochko wrote:
> Signed-off-by: Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>
> ---
>  xen/arch/riscv/setup.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
>
> diff --git a/xen/arch/riscv/setup.c b/xen/arch/riscv/setup.c
> index d09ffe1454..174e134c93 100644
> --- a/xen/arch/riscv/setup.c
> +++ b/xen/arch/riscv/setup.c
> @@ -1,16 +1,27 @@
>  #include <xen/compile.h>
>  #include <xen/init.h>
>  
> +#include <asm/csr.h>
>  #include <asm/early_printk.h>
> +#include <asm/traps.h>
>  
>  /* Xen stack for bringing up the first CPU. */
>  unsigned char __initdata cpu0_boot_stack[STACK_SIZE]
>      __aligned(STACK_SIZE);
>  
> +static void setup_trap_handler(void)

We'd normally call this trap_init(), but it wants to live in traps.c
rather than setup.c, with a prototype in traps.h.

> +{
> +    unsigned long addr = (unsigned long)&handle_exception;

Coding style.  Newline between variable declarations and code.

Having looked at the spec, the entrypoint should be named handle_trap
rather than handle_exception.  Per the spec, a trap is either an
interrupt or an exception based on the IRQ flag in CAUSE.

That adjustment to naming wants to percolate down through the calltree
and also in earlier patches.

To avoid the __handle_exception() function in C, you could call the C
version do_trap() which is a reasonably common idiom in other architectures.

> +    csr_write(CSR_STVEC, addr);
> +}
> +
>  void __init noreturn start_xen(void)
>  {
>      early_printk("Hello from C env\n");
>  
> +    setup_trap_handler();
> +    early_printk("exception handler has been setup\n");

Personally I don't think this printk() adds any value.  It's not one
looked at by the smoke test, and it's only a single CSRW away from the
"Hello from C" message.

~Andrew

 


Rackspace

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