Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp5854121ybi; Wed, 31 Jul 2019 04:25:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqzupFRBphxx0UF00JT2LwbgnU9wkEyrPq+OCsAF3s+WAT0QvpdtX89N8lgwB9SNpokuOu1B X-Received: by 2002:a63:b555:: with SMTP id u21mr115384424pgo.222.1564572353623; Wed, 31 Jul 2019 04:25:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564572353; cv=none; d=google.com; s=arc-20160816; b=s/AjfK/XZUp4nvM35a5ajgL+UIXdhrTiPriGNd7wBLNmjc3/IoNHHocohmRpIdp3Sh mW12IJic4VkUjYNBp8jrApoXJZdAFUTbbxC2WcjHe6cRWkvehEDV3Za8xQfW2vbZNV3F cdNBI7jIZ2hcTcl19ahTYnMGt6eojO3dLloBrD62r+wXq19UX1bfNeCPdkVnkCgnS62A twVuyTo3Cc2+/taFCYWwhK7lIzjCZwFQNFgDSv/54QXCMl8zohued/YfeVunWl4Ouqyc aEDhYOjc2jIhUypag0ncqj4dmVokMT6tMOYzMxnwyW0zmwQkIQqnvF18V3wcBMEx45Bx V3gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=QCgXIs0rocRuh/UfaOsVqD3vzq77J6pYWRD2ShgIjGU=; b=PFGXRjbDjWl4/kx+JWfVBAK3cAfnAncIdPJpH7NxI9NTUrlLulsjG3gdFrxXDOjYry 4KCD72yP4CC+QwiKrrgDYAvS+rpMcYX+bLB+nhEDnR/u7x2pKtxrv6BnNOVOIm9s4Oll 7NJsidpNVlJik0M3iDS8At8mQW6jJg2Lkj6XKiLymtXGmeKApFrPbJ0YffTImDdsrryx I4lFT+wEWr03dO1+VMyzHUvKXBuVY4v/YZXIHf97b3r3Hd402mHU7aCMNPmo0FRxI9ET WWzoynvxpOxdVeIZ9jk0dLAhdjTHKDpcH97QZB+X/vePtzQ7kC9F8SKKRDQzPguu6ewJ 84Pg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bc7si31163621plb.55.2019.07.31.04.25.38; Wed, 31 Jul 2019 04:25:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387645AbfGaK3C (ORCPT + 99 others); Wed, 31 Jul 2019 06:29:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60684 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387399AbfGaK3C (ORCPT ); Wed, 31 Jul 2019 06:29:02 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 44D6EC01DE0D; Wed, 31 Jul 2019 10:29:01 +0000 (UTC) Received: from kamzik.brq.redhat.com (unknown [10.43.2.160]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F173019C70; Wed, 31 Jul 2019 10:28:51 +0000 (UTC) Date: Wed, 31 Jul 2019 12:28:49 +0200 From: Andrew Jones To: Thomas Huth Cc: kvm@vger.kernel.org, Christian Borntraeger , Janosch Frank , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, David Hildenbrand , Cornelia Huck , Paolo Bonzini , Radim =?utf-8?B?S3LEjW3DocWZ?= , Shuah Khan , Peter Xu Subject: Re: [PATCH 1/2] KVM: selftests: Implement ucall() for s390x Message-ID: <20190731102849.x26rdan7cddmpvhe@kamzik.brq.redhat.com> References: <20190730100112.18205-1-thuth@redhat.com> <20190730100112.18205-2-thuth@redhat.com> <20190730104807.7uzuvd52foybakgu@kamzik.brq.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 31 Jul 2019 10:29:01 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > >> --- > >> .../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. Thanks, drew