Re: [kvm-unit-tests PATCH v3 6/8] s390x: Add cmm tests

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

 



On 27.03.2018 13:55, Janosch Frank wrote:
> Collaborative Memory Management is the extended vm memory usage
> hinting for the hypervisor and handling the ESSA instruction is quite
> complicated. Let's add at least a bare-bones test, maybe someone will
> extend it later.
> 
> Signed-off-by: Janosch Frank <frankja@xxxxxxxxxxxxxxxxxx>
> ---
>  s390x/Makefile      |  1 +
>  s390x/cmm.c         | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  s390x/unittests.cfg |  3 +++
>  3 files changed, 73 insertions(+)
>  create mode 100644 s390x/cmm.c
> 
> diff --git a/s390x/Makefile b/s390x/Makefile
> index 074c32e..d80ca96 100644
> --- a/s390x/Makefile
> +++ b/s390x/Makefile
> @@ -6,6 +6,7 @@ tests += $(TEST_DIR)/sthyi.elf
>  tests += $(TEST_DIR)/skey.elf
>  tests += $(TEST_DIR)/diag10.elf
>  tests += $(TEST_DIR)/pfmf.elf
> +tests += $(TEST_DIR)/cmm.elf
>  
>  all: directories test_cases
>  
> diff --git a/s390x/cmm.c b/s390x/cmm.c
> new file mode 100644
> index 0000000..9e6a193
> --- /dev/null
> +++ b/s390x/cmm.c
> @@ -0,0 +1,69 @@
> +/*
> + * CMM tests (ESSA)
> + *
> + * Copyright (c) 2018 IBM Corp
> + *
> + * Authors:
> + *  Janosch Frank <frankja@xxxxxxxxxxxxxxxxxx>
> + *
> + * This code is free software; you can redistribute it and/or modify it
> + * under the terms of the GNU Library General Public License version 2.
> + */
> +
> +#include <libcflat.h>
> +#include <asm/asm-offsets.h>
> +#include <asm/interrupt.h>
> +#include <asm/page.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)
> +{
> +	expect_pgm_int();
> +	essa(8, (unsigned long)pagebuf);
> +	check_pgm_int_code(PGM_INT_CODE_SPECIFICATION);
> +}
> +
> +static void test_priv(void)
> +{
> +	expect_pgm_int();
> +	enter_pstate();
> +	essa(0, (unsigned long)pagebuf);
> +	check_pgm_int_code(PGM_INT_CODE_PRIVILEGED_OPERATION);
> +}
> +
> +/* 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();
> +
> +	report_prefix_push("cmm");
> +	report_xfail("ESSA available", !has_essa, has_essa);
> +	if (!has_essa)
> +		goto done;
> +
> +	test_priv();
> +	test_params();
> +done:
> +	report_prefix_pop();
> +	return report_summary();
> +}
> diff --git a/s390x/unittests.cfg b/s390x/unittests.cfg
> index a420457..63135d5 100644
> --- a/s390x/unittests.cfg
> +++ b/s390x/unittests.cfg
> @@ -46,3 +46,6 @@ file = diag10.elf
>  
>  [pfmf]
>  file = pfmf.elf
> +
> +[cmm]
> +file = cmm.elf
> 

Reviewed-by: Thomas Huth <thuth@xxxxxxxxxx>



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux