From: Janosch Frank <frankja@linux.ibm.com>
To: Claudio Imbrenda <imbrenda@linux.ibm.com>
Cc: kvm@vger.kernel.org, linux-s390@vger.kernel.org,
david@redhat.com, thuth@redhat.com, cohuck@redhat.com
Subject: Re: [kvm-unit-tests RFC 1/2] s390x: Add guest snippet support
Date: Wed, 26 May 2021 12:12:30 +0200 [thread overview]
Message-ID: <0b971b37-ce5c-74ba-1a59-0863ee2f8354@linux.ibm.com> (raw)
In-Reply-To: <20210525184454.2d0693ef@ibm-vm>
On 5/25/21 6:44 PM, Claudio Imbrenda wrote:
> On Thu, 20 May 2021 09:47:29 +0000
> Janosch Frank <frankja@linux.ibm.com> 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 =
>> +
>> +snippets = $(snippets-a)$(snippets-c)
> ↑↑
> I'm not a Makefile expert, but, don't you need a space between the two
> variable expansions?
>
Yup, I already fixed that one
>> +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)
>
> I would keep the %.o as the first in the list>
>> $(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)
>
> so all the snippets are always baked in every test?
Currently yes.
Do you have better ideas?
>
>> $(@:.elf=.aux.o) $(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
>> diff --git a/s390x/snippets/c/flat.lds b/s390x/snippets/c/flat.lds
>> new file mode 100644
>> index 00000000..5e707325
>> --- /dev/null
>> +++ b/s390x/snippets/c/flat.lds
>> @@ -0,0 +1,51 @@
>> +SECTIONS
>> +{
>> + .lowcore : {
>> + /*
>> + * Initial short psw for disk boot, with 31 bit
>> addressing for
>> + * non z/Arch environment compatibility and the
>> instruction
>> + * address 0x10000 (cstart64.S .init).
>> + */
>> + . = 0;
>> + LONG(0x00080000)
>> + LONG(0x80004000)
>> + /* Restart new PSW for booting via PSW restart. */
>> + . = 0x1a0;
>> + QUAD(0x0000000180000000)
>> + QUAD(0x0000000000004000)
>> + }
>> + . = 0x4000;
>> + .text : {
>> + *(.init)
>> + *(.text)
>> + *(.text.*)
>> + }
>> + . = ALIGN(64K);
>> + etext = .;
>> + .opd : { *(.opd) }
>> + . = ALIGN(16);
>> + .dynamic : {
>> + dynamic_start = .;
>> + *(.dynamic)
>> + }
>> + .dynsym : {
>> + dynsym_start = .;
>> + *(.dynsym)
>> + }
>> + .rela.dyn : { *(.rela*) }
>> + . = ALIGN(16);
>> + .data : {
>> + *(.data)
>> + *(.data.rel*)
>> + }
>> + . = ALIGN(16);
>> + .rodata : { *(.rodata) *(.rodata.*) }
>> + . = ALIGN(16);
>> + __bss_start = .;
>> + .bss : { *(.bss) }
>> + __bss_end = .;
>> + . = ALIGN(64K);
>> + edata = .;
>> + . += 64K;
>> + . = ALIGN(64K);
>> +}
>
next prev parent reply other threads:[~2021-05-26 10:12 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 [this message]
2021-06-21 10:10 ` Thomas Huth
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=0b971b37-ce5c-74ba-1a59-0863ee2f8354@linux.ibm.com \
--to=frankja@linux.ibm.com \
--cc=cohuck@redhat.com \
--cc=david@redhat.com \
--cc=imbrenda@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.