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 16:59:14 +0200	[thread overview]
Message-ID: <a74f86e1-6fc9-e2fd-12f9-4670c1290355@redhat.com> (raw)
In-Reply-To: <68698aa3-d207-9260-197e-9d906cc6704f@linux.ibm.com>

On 21/06/2021 16.42, Janosch Frank wrote:
> On 6/21/21 3:28 PM, Thomas Huth wrote:
>> On 21/06/2021 14.39, Janosch Frank wrote:
>>> On 6/21/21 2:32 PM, Thomas Huth wrote:
>>>> On 21/06/2021 14.19, Janosch Frank wrote:
>>>>> On 6/21/21 12:10 PM, Thomas Huth wrote:
>>>>>> 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.
>>>>>
>>>>> Sure
>>>>>
>>>>>>
>>>>>>> +snippets = $(snippets-a)$(snippets-c)
>>>>>>
>>>>>> Shouldn't there be a space between the two?
>>>>>
>>>>> Yes, already fixed that a long while ago
>>>>> I thought I had sent out a new version already, maybe that was an
>>>>> illusion as I can't seem to find it right now.
>>>>>
>>>>>>
>>>>>>> +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?
>>>>>
>>>>> Yes it does.
>>>>> I'd like to avoid having to specify a makefile rule for every test that
>>>>> uses snippets as we already have more than the mvpg one in the queue.
>>>>>
>>>>> So I'm having Steffen looking into a solution for this problem. My first
>>>>> idea was to bring the used snippets into the unittests.cfg but I
>>>>> disliked that we then would have compile instructions in another file.
>>>>> Maybe there's a way to include that into the makefile in a clever way?
>>>>
>>>> I haven't tried, but maybe you could replace the $(snippets) in the last
>>>> line with
>>>>
>>>>     $(wildcard snippets/$@.gbin)
>>>>
>>>> or something similar?
>>>
>>> That starts falling apart when multiple tests use the same snippet, no?
>>
>> That's true ... Maybe something like:
>>
>>    $(filter %.gbin,$^)
> 
> That filters all files that are not gbins from the prereqs, right?
> In what way is that different to linking all the snippets? After all
> they are currently a prereq for %.elf or am I missing something here?

Sorry, I meant we could then add the prereqs manually for each tests that 
require it, e.g. add a single line like:

mvpg-sie.elf: snippets/mvpg.gbin

(without specifying a rule, just the dependency)

... not sure whether that works, though...

  Thomas


  reply	other threads:[~2021-06-21 14:59 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
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 [this message]
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=a74f86e1-6fc9-e2fd-12f9-4670c1290355@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).