linux-s390.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: Janosch Frank <frankja@linux.ibm.com>, kvm@vger.kernel.org
Cc: linux-s390@vger.kernel.org, imbrenda@linux.ibm.com,
	david@redhat.com, cohuck@redhat.com
Subject: Re: [kvm-unit-tests RFC 1/2] s390x: Add guest snippet support
Date: Mon, 21 Jun 2021 12:10:45 +0200	[thread overview]
Message-ID: <b5171773-afb6-e148-a82f-ea78877206ce@redhat.com> (raw)
In-Reply-To: <20210520094730.55759-2-frankja@linux.ibm.com>

On 20/05/2021 11.47, Janosch Frank wrote:
> Snippets can be used to easily write and run guest (SIE) tests.
> The snippet is linked into the test binaries and can therefore be
> accessed via a ptr.
> 
> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
> ---
>   .gitignore                |  2 ++
>   s390x/Makefile            | 28 ++++++++++++++++++---
>   s390x/snippets/c/cstart.S | 13 ++++++++++
>   s390x/snippets/c/flat.lds | 51 +++++++++++++++++++++++++++++++++++++++
>   4 files changed, 91 insertions(+), 3 deletions(-)
>   create mode 100644 s390x/snippets/c/cstart.S
>   create mode 100644 s390x/snippets/c/flat.lds
> 
> diff --git a/.gitignore b/.gitignore
> index 784cb2dd..29d3635b 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -22,3 +22,5 @@ cscope.*
>   /api/dirty-log
>   /api/dirty-log-perf
>   /s390x/*.bin
> +/s390x/snippets/*/*.bin
> +/s390x/snippets/*/*.gbin
> diff --git a/s390x/Makefile b/s390x/Makefile
> index 8de926ab..fe267011 100644
> --- a/s390x/Makefile
> +++ b/s390x/Makefile
> @@ -75,11 +75,33 @@ OBJDIRS += lib/s390x
>   asmlib = $(TEST_DIR)/cstart64.o $(TEST_DIR)/cpu.o
>   
>   FLATLIBS = $(libcflat)
> -%.elf: %.o $(FLATLIBS) $(SRCDIR)/s390x/flat.lds $(asmlib)
> +
> +SNIPPET_DIR = $(TEST_DIR)/snippets
> +
> +# C snippets that need to be linked
> +snippets-c =
> +
> +# ASM snippets that are directly compiled and converted to a *.gbin
> +snippets-a =

Could you please call this snippets-s instead of ...-a ? The -a suffix looks 
like an archive to me otherwise.

> +snippets = $(snippets-a)$(snippets-c)

Shouldn't there be a space between the two?

> +snippets-o += $(patsubst %.gbin,%.o,$(snippets))
> +
> +$(snippets-a): $(snippets-o) $(FLATLIBS)
> +	$(OBJCOPY) -O binary $(patsubst %.gbin,%.o,$@) $@
> +	$(OBJCOPY) -I binary -O elf64-s390 -B "s390:64-bit" $@ $@
> +
> +$(snippets-c): $(snippets-o) $(SNIPPET_DIR)/c/cstart.o  $(FLATLIBS)
> +	$(CC) $(LDFLAGS) -o $@ -T $(SNIPPET_DIR)/c/flat.lds \
> +		$(filter %.o, $^) $(FLATLIBS)
> +	$(OBJCOPY) -O binary $@ $@
> +	$(OBJCOPY) -I binary -O elf64-s390 -B "s390:64-bit" $@ $@
> +
> +%.elf: $(snippets) %.o $(FLATLIBS) $(SRCDIR)/s390x/flat.lds $(asmlib)
>   	$(CC) $(CFLAGS) -c -o $(@:.elf=.aux.o) \
>   		$(SRCDIR)/lib/auxinfo.c -DPROGNAME=\"$@\"
>   	$(CC) $(LDFLAGS) -o $@ -T $(SRCDIR)/s390x/flat.lds \
> -		$(filter %.o, $^) $(FLATLIBS) $(@:.elf=.aux.o)
> +		$(filter %.o, $^) $(FLATLIBS) $(snippets) $(@:.elf=.aux.o)

Does this link the snippets into all elf files? ... wouldn't it be better to 
restrict it somehow to the files that really need them?

>   	$(RM) $(@:.elf=.aux.o)
>   	@chmod a-x $@
>   
> @@ -93,7 +115,7 @@ FLATLIBS = $(libcflat)
>   	$(GENPROTIMG) --host-key-document $(HOST_KEY_DOCUMENT) --no-verify --image $< -o $@
>   
>   arch_clean: asm_offsets_clean
> -	$(RM) $(TEST_DIR)/*.{o,elf,bin} $(TEST_DIR)/.*.d lib/s390x/.*.d
> +	$(RM) $(TEST_DIR)/*.{o,elf,bin} $(SNIPPET_DIR)/c/*.{o,elf,bin,gbin} $(SNIPPET_DIR)/.*.d $(TEST_DIR)/.*.d lib/s390x/.*.d
>   
>   generated-files = $(asm-offsets)
>   $(tests:.elf=.o) $(asmlib) $(cflatobjs): $(generated-files)
> diff --git a/s390x/snippets/c/cstart.S b/s390x/snippets/c/cstart.S
> new file mode 100644
> index 00000000..02a3338b
> --- /dev/null
> +++ b/s390x/snippets/c/cstart.S
> @@ -0,0 +1,13 @@
> +#include <asm/sigp.h>
> +
> +.section .init
> +	.globl start
> +start:
> +	/* XOR all registers with themselves to clear them fully. */
> +	.irp i, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
> +	xgr \i,\i
> +	.endr
> +	/* 0x3000 is the stack page for now */
> +	lghi	%r15, 0x4000
> +	brasl	%r14, main
> +	sigp    %r1, %r0, SIGP_STOP

I think you should clear r0 before using it here?

  Thomas


  parent reply	other threads:[~2021-06-21 10:10 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-20  9:47 [kvm-unit-tests RFC 0/2] s390x: Add snippet support Janosch Frank
2021-05-20  9:47 ` [kvm-unit-tests RFC 1/2] s390x: Add guest " Janosch Frank
2021-05-25 16:44   ` Claudio Imbrenda
2021-05-26 10:12     ` Janosch Frank
2021-06-21 10:10   ` Thomas Huth [this message]
2021-06-21 12:19     ` Janosch Frank
2021-06-21 12:32       ` Thomas Huth
2021-06-21 12:39         ` Janosch Frank
2021-06-21 13:28           ` Thomas Huth
2021-06-21 14:42             ` Janosch Frank
2021-06-21 14:59               ` Thomas Huth
2021-05-20  9:47 ` [kvm-unit-tests RFC 2/2] s390x: mvpg: Add SIE mvpg test Janosch Frank
2021-05-25 17:37   ` Claudio Imbrenda
2021-05-26 10:17     ` Janosch Frank
2021-05-27 14:35     ` Janosch Frank
2021-06-21 10:23   ` Thomas Huth
2021-06-21 12:41     ` Janosch Frank
2021-05-20 13:36 ` [kvm-unit-tests RFC 0/2] s390x: Add snippet support David Hildenbrand

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=b5171773-afb6-e148-a82f-ea78877206ce@redhat.com \
    --to=thuth@redhat.com \
    --cc=cohuck@redhat.com \
    --cc=david@redhat.com \
    --cc=frankja@linux.ibm.com \
    --cc=imbrenda@linux.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).