KVM Archive on lore.kernel.org
 help / color / Atom feed
From: Claudio Imbrenda <imbrenda@linux.ibm.com>
To: Janosch Frank <frankja@linux.ibm.com>
Cc: kvm@vger.kernel.org, linux-s390@vger.kernel.org,
	thuth@redhat.com, david@redhat.com
Subject: Re: [kvm-unit-tests PATCH 3/6] s390x: uv: Add UV lib
Date: Tue, 20 Apr 2021 16:15:27 +0200
Message-ID: <20210420161527.615fb8f6@ibm-vm> (raw)
In-Reply-To: <20210316091654.1646-4-frankja@linux.ibm.com>

On Tue, 16 Mar 2021 09:16:51 +0000
Janosch Frank <frankja@linux.ibm.com> wrote:

> Let's add a UV library to make checking the UV feature bit easier.
> In the future this library file can take care of handling UV
> initialization and UV guest creation.
> 
> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>

Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>

but see some comments below

> ---
>  lib/s390x/asm/uv.h |  4 ++--
>  lib/s390x/io.c     |  2 ++
>  lib/s390x/uv.c     | 48
> ++++++++++++++++++++++++++++++++++++++++++++++ lib/s390x/uv.h     |
> 10 ++++++++++ s390x/Makefile     |  1 +
>  5 files changed, 63 insertions(+), 2 deletions(-)
>  create mode 100644 lib/s390x/uv.c
>  create mode 100644 lib/s390x/uv.h
> 
> diff --git a/lib/s390x/asm/uv.h b/lib/s390x/asm/uv.h
> index 11f70a9f..b22cbaa8 100644
> --- a/lib/s390x/asm/uv.h
> +++ b/lib/s390x/asm/uv.h
> @@ -9,8 +9,8 @@
>   * This code is free software; you can redistribute it and/or modify
> it
>   * under the terms of the GNU General Public License version 2.
>   */
> -#ifndef UV_H
> -#define UV_H
> +#ifndef ASM_S390X_UV_H
> +#define ASM_S390X_UV_H
>  
>  #define UVC_RC_EXECUTED		0x0001
>  #define UVC_RC_INV_CMD		0x0002
> diff --git a/lib/s390x/io.c b/lib/s390x/io.c
> index ef9f59e3..a4f1b113 100644
> --- a/lib/s390x/io.c
> +++ b/lib/s390x/io.c
> @@ -14,6 +14,7 @@
>  #include <asm/facility.h>
>  #include <asm/sigp.h>
>  #include "sclp.h"
> +#include "uv.h"
>  #include "smp.h"
>  
>  extern char ipl_args[];
> @@ -38,6 +39,7 @@ void setup(void)
>  	sclp_facilities_setup();
>  	sclp_console_setup();
>  	sclp_memory_setup();
> +	uv_setup();
>  	smp_setup();
>  }
>  
> diff --git a/lib/s390x/uv.c b/lib/s390x/uv.c
> new file mode 100644
> index 00000000..a84a85fc
> --- /dev/null
> +++ b/lib/s390x/uv.c
> @@ -0,0 +1,48 @@
> +#include <libcflat.h>
> +#include <bitops.h>
> +#include <alloc.h>
> +#include <alloc_page.h>
> +#include <asm/page.h>
> +#include <asm/arch_def.h>
> +
> +#include <asm/facility.h>
> +#include <asm/uv.h>
> +#include <uv.h>
> +
> +static struct uv_cb_qui uvcb_qui = {
> +	.header.cmd = UVC_CMD_QUI,
> +	.header.len = sizeof(uvcb_qui),
> +};
> +
> +bool uv_os_is_guest(void)
> +{
> +	return uv_query_test_feature(BIT_UVC_CMD_SET_SHARED_ACCESS)
> +		&&
> uv_query_test_feature(BIT_UVC_CMD_REMOVE_SHARED_ACCESS); +}
> +
> +bool uv_os_is_host(void)
> +{
> +	return uv_query_test_feature(BIT_UVC_CMD_INIT_UV);
> +}
> +
> +bool uv_query_test_feature(int nr)
> +{
> +	/* Query needs to be called first */
> +	if (!uvcb_qui.header.rc)
> +		return false;

why not an assert?

> +
> +	return test_bit_inv(nr, uvcb_qui.inst_calls_list);
> +}
> +
> +int uv_setup(void)
> +{
> +	int cc;
> +
> +	if (!test_facility(158))
> +		return 0;
> +
> +	cc = uv_call(0, (u64)&uvcb_qui);
> +	assert(cc == 0);
> +
> +	return cc == 0;

sooo... return 1?

> +}
> diff --git a/lib/s390x/uv.h b/lib/s390x/uv.h
> new file mode 100644
> index 00000000..159bf8e5
> --- /dev/null
> +++ b/lib/s390x/uv.h
> @@ -0,0 +1,10 @@
> +/* SPDX-License-Identifier: GPL-2.0-or-later */
> +#ifndef UV_H
> +#define UV_H
> +
> +bool uv_os_is_guest(void);
> +bool uv_os_is_host(void);
> +bool uv_query_test_feature(int nr);
> +int uv_setup(void);
> +
> +#endif /* UV_H */
> diff --git a/s390x/Makefile b/s390x/Makefile
> index b92de9c5..bbf177fa 100644
> --- a/s390x/Makefile
> +++ b/s390x/Makefile
> @@ -67,6 +67,7 @@ cflatobjs += lib/s390x/vm.o
>  cflatobjs += lib/s390x/css_dump.o
>  cflatobjs += lib/s390x/css_lib.o
>  cflatobjs += lib/s390x/malloc_io.o
> +cflatobjs += lib/s390x/uv.o
>  
>  OBJDIRS += lib/s390x
>  


  reply index

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-16  9:16 [kvm-unit-tests PATCH 0/6] s390x: uv: Extend guest test and add host test Janosch Frank
2021-03-16  9:16 ` [kvm-unit-tests PATCH 1/6] s390x: uv-guest: Add invalid share location test Janosch Frank
2021-04-19 11:24   ` Thomas Huth
2021-04-19 11:45     ` Janosch Frank
2021-04-20  8:48       ` Thomas Huth
2021-04-20 13:40   ` Claudio Imbrenda
2021-04-21 11:04   ` Cornelia Huck
2021-03-16  9:16 ` [kvm-unit-tests PATCH 2/6] s390x: Add more Ultravisor command structure definitions Janosch Frank
2021-04-20 14:09   ` Claudio Imbrenda
2021-04-21 11:13   ` Cornelia Huck
2021-04-26 14:33     ` Janosch Frank
2021-03-16  9:16 ` [kvm-unit-tests PATCH 3/6] s390x: uv: Add UV lib Janosch Frank
2021-04-20 14:15   ` Claudio Imbrenda [this message]
2021-04-26 14:20     ` Janosch Frank
2021-03-16  9:16 ` [kvm-unit-tests PATCH 4/6] s390x: Test for share/unshare call support before using them Janosch Frank
2021-04-20 14:18   ` Claudio Imbrenda
2021-03-16  9:16 ` [kvm-unit-tests PATCH 5/6] s390x: uv-guest: Test invalid commands Janosch Frank
2021-04-20 14:26   ` Claudio Imbrenda
2021-04-26 13:40     ` Janosch Frank
2021-03-16  9:16 ` [kvm-unit-tests PATCH 6/6] s390x: Add UV host test Janosch Frank
2021-04-20 15:47   ` Claudio Imbrenda
2021-04-26 14:31     ` Janosch Frank
2021-04-19  7:24 ` [kvm-unit-tests PATCH 0/6] s390x: uv: Extend guest test and add " Janosch Frank

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210420161527.615fb8f6@ibm-vm \
    --to=imbrenda@linux.ibm.com \
    --cc=david@redhat.com \
    --cc=frankja@linux.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

KVM Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/kvm/0 kvm/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 kvm kvm/ https://lore.kernel.org/kvm \
		kvm@vger.kernel.org
	public-inbox-index kvm

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.kvm


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git