Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp360814ybl; Fri, 24 Jan 2020 01:37:10 -0800 (PST) X-Google-Smtp-Source: APXvYqwRBRUW8ePZ27RI3mKaJJq0xbhZimj+uLWwGSNo/2yM1nreUFWnI0UHQCDN2Y2vf2KoVTyz X-Received: by 2002:a9d:798e:: with SMTP id h14mr1953249otm.257.1579858630224; Fri, 24 Jan 2020 01:37:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579858630; cv=none; d=google.com; s=arc-20160816; b=rlbjxeTf9RbW/SYxmtfRRo/FGE65xJFrSXHqvezX7qJe3bzKsLMl1TI/U7U+QpNxJu wQSoBFGnp/oFZ2He77STQbAoRRo560HWJifQWhbw3lrKOPmWoToLTtOdMzwmuY5I4QNX HbBe/um0qPtvCWCX3UdvGV2iS0fG6aFqPerM2CD3zcoaS2LP9TRsmq7mBO9u4pBbeYJc kwQCUE/8v+e83EdKmv3e7qrCg30s5m4OFEl5L46NmE2CQFerDtNvSg1yi2ZCsRaS0cyL Oi4eR+flZJpmhv8DApqd/Kxbtsvt6/zUKUHfswJTIK0307YAwdZgcgirOZY/HdG61rkn jK7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=KkR9XsyYszWewqqmOrVzZ1ik4TqqddD7Z9JTAAFoEcA=; b=BIMfyOJngrGNySfeKUSsE53tlJ0uwK+c+XVCD7/5N3j7czkKMgYtZTRPvLjo5Yoxqj Dbosm/OrY/OzDAq9T5bNH/bnfg5+bGdI8HoHJLUtqGLLx6lh7y7fqHeOSMKw4cpjzvV2 JSw0NFqPu1/Osybxz2cJ/NyqAeEsK6LnJMy5lcFiR89UNWgzpdOjTs5qtcdSPwkbEgXF A9jGyY35/U5Vf4y6lgzR3i0+357dOA46JDyGXRgMHNZF0r7JhtoPi6aSbNqc9jh4xP80 8FfWD/k70DMSPyR7x5rsnyY7smHcmTXWNImvVN5G4Xbg//Df4apKwq5Rd1LszUEDBjTG gdGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IBmc5q1w; 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=pass (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 j14si2480869otp.319.2020.01.24.01.36.57; Fri, 24 Jan 2020 01:37:10 -0800 (PST) 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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IBmc5q1w; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729459AbgAXJf5 (ORCPT + 99 others); Fri, 24 Jan 2020 04:35:57 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:45466 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729180AbgAXJf5 (ORCPT ); Fri, 24 Jan 2020 04:35:57 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579858556; 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: in-reply-to:in-reply-to:references:references; bh=KkR9XsyYszWewqqmOrVzZ1ik4TqqddD7Z9JTAAFoEcA=; b=IBmc5q1wcP1F7aKhwG108GEyx/J3ix5QqeSus0dGe1VzSQ9lmiknffAu8PyEhMcXLo9VF+ CO5cQLsyJUetR6XRFfcHttpYnC/21kUdLMwL55wu85GFtNqt0WstnlRe8NcTmV75D60kds YNQ6O6gVK0XFOrGsObg5a+l14lEIEvo= 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-395-OIjQAVdYPbepnMZWON9ngw-1; Fri, 24 Jan 2020 04:35:52 -0500 X-MC-Unique: OIjQAVdYPbepnMZWON9ngw-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 84FB28C5C9B; Fri, 24 Jan 2020 09:35:50 +0000 (UTC) Received: from kamzik.brq.redhat.com (unknown [10.43.2.160]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EA1A6863BC; Fri, 24 Jan 2020 09:35:45 +0000 (UTC) Date: Fri, 24 Jan 2020 10:35:43 +0100 From: Andrew Jones To: Paolo Bonzini Cc: Ben Gardon , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, Cannon Matthews , Peter Xu , Peter Shier , Oliver Upton , Marc Zyngier , Cornelia Huck , Christian Borntraeger Subject: Re: [PATCH v4 06/10] KVM: selftests: Add support for vcpu_args_set to aarch64 and s390x Message-ID: <20200124093543.m5oqo7fnjnc2scko@kamzik.brq.redhat.com> References: <20200123180436.99487-1-bgardon@google.com> <20200123180436.99487-7-bgardon@google.com> <4dbb6d1b-3162-d9b3-4ebb-5e4061776bb6@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4dbb6d1b-3162-d9b3-4ebb-5e4061776bb6@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 24, 2020 at 10:03:08AM +0100, Paolo Bonzini wrote: > CCing Marc, Conny and Christian (plus Thomas and Drew who were already > in the list) for review. > > Thanks, > > Paolo > > On 23/01/20 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. It'd be nice to keep the separate architecture changes in separate patches. Otherwise I can't really give an r-b. > > > > 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/aarch64/processor.c b/tools/testing/selftests/kvm/lib/aarch64/processor.c > > index 86036a59a668e..a2ff90a75f326 100644 > > --- a/tools/testing/selftests/kvm/lib/aarch64/processor.c > > +++ b/tools/testing/selftests/kvm/lib/aarch64/processor.c > > @@ -333,3 +333,36 @@ void vm_vcpu_add_default(struct kvm_vm *vm, uint32_t vcpuid, void *guest_code) > > { > > aarch64_vcpu_add_default(vm, vcpuid, NULL, 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 r0-r7. > > + */ lib/aarch64/processor.c so far doesn't have big function headers like this. Also, since this function is common for all architectures [now], I feel like the documentation should be in common code - so in the header file. > > +void vcpu_args_set(struct kvm_vm *vm, uint32_t vcpuid, unsigned int num, ...) > > +{ > > + va_list ap; > > + > > + TEST_ASSERT(num >= 1 && num <= 8, "Unsupported number of args,\n" > > + " num: %u\n", > > + num); Weird line breaking. I see it came from the x86 implementation, but it's weird there too... Personally I'd just put it all on one line, because my vt100 died two decades ago. > > + > > + va_start(ap, num); > > + > > + for (i = 0; i < num; i++) > > + set_reg(vm, vcpuid, ARM64_CORE_REG(regs.regs[num]), ^^ should be 'i' > > + va_arg(ap, uint64_t)); nit: I'd use {} because of the line break. Or just not break the line and bust the 80 char "limit" (RIP vt100). Thanks, drew > > + > > + va_end(ap); > > +} > > 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; > > + > > + TEST_ASSERT(num >= 1 && num <= 5, "Unsupported number of args,\n" > > + " 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); > > +} > > + > > void vcpu_dump(FILE *stream, struct kvm_vm *vm, uint32_t vcpuid, uint8_t indent) > > { > > struct vcpu *vcpu = vm->vcpu_head; > > >