Re: [kvm-unit-tests PATCH v3] powerpc: Check whether TM is available before running other tests

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

 




On 04/10/2016 11:07, Thomas Huth wrote:
> Transactional memory is currently only supported on KVM-HV, and
> not yet on KVM-PR. So it's better to check the device tree first
> and fail gracefully if it is not available.
> 
> Reviewed-by: Laurent Vivier <lvivier@xxxxxxxxxx>
> Reviewed-by: Andrew Jones <drjones@xxxxxxxxxx> 
> Signed-off-by: Thomas Huth <thuth@xxxxxxxxxx>
> ---
>  v3:
>  - Removed unnecessary check for "plen >= 26" in cpu_has_tm()
> 
>  v2:
>  - Reworked the check for the "ibm,pa-features" and added a comment
>  - Use a dedicated variable "has_tm" instead of "i" in main()
> 
>  powerpc/tm.c | 43 ++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 42 insertions(+), 1 deletion(-)
> 
> diff --git a/powerpc/tm.c b/powerpc/tm.c
> index 6ce750a..b611061 100644
> --- a/powerpc/tm.c
> +++ b/powerpc/tm.c
> @@ -10,6 +10,41 @@
>  #include <asm/processor.h>
>  #include <asm/handlers.h>
>  #include <asm/smp.h>
> +#include <asm/setup.h>
> +#include <devicetree.h>
> +
> +/* Check "ibm,pa-features" property of a CPU node for the TM flag */
> +static void cpu_has_tm(int fdtnode, u32 regval __unused, void *ptr)
> +{
> +	const struct fdt_property *prop;
> +	int plen;
> +
> +	prop = fdt_get_property(dt_fdt(), fdtnode, "ibm,pa-features", &plen);
> +	if (!prop)	/* No features means TM is also not available */
> +		return;
> +	/* Sanity check for the property layout (first two bytes are header) */
> +	assert(plen >= 8 && prop->data[1] == 0 && prop->data[0] <= plen - 2);
> +
> +	/*
> +	 * The "Transactional Memory Category Support" flags are at byte
> +	 * offset 22 and 23 of the attribute type 0, so when adding the
> +	 * two bytes for the header, we've got to look at offset 24 for
> +	 * the TM support bit.
> +	 */
> +	if (prop->data[0] >= 24 && (prop->data[24] & 0x80) != 0)
> +		*(int *)ptr += 1;
> +}

in the future, if we think we can have more than the type 0, we should
scan the property with something like:

  off = 0
  while (off + 1 < plen) {
    if (prop->data[off + 1] != 0) {
      off += 2 + prop->data[off];
      continue;
    }
    ... check TM ...
  }

but I don't think we need that now...

Laurent
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[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