Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1175054ybi; Wed, 3 Jul 2019 10:47:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqyBPBZVC/GqDxzUBtJOd8c9AvIY7aOoi0hpq0+bhKb3yEjxuAllEerxvqlJ2ATJVYivpd+0 X-Received: by 2002:a63:f346:: with SMTP id t6mr39773828pgj.203.1562176024280; Wed, 03 Jul 2019 10:47:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562176024; cv=none; d=google.com; s=arc-20160816; b=eYvjhDUcV1Nk2izwZQvEqDwFNtNlwe9yIMjxZodZi2mi26opPK1bH7SEpdF+Y25lYK eiOWtm11lSRaQgpdrN8aqVzZr2ryvKXlVobELuSbBec0FuVghW1kGPuckNgPm/Q/hH5V lyJ2dfcl327EqU43Poli5gT9F97m5J/wraFLecKEP9k53/lqhI3iiLKtWqzmIUEkXI2M ztlhFRaogumQDNjpQykZdvYODE/d0bgrQKOdBr1IYK1l3iqlQUbehjiv3YbVKXeuy9Wf pfmlybg0oT7n7p2LsHoLPAX9NCKwa+kOqpwMp8gJNgwgdGC8H7XvFQ7pktIZvs++nFkE tw5A== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=bOfkkSp6S8SG74jNrGhlGWhgPedBubJ0GQeBn1mj0YU=; b=dEeti+2yNlIKzmZF1rUGu7wZ3G3ZSLaoB1vJas5JWtHRbbDH71PITKu3gjWY0gC3gY W+8Mx1VKhXEFqH73SGNpIXO0X3WMBN8B89ZnrCmoy44skSBYC8JcDhl1WqrQwiSsIxGz zjjf6gFB3c7AIesIdz8WhLxh3cRn4JUPif9lru/1Fd3IEmDbMtryOh64jiCoVPVk2Sjf Qxz2jUyFPywAt2sfiMy0HcCbCApiXWNrd9ot3w6qhAv1795bJjLiI9Qzlgfu2wBe/Eo4 UviXrYMrFv1i5lBjLVbA4CsfPqDB/hejRaM+NOWyjd6m7AGmryKSnsDZ8tV8sigcu0Df 9H2Q== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 31si2773353pld.245.2019.07.03.10.46.48; Wed, 03 Jul 2019 10:47:04 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727014AbfGCRqN (ORCPT + 99 others); Wed, 3 Jul 2019 13:46:13 -0400 Received: from foss.arm.com ([217.140.110.172]:54158 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726574AbfGCRqN (ORCPT ); Wed, 3 Jul 2019 13:46:13 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3F961344; Wed, 3 Jul 2019 10:46:12 -0700 (PDT) Received: from e103592.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 723E93F718; Wed, 3 Jul 2019 10:46:10 -0700 (PDT) Date: Wed, 3 Jul 2019 18:46:08 +0100 From: Dave Martin To: "Zhang, Lei" Cc: 'Viresh Kumar' , Marc Zyngier , James Morse , Julien Thierry , Suzuki K Pouloze , Catalin Marinas , Will Deacon , "Okamoto, Takayuki" , "linux-kernel@vger.kernel.org" , "kvmarm@lists.cs.columbia.edu" , "Mizuma, Masayoshi" , "linux-arm-kernel@lists.infradead.org" , "Indoh, Takao" Subject: Re: [PATCH V3] KVM: arm64: Implement vq_present() as a macro Message-ID: <20190703174605.GX2790@e103592.cambridge.arm.com> References: <8898674D84E3B24BA3A2D289B872026A78BA95D6@G01JPEXMBKW03> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <8898674D84E3B24BA3A2D289B872026A78BA95D6@G01JPEXMBKW03> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 03, 2019 at 12:04:11PM +0000, Zhang, Lei wrote: > Hi guys, > > I can't start up KVM guest os with SVE feature with your patch. > The error message is > qemu-system-aarch64: kvm_init_vcpu failed: Invalid argument. > > My test enviroment. > kernel linux-5.2-rc6 > qemu [Qemu-devel] [PATCH v2 00/14] target/arm/kvm: enable SVE in guests https://lists.gnu.org/archive/html/qemu-devel/2019-06/msg04945.html > KVM start up option > -machine virt,gic-version=host,accel=kvm \ > -cpu host \ > -machine type=virt \ > -nographic \ > -smp 16 \ -m 4096 \ > -drive if=none,file=/root/image.qcow2,id=hd0,format=qcow2 \ > -device virtio-blk-device,drive=hd0 \ > -netdev user,id=mynet0,restrict=off,hostfwd=tcp::38001-:22 \ > -device virtio-net-device,netdev=mynet0 \ > -bios /root/QEMU_EFI.fd > > sve_vq_available function's return value' type is bool. > But vq_present is macro, so the value is not only TRUE, FALSE but also some numbers. > So It failed at > if (vq_present(vqs, vq) != sve_vq_available(vq)). > I think it is nessary to make vq_present macro's value only TRUE and FALSE. > > arch/arm64/kvm/guest.c > static int set_sve_vls(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg) > for (vq = SVE_VQ_MIN; vq <= max_vq; ++vq) > if (vq_present(vqs, vq) != sve_vq_available(vq)) // It failed at here. > return -EINVAL; > > My patch as follows. > I have started up KVM guest os successfully with SVE feature with this patch. > > Could you review and merge my patch? [...] Thanks for reporting this! It looks like we didn't realise we dropped the implicit cast to bool when the result was returned from the original version of vq_present(). Your fix looks sensible to me. For the future, see Documentation/process/submitting-patches.rst for guidance on how to prepare a patch for submission. However, due to the fact that we're already at -rc7 I've written a commit message for the patch and reposted [1]. Since the fix is yours, I'll keep your authorship and S-o-B. Please retest when you can (though the diff should be the same). Note, your mail seems to be corrupted, but since the diff is a one-line fix, I'm pretty confident I decoded it correctly. If anything looks wrong, please let me know. [...] Cheers ---Dave [1] [PATCH] KVM: arm64/sve: Fix vq_present() macro to yield a bool http://lists.infradead.org/pipermail/linux-arm-kernel/2019-July/664745.html