public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: "Nicholas Piggin" <npiggin@gmail.com>
To: "Thomas Huth" <thuth@redhat.com>, <kvm@vger.kernel.org>
Cc: <linuxppc-dev@lists.ozlabs.org>,
	"Laurent Vivier" <lvivier@redhat.com>,
	"Shaoqin Huang" <shahuang@redhat.com>,
	"Andrew Jones" <andrew.jones@linux.dev>,
	"Nico Boehr" <nrb@linux.ibm.com>
Subject: Re: [kvm-unit-tests PATCH v5 10/29] powerpc/sprs: Specify SPRs with data rather than code
Date: Fri, 22 Dec 2023 20:32:51 +1000	[thread overview]
Message-ID: <CXUSLS07KV0L.1YBG3AE5BLHU0@wheely> (raw)
In-Reply-To: <49fe69ad-828e-4ac7-8693-7fd983e5152e@redhat.com>

On Tue Dec 19, 2023 at 4:14 PM AEST, Thomas Huth wrote:
> On 16/12/2023 14.42, Nicholas Piggin wrote:
> > A significant rework that builds an array of 'struct spr', where each
> > element describes an SPR. This makes various metadata about the SPR
> > like name and access type easier to carry and use.
> > 
> > Hypervisor privileged registers are described despite not being used
> > at the moment for completeness, but also the code might one day be
> > reused for a hypervisor-privileged test.
> > 
> > Acked-by: Thomas Huth <thuth@redhat.com>
> > Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> > ---
> >   powerpc/sprs.c | 643 ++++++++++++++++++++++++++++++++++---------------
> >   1 file changed, 450 insertions(+), 193 deletions(-)
> > 
> > diff --git a/powerpc/sprs.c b/powerpc/sprs.c
> > index 57e487ce..cd8b472d 100644
> > --- a/powerpc/sprs.c
> > +++ b/powerpc/sprs.c
> > @@ -28,231 +28,465 @@
> >   #include <asm/processor.h>
> >   #include <asm/barrier.h>
> >   
> > -uint64_t before[1024], after[1024];
> > -
> > -/* Common SPRs for all PowerPC CPUs */
> > -static void set_sprs_common(uint64_t val)
> > +/* "Indirect" mfspr/mtspr which accept a non-constant spr number */
> > +static uint64_t __mfspr(unsigned spr)
> >   {
> > -	mtspr(9, val);		/* CTR */
> > -	// mtspr(273, val);	/* SPRG1 */  /* Used by our exception handler */
> > -	mtspr(274, val);	/* SPRG2 */
> > -	mtspr(275, val);	/* SPRG3 */
> > +	uint64_t tmp;
> > +	uint64_t ret;
> > +
> > +	asm volatile(
> > +"	bcl	20, 31, 1f		\n"
> > +"1:	mflr	%0			\n"
> > +"	addi	%0, %0, (2f-1b)		\n"
> > +"	add	%0, %0, %2		\n"
> > +"	mtctr	%0			\n"
> > +"	bctr				\n"
> > +"2:					\n"
> > +".LSPR=0				\n"
> > +".rept 1024				\n"
> > +"	mfspr	%1, .LSPR		\n"
> > +"	b	3f			\n"
> > +"	.LSPR=.LSPR+1			\n"
> > +".endr					\n"
> > +"3:					\n"
> > +	: "=&r"(tmp),
> > +	  "=r"(ret)
> > +	: "r"(spr*8) /* 8 bytes per 'mfspr ; b' block */
> > +	: "lr", "ctr");
> > +
> > +	return ret;
> >   }
> >   
> > -/* SPRs from PowerPC Operating Environment Architecture, Book III, Vers. 2.01 */
> > -static void set_sprs_book3s_201(uint64_t val)
> > +static void __mtspr(unsigned spr, uint64_t val)
> >   {
> > -	mtspr(18, val);		/* DSISR */
> > -	mtspr(19, val);		/* DAR */
> > -	mtspr(152, val);	/* CTRL */
> > -	mtspr(256, val);	/* VRSAVE */
> > -	mtspr(786, val);	/* MMCRA */
> > -	mtspr(795, val);	/* MMCR0 */
> > -	mtspr(798, val);	/* MMCR1 */
> > +	uint64_t tmp;
> > +
> > +	asm volatile(
> > +"	bcl	20, 31, 1f		\n"
> > +"1:	mflr	%0			\n"
> > +"	addi	%0, %0, (2f-1b)		\n"
> > +"	add	%0, %0, %2		\n"
> > +"	mtctr	%0			\n"
> > +"	bctr				\n"
> > +"2:					\n"
> > +".LSPR=0				\n"
> > +".rept 1024				\n"
> > +"	mtspr	.LSPR, %1		\n"
> > +"	b	3f			\n"
> > +"	.LSPR=.LSPR+1			\n"
> > +".endr					\n"
> > +"3:					\n"
> > +	: "=&r"(tmp)
> > +	: "r"(val),
> > +	  "r"(spr*8) /* 8 bytes per 'mfspr ; b' block */
> > +	: "lr", "ctr", "xer");
> >   }
> >   
> > +static uint64_t before[1024], after[1024];
> > +
> > +#define SPR_PR_READ	0x0001
> > +#define SPR_PR_WRITE	0x0002
> > +#define SPR_OS_READ	0x0010
> > +#define SPR_OS_WRITE	0x0020
> > +#define SPR_HV_READ	0x0100
> > +#define SPR_HV_WRITE	0x0200
> > +
> > +#define RW		0x333
> > +#define RO		0x111
> > +#define WO		0x222
> > +#define OS_RW		0x330
> > +#define OS_RO		0x110
> > +#define OS_WO		0x220
> > +#define HV_RW		0x300
> > +#define HV_RO		0x100
> > +#define HV_WO		0x200
> > +
> > +#define SPR_ASYNC	0x1000	/* May be updated asynchronously */
> > +#define SPR_INT		0x2000	/* May be updated by synchronous interrupt */
> > +#define SPR_HARNESS	0x4000	/* Test harness uses the register */
> > +
> > +struct spr {
> > +	const char	*name;
> > +	uint8_t		width;
> > +	uint16_t	access;
> > +	uint16_t	type;
> > +};
> > +
> > +/* SPRs common denominator back to PowerPC Operating Environment Architecture */
> > +static const struct spr sprs_common[1024] = {
> > +  [1] = {"XER",		64,	RW,		SPR_HARNESS, }, /* Compiler */
> > +  [8] = {"LR", 		64,	RW,		SPR_HARNESS, }, /* Compiler, mfspr/mtspr */
> > +  [9] = {"CTR",		64,	RW,		SPR_HARNESS, }, /* Compiler, mfspr/mtspr */
> > + [18] = {"DSISR",	32,	OS_RW,		SPR_INT, },
> > + [19] = {"DAR",		64,	OS_RW,		SPR_INT, },
> > + [26] = {"SRR0",	64,	OS_RW,		SPR_INT, },
> > + [27] = {"SRR1",	64,	OS_RW,		SPR_INT, },
> > +[268] = {"TB",		64,	RO	,	SPR_ASYNC, },
> > +[269] = {"TBU",		32,	RO,		SPR_ASYNC, },
> > +[272] = {"SPRG0",	64,	OS_RW,		SPR_HARNESS, }, /* Int stack */
> > +[273] = {"SPRG1",	64,	OS_RW,		SPR_HARNESS, }, /* Scratch */
> > +[274] = {"SPRG2",	64,	OS_RW, },
> > +[275] = {"SPRG3",	64,	OS_RW, },
> > +[287] = {"PVR",		32,	OS_RO, },
>
> Just a little stylish nit: You've got a space before the closing "}", but no 
> space after the opening "{". Looks a little bit weird to me. Maybe add a 
> space after the "{", too?

Yes that is inconsistent. I'll fix.

Thanks,
Nick

  reply	other threads:[~2023-12-22 10:32 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-16 13:42 [kvm-unit-tests PATCH v5 00/29] powerpc: updates, P10, PNV support Nicholas Piggin
2023-12-16 13:42 ` [kvm-unit-tests PATCH v5 01/29] arch-run: Clean up temporary files properly Nicholas Piggin
2023-12-16 13:42 ` [kvm-unit-tests PATCH v5 02/29] arch-run: Clean up initrd cleanup Nicholas Piggin
2023-12-16 13:42 ` [kvm-unit-tests PATCH v5 03/29] migration: use a more robust way to wait for background job Nicholas Piggin
2023-12-16 13:42 ` [kvm-unit-tests PATCH v5 04/29] migration: Support multiple migrations Nicholas Piggin
2023-12-16 13:42 ` [kvm-unit-tests PATCH v5 05/29] arch-run: rename migration variables Nicholas Piggin
2023-12-16 13:42 ` [kvm-unit-tests PATCH v5 06/29] powerpc: Quiet QEMU TCG pseries capability warnings Nicholas Piggin
2023-12-19  5:55   ` Thomas Huth
2023-12-16 13:42 ` [kvm-unit-tests PATCH v5 07/29] powerpc: Add a migration stress tester Nicholas Piggin
2023-12-19  5:58   ` Thomas Huth
2023-12-22 10:32     ` Nicholas Piggin
2023-12-16 13:42 ` [kvm-unit-tests PATCH v5 08/29] powerpc: Require KVM for the TM test Nicholas Piggin
2023-12-19  5:59   ` Thomas Huth
2023-12-16 13:42 ` [kvm-unit-tests PATCH v5 09/29] powerpc: Fix interrupt stack alignment Nicholas Piggin
2023-12-19  6:09   ` Thomas Huth
2023-12-16 13:42 ` [kvm-unit-tests PATCH v5 10/29] powerpc/sprs: Specify SPRs with data rather than code Nicholas Piggin
2023-12-19  6:14   ` Thomas Huth
2023-12-22 10:32     ` Nicholas Piggin [this message]
2023-12-16 13:42 ` [kvm-unit-tests PATCH v5 11/29] powerpc/sprs: Don't fail changed SPRs that are used by the test harness Nicholas Piggin
2023-12-19 11:34   ` Thomas Huth
2023-12-16 13:42 ` [kvm-unit-tests PATCH v5 12/29] powerpc/sprs: Avoid taking async interrupts caused by register fuzzing Nicholas Piggin
2023-12-19 11:47   ` Thomas Huth
2023-12-22  9:51     ` Nicholas Piggin
2023-12-16 13:42 ` [kvm-unit-tests PATCH v5 13/29] powerpc: Make interrupt handler error more readable Nicholas Piggin
2023-12-19 11:53   ` Thomas Huth
2023-12-22  9:52     ` Nicholas Piggin
2023-12-16 13:42 ` [kvm-unit-tests PATCH v5 14/29] powerpc: Expand exception handler vector granularity Nicholas Piggin
2023-12-19 11:55   ` Thomas Huth
2023-12-16 13:42 ` [kvm-unit-tests PATCH v5 15/29] powerpc: Add support for more interrupts including HV interrupts Nicholas Piggin
2023-12-16 13:42 ` [kvm-unit-tests PATCH v5 16/29] powerpc: Set .got section alignment to 256 bytes Nicholas Piggin
2023-12-19 12:01   ` Thomas Huth
2023-12-16 13:42 ` [kvm-unit-tests PATCH v5 17/29] powerpc: Discover runtime load address dynamically Nicholas Piggin
2023-12-16 13:42 ` [kvm-unit-tests PATCH v5 18/29] powerpc: Fix stack backtrace termination Nicholas Piggin
2023-12-19 12:22   ` Thomas Huth
2023-12-22  9:55     ` Nicholas Piggin
2023-12-16 13:42 ` [kvm-unit-tests PATCH v5 19/29] scripts: allow machine option to be specified in unittests.cfg Nicholas Piggin
2023-12-19 12:27   ` Thomas Huth
2023-12-16 13:42 ` [kvm-unit-tests PATCH v5 20/29] scripts: Accommodate powerpc powernv machine differences Nicholas Piggin
2023-12-19 12:36   ` Thomas Huth
2023-12-16 13:42 ` [kvm-unit-tests PATCH v5 21/29] powerpc: Support powernv machine with QEMU TCG Nicholas Piggin
2023-12-16 13:42 ` [kvm-unit-tests PATCH v5 22/29] powerpc: Fix emulator illegal instruction test for powernv Nicholas Piggin
2023-12-19 12:39   ` Thomas Huth
2023-12-16 13:42 ` [kvm-unit-tests PATCH v5 23/29] powerpc/sprs: Test hypervisor registers on powernv machine Nicholas Piggin
2023-12-16 13:42 ` [kvm-unit-tests PATCH v5 24/29] powerpc: interrupt tests Nicholas Piggin
2023-12-19 13:57   ` Thomas Huth
2023-12-22  9:58     ` Nicholas Piggin
2023-12-16 13:42 ` [kvm-unit-tests PATCH v5 25/29] powerpc: Add rtas stop-self support Nicholas Piggin
2023-12-19 14:15   ` Thomas Huth
2023-12-16 13:42 ` [kvm-unit-tests PATCH v5 26/29] powerpc: add SMP and IPI support Nicholas Piggin
2023-12-16 13:42 ` [kvm-unit-tests PATCH v5 27/29] powerpc: Avoid using larx/stcx. in spinlocks when only one CPU is running Nicholas Piggin
2023-12-16 13:42 ` [kvm-unit-tests PATCH v5 28/29] powerpc: Add atomics tests Nicholas Piggin
2023-12-16 13:42 ` [kvm-unit-tests PATCH v5 29/29] powerpc: Add timebase tests Nicholas Piggin
2023-12-19 14:23   ` Thomas Huth

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=CXUSLS07KV0L.1YBG3AE5BLHU0@wheely \
    --to=npiggin@gmail.com \
    --cc=andrew.jones@linux.dev \
    --cc=kvm@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=lvivier@redhat.com \
    --cc=nrb@linux.ibm.com \
    --cc=shahuang@redhat.com \
    --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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox