Re: [kvm-unit-tests PATCH v3 5/7] s390x: Add library functions for exiting from snippet

Claudio Imbrenda
2024-06-20T17:06:43Z

On Thu, 20 Jun 2024 16:16:58 +0200
Nina Schoetterl-Glausch <nsg@linux.ibm.com> wrote:

> It is useful to be able to force an exit to the host from the snippet,
> as well as do so while returning a value.
> Add this functionality, also add helper functions for the host to check
> for an exit and get or check the value.
> Use diag 0x44 and 0x9c for this.
> Add a guest specific snippet header file and rename snippet.h to reflect
> that it is host specific.
>
> Signed-off-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>

[...]

> +static inline void diag44(void)
> +{
> + asm volatile("diag 0,0,0x44\n");
> +}
> +
> +static inline void diag9c(uint64_t val)
> +{
> + asm volatile("diag %[val],0,0x9c\n"
> + :
> + : [val] "d"(val)
> + );
> +}
> +
> #endif

[...]

> +static inline void force_exit(void)
> +{
> + diag44();
> + mb(); /* allow host to modify guest memory */
> +}
> +
> +static inline void force_exit_value(uint64_t val)
> +{
> + diag9c(val);
> + mb(); /* allow host to modify guest memory */
> +}

why not adding "memory" to the clobbers of the inline asm? (not a big
deal, I'm just curious if there is a specific reason for an explicit
mb()) …