linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: Andrew Jones <drjones@redhat.com>
Cc: kvm@vger.kernel.org,
	"Christian Borntraeger" <borntraeger@de.ibm.com>,
	"Janosch Frank" <frankja@linux.ibm.com>,
	linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-s390@vger.kernel.org,
	"David Hildenbrand" <david@redhat.com>,
	"Cornelia Huck" <cohuck@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Radim Krčmář" <rkrcmar@redhat.com>,
	"Shuah Khan" <shuah@kernel.org>, "Peter Xu" <peterx@redhat.com>
Subject: Re: [PATCH 1/2] KVM: selftests: Implement ucall() for s390x
Date: Wed, 31 Jul 2019 13:16:31 +0200	[thread overview]
Message-ID: <0c38beb7-7383-a7ac-13d4-9d4bde4a21bb@redhat.com> (raw)
In-Reply-To: <20190731102849.x26rdan7cddmpvhe@kamzik.brq.redhat.com>

On 31/07/2019 12.28, Andrew Jones wrote:
> On Wed, Jul 31, 2019 at 11:43:16AM +0200, Thomas Huth wrote:
>> On 30/07/2019 12.48, Andrew Jones wrote:
>>> On Tue, Jul 30, 2019 at 12:01:11PM +0200, Thomas Huth wrote:
>>>> On s390x, we can neither exit via PIO nor MMIO, but have to use
>>>> an instruction like DIAGNOSE. While we're at it, rename UCALL_PIO
>>>> to UCALL_DEFAULT, since PIO only works on x86 anyway, and this
>>>> way we can re-use the "default" type for the DIAGNOSE exit on s390x.
>>>>
>>>> Now that ucall() is implemented, we can use it in the sync_reg_test
>>>> on s390x, too.
>>>>
>>>> Signed-off-by: Thomas Huth <thuth@redhat.com>
>>>> ---
>>>>  .../testing/selftests/kvm/include/kvm_util.h  |  2 +-
>>>>  tools/testing/selftests/kvm/lib/ucall.c       | 34 +++++++++++++++----
>>>>  .../selftests/kvm/s390x/sync_regs_test.c      |  6 ++--
>>>>  3 files changed, 32 insertions(+), 10 deletions(-)
>>>>
>>>> diff --git a/tools/testing/selftests/kvm/include/kvm_util.h b/tools/testing/selftests/kvm/include/kvm_util.h
>>>> index e0e66b115ef2..c37aea2e33e5 100644
>>>> --- a/tools/testing/selftests/kvm/include/kvm_util.h
>>>> +++ b/tools/testing/selftests/kvm/include/kvm_util.h
>>>> @@ -167,7 +167,7 @@ int vm_create_device(struct kvm_vm *vm, struct kvm_create_device *cd);
>>>>  
>>>>  /* ucall implementation types */
>>>>  typedef enum {
>>>> -	UCALL_PIO,
>>>> +	UCALL_DEFAULT,
>>>
>>> I'd rather we keep explicit types defined; keep PIO and add DIAG. Then
>>> we can have
>>>
>>> /*  Set default ucall types */
>>> #if defined(__x86_64__)
>>>   ucall_type = UCALL_PIO;
>>> #elif defined(__aarch64__)
>>>   ucall_type = UCALL_MMIO;
>>>   ucall_requires_init = true;
>>> #elif defined(__s390x__)
>>>   ucall_type = UCALL_DIAG;
>>> #endif
>>>
>>> And add an assert in get_ucall()
>>>
>>>  assert(!ucall_requires_init || ucall_initialized);
>>
>> I'm not sure whether I really like that. It's yet another additional
>> #ifdef block, and yet another variable ...
>>
>> What do you think about removing the enum completely and simply code it
>> directly, without the ucall_type indirection, i.e.:
>>
>> void ucall(uint64_t cmd, int nargs, ...)
>> {
>> 	struct ucall uc = {
>> 		.cmd = cmd,
>> 	};
>> 	va_list va;
>> 	int i;
>>
>> 	nargs = nargs <= UCALL_MAX_ARGS ? nargs : UCALL_MAX_ARGS;
>>
>> 	va_start(va, nargs);
>> 	for (i = 0; i < nargs; ++i)
>> 		uc.args[i] = va_arg(va, uint64_t);
>> 	va_end(va);
>>
>> #if defined(__x86_64__)
>>
>> 	/* Exit via PIO */
>> 	asm volatile("in %[port], %%al"
>> 		: : [port] "d" (UCALL_PIO_PORT), "D" (&uc) : "rax");
>>
>> #elif defined(__aarch64__)
>>
>> 	*ucall_exit_mmio_addr = (vm_vaddr_t)&uc;
>>
>> #elif defined(__s390x__)
>>
>> 	/* Exit via DIAGNOSE 0x501 (normally used for breakpoints) */
>> 	asm volatile ("diag 0,%0,0x501" : : "a"(&uc) : "memory");
>>
>> #endif
>> }
>>
>> I think that's way less confusing than having to understand the meaning
>> of ucall_type etc. before...?
>>
> 
> Sounds good to me.

Or maybe even better: Let's move this file into lib/x86_64/ and
lib/aarch64/ instead, since there is more different code between the
architectures here than common code.

 Thomas

  reply	other threads:[~2019-07-31 11:16 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-30 10:01 [PATCH 0/2] KVM: selftests: Enable ucall and dirty_log_test on s390x Thomas Huth
2019-07-30 10:01 ` [PATCH 1/2] KVM: selftests: Implement ucall() for s390x Thomas Huth
2019-07-30 10:48   ` Andrew Jones
2019-07-31  9:43     ` Thomas Huth
2019-07-31 10:28       ` Andrew Jones
2019-07-31 11:16         ` Thomas Huth [this message]
2019-07-31 12:57           ` Paolo Bonzini
2019-07-31 13:05             ` Andrew Jones
2019-07-30 10:01 ` [PATCH 2/2] KVM: selftests: Enable dirty_log_test on s390x Thomas Huth
2019-07-30 10:57   ` Andrew Jones
2019-07-31  8:19     ` Thomas Huth
2019-07-31  8:44       ` Andrew Jones
2019-07-31 12:58       ` Paolo Bonzini
2019-07-30 11:35   ` Paolo Bonzini
2019-07-30 14:57   ` Christian Borntraeger
2019-07-30 17:11     ` Thomas Huth
2019-07-30 18:04       ` Christian Borntraeger
2019-07-31 11:06         ` David Hildenbrand
2019-07-30 19:06     ` Paolo Bonzini
2019-07-31  7:16       ` Christian Borntraeger
2019-07-30 11:36 ` [PATCH 0/2] KVM: selftests: Enable ucall and " Paolo Bonzini

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=0c38beb7-7383-a7ac-13d4-9d4bde4a21bb@redhat.com \
    --to=thuth@redhat.com \
    --cc=borntraeger@de.ibm.com \
    --cc=cohuck@redhat.com \
    --cc=david@redhat.com \
    --cc=drjones@redhat.com \
    --cc=frankja@linux.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=peterx@redhat.com \
    --cc=rkrcmar@redhat.com \
    --cc=shuah@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).