Re: [kvm-unit-tests PATCH v2 1/2] lib: s390x: add header for CMM related defines

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

 



On Wed, 11 May 2022 10:56:51 +0200
Nico Boehr <nrb@xxxxxxxxxxxxx> wrote:

> Since we're going to need the definitions in an upcoming migration test for CMM,
> add a header for CMM related defines. It is based on
> arch/s390/include/asm/page-states.h from linux.
> 
> While at it, use the constants in existing calls to CMM related functions.
> 
> Also move essa() and test_availability() there to be able to use it outside
> cmm.c.
> 
> Signed-off-by: Nico Boehr <nrb@xxxxxxxxxxxxx>

Reviewed-by: Claudio Imbrenda <imbrenda@xxxxxxxxxxxxx>

> ---
>  lib/s390x/asm/cmm.h | 50 +++++++++++++++++++++++++++++++++++++++++++++
>  s390x/cmm.c         | 25 +++--------------------
>  2 files changed, 53 insertions(+), 22 deletions(-)
>  create mode 100644 lib/s390x/asm/cmm.h
> 
> diff --git a/lib/s390x/asm/cmm.h b/lib/s390x/asm/cmm.h
> new file mode 100644
> index 000000000000..554a60031fbf
> --- /dev/null
> +++ b/lib/s390x/asm/cmm.h
> @@ -0,0 +1,50 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +/*
> + *    Copyright IBM Corp. 2017, 2022
> + *    Author(s): Claudio Imbrenda <imbrenda@xxxxxxxxxxxxxxxxxx>
> + *               Nico Boehr <nrb@xxxxxxxxxxxxx>
> + */
> +#include <asm/interrupt.h>
> +
> +#ifndef PAGE_STATES_H
> +#define PAGE_STATES_H
> +
> +#define ESSA_GET_STATE			0
> +#define ESSA_SET_STABLE			1
> +#define ESSA_SET_UNUSED			2
> +#define ESSA_SET_VOLATILE		3
> +#define ESSA_SET_POT_VOLATILE		4
> +#define ESSA_SET_STABLE_RESIDENT	5
> +#define ESSA_SET_STABLE_IF_RESIDENT	6
> +#define ESSA_SET_STABLE_NODAT		7
> +
> +#define ESSA_MAX	ESSA_SET_STABLE_NODAT
> +
> +#define ESSA_USAGE_STABLE		0
> +#define ESSA_USAGE_UNUSED		1
> +#define ESSA_USAGE_POT_VOLATILE		2
> +#define ESSA_USAGE_VOLATILE		3
> +
> +static unsigned long essa(uint8_t state, unsigned long paddr)
> +{
> +	uint64_t extr_state;
> +
> +	asm volatile(".insn rrf,0xb9ab0000,%[extr_state],%[addr],%[new_state],0" \
> +			: [extr_state] "=d" (extr_state) \
> +			: [addr] "a" (paddr), [new_state] "i" (state));
> +
> +	return (unsigned long)extr_state;
> +}
> +
> +/*
> + * Unfortunately the availability is not indicated by stfl bits, but
> + * we have to try to execute it and test for an operation exception.
> + */
> +static inline bool check_essa_available(void)
> +{
> +	expect_pgm_int();
> +	essa(ESSA_GET_STATE, 0);
> +	return clear_pgm_int() == 0;
> +}
> +
> +#endif
> diff --git a/s390x/cmm.c b/s390x/cmm.c
> index c3f0c931ae36..af852838851e 100644
> --- a/s390x/cmm.c
> +++ b/s390x/cmm.c
> @@ -12,19 +12,10 @@
>  #include <asm/asm-offsets.h>
>  #include <asm/interrupt.h>
>  #include <asm/page.h>
> +#include <asm/cmm.h>
>  
>  static uint8_t pagebuf[PAGE_SIZE] __attribute__((aligned(PAGE_SIZE)));
>  
> -static unsigned long essa(uint8_t state, unsigned long paddr)
> -{
> -	uint64_t extr_state;
> -
> -	asm volatile(".insn rrf,0xb9ab0000,%[extr_state],%[addr],%[new_state],0"
> -			: [extr_state] "=d" (extr_state)
> -			: [addr] "a" (paddr), [new_state] "i" (state));
> -	return (unsigned long)extr_state;
> -}
> -
>  static void test_params(void)
>  {
>  	report_prefix_push("invalid ORC 8");
> @@ -39,24 +30,14 @@ static void test_priv(void)
>  	report_prefix_push("privileged");
>  	expect_pgm_int();
>  	enter_pstate();
> -	essa(0, (unsigned long)pagebuf);
> +	essa(ESSA_GET_STATE, (unsigned long)pagebuf);
>  	check_pgm_int_code(PGM_INT_CODE_PRIVILEGED_OPERATION);
>  	report_prefix_pop();
>  }
>  
> -/* Unfortunately the availability is not indicated by stfl bits, but
> - * we have to try to execute it and test for an operation exception.
> - */
> -static bool test_availability(void)
> -{
> -	expect_pgm_int();
> -	essa(0, (unsigned long)pagebuf);
> -	return clear_pgm_int() == 0;
> -}
> -
>  int main(void)
>  {
> -	bool has_essa = test_availability();
> +	bool has_essa = check_essa_available();
>  
>  	report_prefix_push("cmm");
>  	if (!has_essa) {




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Kernel Development]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Info]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Linux Media]     [Device Mapper]

  Powered by Linux