All of lore.kernel.org
 help / color / mirror / Atom feed
From: Janosch Frank <frankja@linux.ibm.com>
To: Thomas Huth <thuth@redhat.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:42:56 +0200	[thread overview]
Message-ID: <68698aa3-d207-9260-197e-9d906cc6704f@linux.ibm.com> (raw)
In-Reply-To: <5149db0e-8372-6054-da0d-fc8f85ac4038@redhat.com>

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?

Just to expand our use-case a bit more with an example since the code is
still too rough to post right now:

We test diagnose handling for Secure Execution / PV in one host test
where we have a gbin each for most diagnose codes 0x44, 0x9c, 0x288,
0x500 (0x308 needs a whole test and possible multiple gbins on its own
due to its complexity).
Other test bundles are PV IO, misc (stsi, sthyi, ...) and of course
other VSIE instruction handling tests in the future.

> 
> ?
> 
>   Thomas
> 


  reply	other threads:[~2021-06-21 14:43 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 [this message]
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=68698aa3-d207-9260-197e-9d906cc6704f@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.