On 28/02/2025 2:59 pm, Milan Djokic wrote:
> From: Slavisa Petrovic <[email protected]>
>
> This patch implements copy_to_guest/copy_from_guest functions for RISC-V.
> These functions are designed to facilitate data exchange between guest and
> hypervisor.
>
> Signed-off-by: Milan Djokic <[email protected]>
> Signed-off-by: Slavisa Petrovic <[email protected]>
> ---
> Tested on qemu with xcp-ng latest branch
> https://gitlab.com/xen-project/people/olkur/xen/-/merge_requests/6
> Full description on how to setup test environment can be found in attached PR
> link (Linux kernel patching to support copy_from_guest/copy_to_guest for
> RISC-V).
> Linux kernel patch shall be upstreamed after these changes are merged.
Several things. First, it's probably worth setting you up with Gitlab
access, seeing as that's the first step of RISC-V CI.
Second, where can I read about the semantics of h{l,s}v? That looks
alarmingly like a virtual address, and there's a world supply of corner
cases that can come with it, including incorrect translations.
Also, I very desperately want RISC-V (and PPC) not to inherit
2-decade-old x86-ISMs which we're currently trying to remove, because
starting without them is 10x easier than to fix them after the fact.
> diff --git a/xen/arch/riscv/addr_translation.S
> b/xen/arch/riscv/addr_translation.S
> new file mode 100644
> index 0000000000..7e94774b47
> --- /dev/null
> +++ b/xen/arch/riscv/addr_translation.S
> @@ -0,0 +1,63 @@
> +#include <asm/riscv_encoding.h>
> +#include <asm/asm.h>
> +
> +.macro add_extable lbl
> +.pushsection .extable, "a" /* Start .extable section */
> +.balign 8 /* Align to 8 bytes */
> +.quad \lbl /* Add label address to extable */
> +.popsection /* End section */
> +.endm
> +
> +.section .text
> +
> +/*
> + * size_t _copy_to(uint64_t dest, const void *src, size_t len)
> + *
> + * a0 - dest
> + * a1 - src
> + * a2 - len
> + *
> + */
> +
> +.global _copy_to
> +_copy_to:
For assembly code, please use the linkage macros. See 7015f337a217 as
an example.
However, as far as I can tell, the only interesting thing h{s,l}v.b, at
which point a simple piece of inline asm is surely easier, and would
simplify guestcopy.c too.
Exception table entries are perfectly easy to do in inline asm. See
_ASM_EXTABLE() in x86 for an example.
~Andrew