Skip to contentSkip to conversation

VPHN parsing fixes

PATCH Superseded Greg Kurz 2 participants 9 messages Dec 17, 2014 – Feb 4, 2015 PowerPC

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Greg Kurz

author
#0 lore raw

v2 cover VPHN parsing fixes

Hi,

This series addresses remarks from Ben and Michael (see individual patches). The most notable changes are:
- the parsing code being pull out into a separate file in patch 3/4. This allows to write userland tests like the one below.
- a full rewrite of the parsing logic in patch 4/4

--
#include <stdio.h>
#include <byteswap.h>

typedef unsigned long u64;
typedef unsigned int u32;
typedef unsigned short u16;
typedef enum { false = 0, true } bool;

#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
#define cpu_to_be32(x) bswap_32(x)
#define be32_to_cpu(x) bswap_32(x)
#define be16_to_cpup(x) bswap_16(*x)
#define cpu_to_be64(x) bswap_64(x)
#else
#define cpu_to_be32(x) (x)
#define be32_to_cpu(x) (x)
#define be16_to_cpup(x) (*x)
#define cpu_to_be64(x) (x)
#endif

#define pr_debug(...) printf(__VA_ARGS__)

#include "vphn.c"

void print_packed(const long *packed)

{
	char *p = (char*) packed;
	int i;

	printf("\nRegisters:\n");
	for (i = 0; i < VPHN_REGISTER_COUNT; i++)
		printf("0x%016lx\n", packed[i]);

	printf("\nMemory layout:\n");
	for (i = 0; i < 6; i++) {
		printf("0x %02hhx %02hhx %02hhx %02hhx"
		       " %02hhx %02hhx %02hhx %02hhx\n",
		       *(p + 0), *(p + 1), *(p + 2), *(p + 3),
		       *(p + 4), *(p + 5), *(p + 6), *(p + 7));
		p += 8;
	}

	putchar('\n');
}

void print_unpacked(const __be32 *unpacked)

{
	int i;

	printf("\nVPHN associativity:\n");
	for (i = 0; i <= be32_to_cpu(unpacked[0]); i++)
		printf("0x%08x\n", be32_to_cpu(unpacked[i]));

	putchar('\n');
}

int main(int argc, char **argv)

{
	int i;
	struct {
		const char *descr;
		long packed[VPHN_REGISTER_COUNT];
	} data[] = {
		{
			"16-bit and 32-bit",
			0x8001800280038004,
			0x8005800680078008,
			0x000000090000000a,
			0x0000000b0000000c,
			0xffffffffffffffff,
			0xffffffffffffffff
		},
		{
			"filled with 16-bit",
			0x8001800280038004,
			0x8005800680078008,
			0x8009800a800b800c,
			0x800d800e800f8010,
			0x8011801280138014,
			0x8015801680178018,
		},
		{
			"filled with 32-bit",
			0x0000000100000002,
			0x0000000300000004,
			0x0000000500000006,
			0x0000000700000008,
			0x000000090000000a,
			0x0000000b0000000c,
		},
		{
			"32-bit has all ones in 16 lower bits",
			0x0001ffff80028003,
			0xffffffffffffffff,
			0xffffffffffffffff,
			0xffffffffffffffff,
			0xffffffffffffffff,
			0xffffffffffffffff,
		},
		{
			"32-bit accross two 64-bit registers",
			0x8001000000020000,
			0x0003000000048005,
			0xffffffffffffffff,
			0xffffffffffffffff,
			0xffffffffffffffff,
			0xffffffffffffffff,
		},
		{
			"Truncated last 32-bit",
			0x0000000100000002,
			0x0000000300000004,
			0x0000000500000006,
			0x0000000700000008,
			0x000000090000000a,
			0x0000000b800c0bad,
		},
	};

	for (i = 0; i < sizeof(data) / sizeof(data[0]); i++) {
		__be32 unpacked[VPHN_ASSOC_BUFSIZE] = { 0 };
		printf("\n==================================================\n");
		printf("\nSet #%d: %s\n", i, data[i].descr);
		printf("\n==================================================\n");
		print_packed(data[i].packed);
		vphn_unpack_associativity(data[i].packed, unpacked);
		print_unpacked(unpacked);
	}

	return 0;
}

---

Greg Kurz (4):
powerpc/vphn: clarify the H_HOME_NODE_ASSOCIATIVITY API powerpc/vphn: move endianness fixing to vphn_unpack_associativity() powerpc/vphn: move VPHN parsing logic to a separate file powerpc/vphn: parsing code rewrite

 arch/powerpc/mm/Makefile |    1 +
 arch/powerpc/mm/numa.c   |   55 ++----------------------------------
 arch/powerpc/mm/vphn.c   |   70 ++++++++++++++++++++++++++++++++++++++++++++++
 arch/powerpc/mm/vphn.h   |   16 +++++++++++
 4 files changed, 90 insertions(+), 52 deletions(-)
 create mode 100644 arch/powerpc/mm/vphn.c
 create mode 100644 arch/powerpc/mm/vphn.h

--
Greg

author
#1 lore raw

PATCH v2 1/4 powerpc/vphn: clarify the H_HOME_NODE_ASSOCIATIVITY API

The number of values returned by the H_HOME_NODE_ASSOCIATIVITY h_call deserves to be explicitly defined, for a better understanding of the code.

---

No changes in v2.

 arch/powerpc/mm/numa.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
arch/powerpc/mm/numa.c +6 -2
index 417b0a5..2a83e48 100644
@@ -1247,11 +1247,15 @@ static int update_cpu_associativity_changes_mask(void)
 	return cpumask_weight(changes);
 }
 
+/* The H_HOME_NODE_ASSOCIATIVITY h_call returns 6 64-bit registers.
+ */
+#define VPHN_REGISTER_COUNT 6
+
 /*
  * 6 64-bit registers unpacked into 12 32-bit associativity values. To form
  * the complete property we have to add the length in the first cell.
  */
-#define VPHN_ASSOC_BUFSIZE (6*sizeof(u64)/sizeof(u32) + 1)
+#define VPHN_ASSOC_BUFSIZE (VPHN_REGISTER_COUNT*sizeof(u64)/sizeof(u32) + 1)
 
 /*
  * Convert the associativity domain numbers returned from the hypervisor
@@ -1309,7 +1313,7 @@ static long hcall_vphn(unsigned long cpu, __be32 *associativity)
 	int i;
 
 	rc = plpar_hcall9(H_HOME_NODE_ASSOCIATIVITY, retbuf, flags, hwcpu);
-	for (i = 0; i < 6; i++)
+	for (i = 0; i < VPHN_REGISTER_COUNT; i++)
 		retbuf[i] = cpu_to_be64(retbuf[i]);
 	vphn_unpack_associativity(retbuf, associativity);
 
author
#2 lore raw

PATCH v2 2/4 powerpc/vphn: move endianness fixing to vphn_unpack_associativity()

In reply to Greg Kurz

The first argument to vphn_unpack_associativity() is a const long *, but the parsing code expects __be64 values actually. Let's move the endian fixing down for consistency.

---

v2: only move the endian fixing. The logic is reworked in another patch.

 arch/powerpc/mm/numa.c |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
arch/powerpc/mm/numa.c +6 -4
index 2a83e48..2e36a6f 100644
@@ -1263,13 +1263,18 @@ static int update_cpu_associativity_changes_mask(void)
  */
 static int vphn_unpack_associativity(const long *packed, __be32 *unpacked)
 {
+	__be64 be_packed[VPHN_REGISTER_COUNT];
 	int i, nr_assoc_doms = 0;
-	const __be16 *field = (const __be16 *) packed;
+	const __be16 *field = (const __be16 *) be_packed;
 
 #define VPHN_FIELD_UNUSED	(0xffff)
 #define VPHN_FIELD_MSB		(0x8000)
 #define VPHN_FIELD_MASK		(~VPHN_FIELD_MSB)
 
+	/* Let's recreate the original stream. */
+	for (i = 0; i < VPHN_REGISTER_COUNT; i++)
+		be_packed[i] = cpu_to_be64(packed[i]);
+
 	for (i = 1; i < VPHN_ASSOC_BUFSIZE; i++) {
 		if (be16_to_cpup(field) == VPHN_FIELD_UNUSED) {
 			/* All significant fields processed, and remaining
@@ -1310,11 +1315,8 @@ static long hcall_vphn(unsigned long cpu, __be32 *associativity)
 	long retbuf[PLPAR_HCALL9_BUFSIZE] = {0};
 	u64 flags = 1;
 	int hwcpu = get_hard_smp_processor_id(cpu);
-	int i;
 
 	rc = plpar_hcall9(H_HOME_NODE_ASSOCIATIVITY, retbuf, flags, hwcpu);
-	for (i = 0; i < VPHN_REGISTER_COUNT; i++)
-		retbuf[i] = cpu_to_be64(retbuf[i]);
 	vphn_unpack_associativity(retbuf, associativity);
 
 	return rc;
author
#3 lore raw

PATCH v2 3/4 powerpc/vphn: move VPHN parsing logic to a separate file

In reply to Greg Kurz

The goal behind this patch is to be able to write userland tests for the VPHN parsing code.

---
 arch/powerpc/mm/Makefile |    1 +
 arch/powerpc/mm/numa.c   |   61 ++--------------------------------------------
 arch/powerpc/mm/vphn.c   |   50 ++++++++++++++++++++++++++++++++++++++
 arch/powerpc/mm/vphn.h   |   16 ++++++++++++
 4 files changed, 70 insertions(+), 58 deletions(-)
 create mode 100644 arch/powerpc/mm/vphn.c
 create mode 100644 arch/powerpc/mm/vphn.h
arch/powerpc/mm/Makefile +1 -0
index 438dcd3..9c8770b 100644
@@ -24,6 +24,7 @@ obj-$(CONFIG_40x)		+= 40x_mmu.o
 obj-$(CONFIG_44x)		+= 44x_mmu.o
 obj-$(CONFIG_PPC_FSL_BOOK3E)	+= fsl_booke_mmu.o
 obj-$(CONFIG_NEED_MULTIPLE_NODES) += numa.o
+obj-$(CONFIG_PPC_SPLPAR)	+= vphn.o
 obj-$(CONFIG_PPC_MM_SLICES)	+= slice.o
 obj-y				+= hugetlbpage.o
 ifeq ($(CONFIG_HUGETLB_PAGE),y)
arch/powerpc/mm/numa.c +3 -58

73 lines not on this page · raw message

arch/powerpc/mm/vphn.c new file +50 -0

50 lines not on this page · raw message

arch/powerpc/mm/vphn.h new file +16 -0
new file mode 100644
index 0000000..96af9a4
@@ -0,0 +1,16 @@
+#ifndef _ARCH_POWERPC_MM_VPHN_H_
+#define _ARCH_POWERPC_MM_VPHN_H_
+
+/* The H_HOME_NODE_ASSOCIATIVITY h_call returns 6 64-bit registers.
+ */
+#define VPHN_REGISTER_COUNT 6
+
+/*
+ * 6 64-bit registers unpacked into 12 32-bit associativity values. To form
+ * the complete property we have to add the length in the first cell.
+ */
+#define VPHN_ASSOC_BUFSIZE (VPHN_REGISTER_COUNT*sizeof(u64)/sizeof(u32) + 1)
+
+extern int vphn_unpack_associativity(const long *packed, __be32 *unpacked);
+
+#endif
author
#4 lore raw

PATCH v2 4/4 powerpc/vphn: parsing code rewrite

In reply to Greg Kurz

The current VPHN parsing logic has some flaws that this patch aims to fix:

1) when the value 0xffff is read, the value 0xffffffff gets added to the the output list and its element count isn't incremented. This is wrong. According to PAPR+ the domain identifiers are packed into a sequence terminated by the "reserved value of all ones". This means that 0xffff is a stream terminator.

2) the combination of byteswaps and casts make the code hardly readable. Let's parse the stream one 16-bit field at a time instead.

3) it is assumed that the hypercall returns 12 32-bit values packed into 6 64-bit registers. According to PAPR+, the domain identifiers may be streamed as 16-bit values. Let's increase the number of expected numbers to 24.

---
 arch/powerpc/mm/vphn.c |   54 +++++++++++++++++++++++++++++++++---------------
 arch/powerpc/mm/vphn.h |    6 +++--
 2 files changed, 40 insertions(+), 20 deletions(-)
arch/powerpc/mm/vphn.c +37 -17
index c49ed51..5f8ef50 100644
@@ -2,44 +2,64 @@
 #include "vphn.h"
 
 /*
- * Convert the associativity domain numbers returned from the hypervisor
- * to the sequence they would appear in the ibm,associativity property.
+ * The associativity domain numbers are returned from the hypervisor as a
+ * stream of mixed 16-bit and 32-bit fields. The stream is terminated by the
+ * special value of "all ones" (aka. 0xffff) and its size may not exceed 48
+ * bytes.
+ *
+ *    --- 16-bit fields -->
+ *  _________________________
+ *  |  0  |  1  |  2  |  3  |   be_packed[0]
+ *  ------+-----+-----+------
+ *  _________________________
+ *  |  4  |  5  |  6  |  7  |   be_packed[1]
+ *  -------------------------
+ *            ...
+ *  _________________________
+ *  | 20  | 21  | 22  | 23  |   be_packed[5]
+ *  -------------------------
+ *
+ * Convert to the sequence they would appear in the ibm,associativity property.
  */
 int vphn_unpack_associativity(const long *packed, __be32 *unpacked)
 {
 	__be64 be_packed[VPHN_REGISTER_COUNT];
 	int i, nr_assoc_doms = 0;
 	const __be16 *field = (const __be16 *) be_packed;
+	u16 last = 0;
+	bool is_32bit = false;
 
 #define VPHN_FIELD_UNUSED	(0xffff)
 #define VPHN_FIELD_MSB		(0x8000)
 #define VPHN_FIELD_MASK		(~VPHN_FIELD_MSB)
 
-	/* Let's recreate the original stream. */
+	/* Let's fix the values returned by plpar_hcall9() */
 	for (i = 0; i < VPHN_REGISTER_COUNT; i++)
 		be_packed[i] = cpu_to_be64(packed[i]);
 
 	for (i = 1; i < VPHN_ASSOC_BUFSIZE; i++) {
-		if (be16_to_cpup(field) == VPHN_FIELD_UNUSED) {
-			/* All significant fields processed, and remaining
-			 * fields contain the reserved value of all 1's.
-			 * Just store them.
+		u16 new = be16_to_cpup(field++);
+
+		if (is_32bit) {
+			/* Let's concatenate the 16 bits of this field to the
+			 * 15 lower bits of the previous field
 			 */
-			unpacked[i] = *((__be32 *)field);
-			field += 2;
-		} else if (be16_to_cpup(field) & VPHN_FIELD_MSB) {
+			unpacked[++nr_assoc_doms] =
+				cpu_to_be32(last << 16 | new);
+			is_32bit = false;
+		} else if (new == VPHN_FIELD_UNUSED)
+			/* This is the list terminator */
+			break;
+		else if (new & VPHN_FIELD_MSB) {
 			/* Data is in the lower 15 bits of this field */
-			unpacked[i] = cpu_to_be32(
-				be16_to_cpup(field) & VPHN_FIELD_MASK);
-			field++;
-			nr_assoc_doms++;
+			unpacked[++nr_assoc_doms] =
+				cpu_to_be32(new & VPHN_FIELD_MASK);
 		} else {
 			/* Data is in the lower 15 bits of this field
 			 * concatenated with the next 16 bit field
 			 */
-			unpacked[i] = *((__be32 *)field);
-			field += 2;
-			nr_assoc_doms++;
+			last = new;
+			is_32bit = true;
 		}
 	}
 
arch/powerpc/mm/vphn.h +3 -3
index 96af9a4..fe8b780 100644
@@ -6,10 +6,10 @@
 #define VPHN_REGISTER_COUNT 6
 
 /*
- * 6 64-bit registers unpacked into 12 32-bit associativity values. To form
- * the complete property we have to add the length in the first cell.
+ * 6 64-bit registers unpacked into up to 24 be32 associativity values. To
+ * form the complete property we have to add the length in the first cell.
  */
-#define VPHN_ASSOC_BUFSIZE (VPHN_REGISTER_COUNT*sizeof(u64)/sizeof(u32) + 1)
+#define VPHN_ASSOC_BUFSIZE (VPHN_REGISTER_COUNT*sizeof(u64)/sizeof(u16) + 1)
 
 extern int vphn_unpack_associativity(const long *packed, __be32 *unpacked);
 
author
#5 lore raw
In reply to Greg Kurz
Quoted 8 lines · On Wed, 17 Dec 2014 10:40:46 +0100 Greg Kurz <[email protected]> wrote:

Hi,

This series addresses remarks from Ben and Michael (see individual patches). The most notable changes are:
- the parsing code being pull out into a separate file in patch 3/4. This allows to write userland tests like the one below.
- a full rewrite of the parsing logic in patch 4/4

Ping ?

Quoted 157 lines

--
#include <stdio.h>
#include <byteswap.h>

typedef unsigned long u64;
typedef unsigned int u32;
typedef unsigned short u16;
typedef enum { false = 0, true } bool;

#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
#define cpu_to_be32(x) bswap_32(x)
#define be32_to_cpu(x) bswap_32(x)
#define be16_to_cpup(x) bswap_16(*x)
#define cpu_to_be64(x) bswap_64(x)
#else
#define cpu_to_be32(x) (x)
#define be32_to_cpu(x) (x)
#define be16_to_cpup(x) (*x)
#define cpu_to_be64(x) (x)
#endif

#define pr_debug(...) printf(__VA_ARGS__)

#include "vphn.c"

void print_packed(const long *packed)

{
	char *p = (char*) packed;
	int i;

	printf("\nRegisters:\n");
	for (i = 0; i < VPHN_REGISTER_COUNT; i++)
		printf("0x%016lx\n", packed[i]);

	printf("\nMemory layout:\n");
	for (i = 0; i < 6; i++) {
		printf("0x %02hhx %02hhx %02hhx %02hhx"
		       " %02hhx %02hhx %02hhx %02hhx\n",
		       *(p + 0), *(p + 1), *(p + 2), *(p + 3),
		       *(p + 4), *(p + 5), *(p + 6), *(p + 7));
		p += 8;
	}

	putchar('\n');
}

void print_unpacked(const __be32 *unpacked)

{
	int i;

	printf("\nVPHN associativity:\n");
	for (i = 0; i <= be32_to_cpu(unpacked[0]); i++)
		printf("0x%08x\n", be32_to_cpu(unpacked[i]));

	putchar('\n');
}

int main(int argc, char **argv)

{
	int i;
	struct {
		const char *descr;
		long packed[VPHN_REGISTER_COUNT];
	} data[] = {
		{
			"16-bit and 32-bit",
			0x8001800280038004,
			0x8005800680078008,
			0x000000090000000a,
			0x0000000b0000000c,
			0xffffffffffffffff,
			0xffffffffffffffff
		},
		{
			"filled with 16-bit",
			0x8001800280038004,
			0x8005800680078008,
			0x8009800a800b800c,
			0x800d800e800f8010,
			0x8011801280138014,
			0x8015801680178018,
		},
		{
			"filled with 32-bit",
			0x0000000100000002,
			0x0000000300000004,
			0x0000000500000006,
			0x0000000700000008,
			0x000000090000000a,
			0x0000000b0000000c,
		},
		{
			"32-bit has all ones in 16 lower bits",
			0x0001ffff80028003,
			0xffffffffffffffff,
			0xffffffffffffffff,
			0xffffffffffffffff,
			0xffffffffffffffff,
			0xffffffffffffffff,
		},
		{
			"32-bit accross two 64-bit registers",
			0x8001000000020000,
			0x0003000000048005,
			0xffffffffffffffff,
			0xffffffffffffffff,
			0xffffffffffffffff,
			0xffffffffffffffff,
		},
		{
			"Truncated last 32-bit",
			0x0000000100000002,
			0x0000000300000004,
			0x0000000500000006,
			0x0000000700000008,
			0x000000090000000a,
			0x0000000b800c0bad,
		},
	};

	for (i = 0; i < sizeof(data) / sizeof(data[0]); i++) {
		__be32 unpacked[VPHN_ASSOC_BUFSIZE] = { 0 };
		printf("\n==================================================\n");
		printf("\nSet #%d: %s\n", i, data[i].descr);
		printf("\n==================================================\n");
		print_packed(data[i].packed);
		vphn_unpack_associativity(data[i].packed, unpacked);
		print_unpacked(unpacked);
	}

	return 0;
}

---

Greg Kurz (4):
powerpc/vphn: clarify the H_HOME_NODE_ASSOCIATIVITY API powerpc/vphn: move endianness fixing to vphn_unpack_associativity() powerpc/vphn: move VPHN parsing logic to a separate file powerpc/vphn: parsing code rewrite

 arch/powerpc/mm/Makefile |    1 +
 arch/powerpc/mm/numa.c   |   55 ++----------------------------------
 arch/powerpc/mm/vphn.c   |   70 ++++++++++++++++++++++++++++++++++++++++++++++
 arch/powerpc/mm/vphn.h   |   16 +++++++++++
 4 files changed, 90 insertions(+), 52 deletions(-)
 create mode 100644 arch/powerpc/mm/vphn.c
 create mode 100644 arch/powerpc/mm/vphn.h

--
Greg

_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://lists.ozlabs.org/listinfo/linuxppc-dev

#6 lore raw
Quoted 4 lines · Greg Kurz
Quoted 2 lines · On Wed, 17 Dec 2014 10:40:46 +0100 Greg Kurz <[email protected]> wrote:

Hi,

Quoted 8 lines
Quoted 6 lines

This series addresses remarks from Ben and Michael (see individual patches). The most notable changes are:
- the parsing code being pull out into a separate file in patch 3/4. This allows to write userland tests like the one below.
- a full rewrite of the parsing logic in patch 4/4

Ping ?

Sorry, lots of patches needing review.

This looks pretty good at a glance, but did you actually write a userspace test for it? If so please send it. I'm happy to rework it into something that can go in selftests.

cheers

author
#7 lore raw
Quoted 12 lines · On Tue, 03 Feb 2015 13:47:35 +1100 Michael Ellerman <[email protected]> wrote:
Quoted 11 lines · Greg Kurz
Quoted 8 lines · On Wed, 17 Dec 2014 10:40:46 +0100 Greg Kurz <[email protected]> wrote:

Hi,

This series addresses remarks from Ben and Michael (see individual patches). The most notable changes are:
- the parsing code being pull out into a separate file in patch 3/4. This allows to write userland tests like the one below.
- a full rewrite of the parsing logic in patch 4/4

Quoted 4 lines
Quoted 1 line

Ping ?

Sorry, lots of patches needing review.

Heh, no problem. :) Since this isn't bugfix, I can even repost later, when the review pressure is lower.

Quoted 4 lines

This looks pretty good at a glance, but did you actually write a userspace test for it? If so please send it. I'm happy to rework it into something that can go in selftests.

Yes, I wrote the premise of a test program. You can find it in the cover mail of this series:

https://lists.ozlabs.org/pipermail/linuxppc-dev/2014-December/123601.html

I'll have a look at selftests.

Quoted 3 lines

cheers

Thanks.

--
Greg

#8 lore raw
Quoted 15 lines · Greg Kurz
Quoted 12 lines · On Tue, 03 Feb 2015 13:47:35 +1100 Michael Ellerman <[email protected]> wrote:
Quoted 11 lines · Greg Kurz
Quoted 8 lines · On Wed, 17 Dec 2014 10:40:46 +0100 Greg Kurz <[email protected]> wrote:

Hi,

This series addresses remarks from Ben and Michael (see individual patches). The most notable changes are:
- the parsing code being pull out into a separate file in patch 3/4. This allows to write userland tests like the one below.
- a full rewrite of the parsing logic in patch 4/4

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Ping ?

Sorry, lots of patches needing review.

Heh, no problem. :) Since this isn't bugfix, I can even repost later, when the review pressure is lower.

Yeah if you can repost in ~2 weeks that would be perfect.

Quoted 11 lines
Quoted 4 lines

This looks pretty good at a glance, but did you actually write a userspace test for it? If so please send it. I'm happy to rework it into something that can go in selftests.

Yes, I wrote the premise of a test program. You can find it in the cover mail of this series:

https://lists.ozlabs.org/pipermail/linuxppc-dev/2014-December/123601.html

I'll have a look at selftests.

Thanks. That test looks like a good start, there might be some more cases to test though?

If you just copy the tools/testing/selftests/powerpc/tm directory and rename to vhpn, you can probably work out the rest.

cheers