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

Re: [PATCH v1 07/14] xen/riscv: introduce exception handlers implementation


  • To: Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Andrew Cooper <Andrew.Cooper3@xxxxxxxxxx>
  • Date: Mon, 23 Jan 2023 11:50:23 +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=uA4REJyAREFunQrTC+sFGsAZOIbdT7QofAVB5zoTSoM=; b=MhYxeajkLMRNWC8VJcdWw9fU1rpy7gsYgyKsUW8KpkK6UuMkvrvLBnFP+AMxjzNNw6ZylkTe9Qkn9BVkys/hrDJxz0ELkSDIxT/RJkHQzf6WsS34DUncYiLzvGreOvS4zPNb26w4pcR4OlNqRZRVE4z8KXx22YyES2riGHN+pANrso+Fk7Wh6PVWOsyUJemSsVnIGTXXDM3zdvX9Cj9rdQmzrCLQCo2zS5t85d0Tc80Ev5CFTvWPVL8IRXxnpcQPTSqW2gVrhdKl+T3UfKGkbUgwesETO+GNDEbcYj/NhkJwnjRrr5eq+bZV7q0Gdf5i4+ovdJdkcD4ACnOF5pxmWw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dYp/6W8Ms6GY4JHquJYVbYluKQ8vHvuzcSrTopHqat6E1mvMewK0mX1LDRr3Ena2QVLVc4YgU5qTt3cqmmLeQUYttKDdFBzOGwoJE9E3X41OnoNDdI58OvhIQ4nn6dXnOS2LaRvTLbw59uv9dXTEedTDWywbdh4VufZ73iT+FNB76Edzc3k92IH+aiZCd2tOIyXb7gflmBcIio/L9FeiizIHVkTMi6psYlSAj9O0EzWOqWDMzaIYie6826Pi2OanKJ1YdCCz9eBPG0RzCEzQZAI77+LaUIM3IZhYW3IayjJGR0FHJon7K9vNEJz09rsC0sCpKv7LB1PZSJC3WOrW0w==
  • 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 11:50:43 +0000
  • Ironport-data: A9a23:GonV/6K+McwBCgDUFE+RSZQlxSXFcZb7ZxGr2PjKsXjdYENSgTZUn 2VOW26EPK2NNmP0ctB1bo+/9R8H6MPRxtdhHFZlqX01Q3x08seUXt7xwmUcnc+xBpaaEB84t ZV2hv3odp1coqr0/0/1WlTZhSAgk/rOHv+kUrWs1hlZHWdMUD0mhQ9oh9k3i4tphcnRKw6Ws Jb5rta31GWNglaYCUpJrfPcwP9TlK6q4mhA5wZlPakjUGL2zBH5MrpOfcldEFOgKmVkNrbSb /rOyri/4lTY838FYj9yuu+mGqGiaue60Tmm0hK6aYD76vRxjnVaPpIAHOgdcS9qZwChxLid/ jnvWauYEm/FNoWU8AgUvoIx/ytWZcWq85efSZSzXFD6I+QrvBIAzt03ZHzaM7H09c4wMUce5 7tHFgsOQU+ehOO80YiREfhz05FLwMnDZOvzu1lG5BSAV7MMZ8CGRK/Ho9hFwD03m8ZCW+7EY NYUYiZuaxKGZABTPlAQC9Q1m+LAanvXKmUE7g7K4/dqpTGMl2Sd05C0WDbRUvWMSd9YgQCzo WXe8n6iKhobKMae2XyO9XfEaurnzHirA99O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DzrxM0b759luqfkTL6uKiGHQEBGqbrUnxzeOLyoZx +eAuMkPxa4FxqeJW9g5XyPZ6Vv
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHZLOAVkIPSVA/PBEeRaJXa6cnAQq6r6ACA
  • Thread-topic: [PATCH v1 07/14] xen/riscv: introduce exception handlers implementation

On 20/01/2023 2:59 pm, Oleksii Kurochko wrote:
> diff --git a/xen/arch/riscv/entry.S b/xen/arch/riscv/entry.S
> new file mode 100644
> index 0000000000..f7d46f42bb
> --- /dev/null
> +++ b/xen/arch/riscv/entry.S
> @@ -0,0 +1,97 @@
> +#include <asm/asm.h>
> +#include <asm/processor.h>
> +#include <asm/riscv_encoding.h>
> +#include <asm/traps.h>
> +
> +        .global handle_exception
> +        .align 4
> +
> +handle_exception:

ENTRY() which takes care of the global and the align.

Also, you want a size and type at the end, just like in head.S  (Sorry,
we *still* don't have any sane infrastructure for doing that nicely. 
Opencode it for now.)

> +
> +    /* Exceptions from xen */
> +save_to_stack:

This label isn't used at all, is it?

> +        /* Save context to stack */
> +        REG_S   sp, (RISCV_CPU_USER_REGS_OFFSET(sp) - 
> RISCV_CPU_USER_REGS_SIZE) (sp)
> +        addi    sp, sp, -RISCV_CPU_USER_REGS_SIZE
> +        REG_S   t0, RISCV_CPU_USER_REGS_OFFSET(t0)(sp)

Exceptions on RISC-V don't adjust the stack pointer.  This logic depends
on interrupting Xen code, and Xen not having suffered a stack overflow
(and actually, that the space on the stack for all registers also
doesn't overflow).

Which might be fine for now, but I think it warrants a comment somewhere
(probably at handle_exception itself) stating the expectations while
it's still a work in progress.  So in this case something like:

/* Work-in-progress:  Depends on interrupting Xen, and the stack being
good. */


But, do we want to allocate stemp right away (even with an empty
struct), and get tp set up properly?

That said, aren't we going to have to rewrite this when enabling H mode
anyway?

> +        j       save_context
> +
> +save_context:

I'd drop this.  It's a nop right now.

> <snip>
> +        csrr    t0, CSR_SEPC
> +        REG_S   t0, RISCV_CPU_USER_REGS_OFFSET(sepc)(sp)
> +        csrr    t0, CSR_SSTATUS
> +        REG_S   t0, RISCV_CPU_USER_REGS_OFFSET(sstatus)(sp)

So something I've noticed about CSRs through this series.

The C CSR macros are set up to use real CSR names, but the CSR_*
constants used in C and ASM are raw numbers.

If we're using raw numbers, then the C CSR accessors should be static
inlines instead, but the advantage of using names is the toolchain can
issue an error when we reference a CSR not supported by the current
extensions.

We ought to use a single form, consistently through Xen.  How feasible
will it be to use names throughout?

~Andrew

 


Rackspace

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