From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.4 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D6ED6C35247 for ; Mon, 27 Jan 2020 09:01:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AE224214DB for ; Mon, 27 Jan 2020 09:01:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="PTz6LzDX" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727464AbgA0JB5 (ORCPT ); Mon, 27 Jan 2020 04:01:57 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:42177 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727233AbgA0JB5 (ORCPT ); Mon, 27 Jan 2020 04:01:57 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580115716; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:openpgp:openpgp; bh=gy0Q6xsJnf+50EzHAO2CLej3bx+BVRRke049WRf3JWc=; b=PTz6LzDXIoUEIInzy2rsPN0ysB3QtSpwAaiHljlxtR82FKUxzLTeUuooBwHtJKeubLUZuJ 6L4T+7l1iAWOy09nuPcCWdie/0NCN6Y9LJJrCnMAPsyd3XcVX1WUYx394Llqz5TmQswas4 b34Dt12UB055EQ5P4/Xu44gIHXGyP0c= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-268-F2ne4R_INUiIDPbS0Eexfw-1; Mon, 27 Jan 2020 04:01:51 -0500 X-MC-Unique: F2ne4R_INUiIDPbS0Eexfw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 96CC61005512; Mon, 27 Jan 2020 09:01:49 +0000 (UTC) Received: from thuth.remote.csb (ovpn-117-94.ams2.redhat.com [10.36.117.94]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D28E2863A3; Mon, 27 Jan 2020 09:01:44 +0000 (UTC) Subject: Re: [PATCH v4 06/10] KVM: selftests: Add support for vcpu_args_set to aarch64 and s390x To: Ben Gardon , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-kselftest@vger.kernel.org Cc: Paolo Bonzini , Cannon Matthews , Peter Xu , Andrew Jones , Peter Shier , Oliver Upton References: <20200123180436.99487-1-bgardon@google.com> <20200123180436.99487-7-bgardon@google.com> From: Thomas Huth Openpgp: preference=signencrypt Message-ID: Date: Mon, 27 Jan 2020 10:01:43 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <20200123180436.99487-7-bgardon@google.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org On 23/01/2020 19.04, Ben Gardon wrote: > Currently vcpu_args_set is only implemented for x86. This makes writing > tests with multiple vCPUs difficult as each guest vCPU must either a.) > do the same thing or b.) derive some kind of unique token from it's > registers or the architecture. To simplify the process of writing tests > with multiple vCPUs for s390 and aarch64, add set args functions for > those architectures. > > Signed-off-by: Ben Gardon > --- > .../selftests/kvm/lib/aarch64/processor.c | 33 +++++++++++++++++ > .../selftests/kvm/lib/s390x/processor.c | 35 +++++++++++++++++++ > 2 files changed, 68 insertions(+) [...] > diff --git a/tools/testing/selftests/kvm/lib/s390x/processor.c b/tools/testing/selftests/kvm/lib/s390x/processor.c > index 32a02360b1eb0..680f37be9dbc9 100644 > --- a/tools/testing/selftests/kvm/lib/s390x/processor.c > +++ b/tools/testing/selftests/kvm/lib/s390x/processor.c > @@ -269,6 +269,41 @@ void vm_vcpu_add_default(struct kvm_vm *vm, uint32_t vcpuid, void *guest_code) > run->psw_addr = (uintptr_t)guest_code; > } > > +/* VM VCPU Args Set > + * > + * Input Args: > + * vm - Virtual Machine > + * vcpuid - VCPU ID > + * num - number of arguments > + * ... - arguments, each of type uint64_t > + * > + * Output Args: None > + * > + * Return: None > + * > + * Sets the first num function input arguments to the values > + * given as variable args. Each of the variable args is expected to > + * be of type uint64_t. The registers set by this function are r2-r6. > + */ > +void vcpu_args_set(struct kvm_vm *vm, uint32_t vcpuid, unsigned int num, ...) > +{ > + va_list ap; > + struct kvm_regs regs; You need an "int i;" here to make it compile. > + TEST_ASSERT(num >= 1 && num <= 5, "Unsupported number of args,\n" why the "\n" right in the middle of the string? Could you please make it one-line only? > + " num: %u\n", > + num); > + > + va_start(ap, num); > + vcpu_regs_get(vm, vcpuid, ®s); > + > + for (i = 0; i < num; i++) > + regs.gprs[i + 2] = va_arg(ap, uint64_t); > + > + vcpu_regs_set(vm, vcpuid, ®s); > + va_end(ap); > +} ... but apart from the nits, this looks basically sane to me. Thomas