Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp970429ybg; Mon, 27 Jul 2020 04:41:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxhhtOi5rNcmBuIOzADPo3KYHok4hIeUtE1XdXH60llSCKOAEQfMk4UhHjUIWAimBtxHfbW X-Received: by 2002:a17:906:7fc9:: with SMTP id r9mr3044582ejs.407.1595850083512; Mon, 27 Jul 2020 04:41:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595850083; cv=none; d=google.com; s=arc-20160816; b=KSSj11A1lFZJPyAr6ZFCbNJz3a3ND9FimmpfeK9/fQx/norRLLBaw9EUnpFq2IQkNd wX3Hf4qJwCHOfOnAM3w1z8AdDRz5XPWFM+jSlwHza2JqoMamINyy64YKZLbnGgEPZzNx B9WS6hmZt4VVs9wlnGxp6wE0/LJomGXw/g87rWAmMBJin5ToLikErIBP21X9PrK6vXBc Q9rRpVjVej/r7b8raoUUbaXe4U8L+BhbyCyxcPq0kNxTqnPsvFA5+QbDLMIuDB76qwxR 8hKCkdStIeXZl4zyQzBTp0hKde9cWSrbGlYJsICT+PwhMzfAD1EqBCQzSmJWn0UQeRze 1dsg== 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:dkim-signature; bh=Yp4aFkNWiONh5YpmoHzMPJdg4uIRnraWkyPkkm15wFI=; b=oQvb8LFsir/71Fc0JLtiFoRbJVjUPsI550aG3BpYjkRJ7qk0JRgdmjO9qqNNPr60k1 ly67DQso8LmBtGbxUC7B90oGLuCZqcCf2QtOXLThNkEDvvjMpkAVHW32lVio1mWWa4R2 5ECQiCfTquDnr7sxaJ19v3Edhdekk9AD4HZQjmsMnbiJJ+/3AD3VfaZgSdKF6Iqz0W/W p99f2HEznLx4ZEBOSfIXG6ieC24kNgxhGNnCIh7eUWMoL3srcMDOwoBIVAvk28VUsaBb DKkfMejKQjLg5n+hjDDBCBxZfjDxlgy0Ic8r48zEsisVH4bGzUZsbFBR86Rduf3XrC8O D9Rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zO7gFLOA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l23si4176202ejq.620.2020.07.27.04.41.01; Mon, 27 Jul 2020 04:41:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zO7gFLOA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728044AbgG0Li3 (ORCPT + 99 others); Mon, 27 Jul 2020 07:38:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:49298 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727037AbgG0Li2 (ORCPT ); Mon, 27 Jul 2020 07:38:28 -0400 Received: from willie-the-truck (236.31.169.217.in-addr.arpa [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D6C832072E; Mon, 27 Jul 2020 11:38:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595849908; bh=uLbTYAh07fv8JZO0YyeUya+9u16JNdr7tPp1pQ4gqYo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=zO7gFLOA17LlgroJllXmWm8YcqAdeP4NTG7mB9v4pP075cnGKv9titYleXePQiaVX J07HCyoLe7QeSH+D5suzf/uXPdQ2C3NMCIvMQrAaxR6HJ5ZPDGdBoOMgsRbYRd36lB AEEtX/k8I1IBrkr3UiqDsvAOjov2r23gFZO83WJw= Date: Mon, 27 Jul 2020 12:38:21 +0100 From: Will Deacon To: Jianyong Wu Cc: "netdev@vger.kernel.org" , "yangbo.lu@nxp.com" , "john.stultz@linaro.org" , "tglx@linutronix.de" , "pbonzini@redhat.com" , "sean.j.christopherson@intel.com" , "maz@kernel.org" , "richardcochran@gmail.com" , Mark Rutland , Suzuki Poulose , Steven Price , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "kvmarm@lists.cs.columbia.edu" , "kvm@vger.kernel.org" , Steve Capper , Kaly Xin , Justin He , Wei Chen , nd Subject: Re: [PATCH v13 2/9] arm/arm64: KVM: Advertise KVM UID to guests via SMCCC Message-ID: <20200727113821.GB20437@willie-the-truck> References: <20200619130120.40556-1-jianyong.wu@arm.com> <20200619130120.40556-3-jianyong.wu@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 27, 2020 at 03:45:37AM +0000, Jianyong Wu wrote: > > From: Will Deacon > > > > We can advertise ourselves to guests as KVM and provide a basic features > > bitmap for discoverability of future hypervisor services. > > > > Cc: Marc Zyngier > > Signed-off-by: Will Deacon > > Signed-off-by: Jianyong Wu > > --- > > arch/arm64/kvm/hypercalls.c | 29 +++++++++++++++++++---------- > > 1 file changed, 19 insertions(+), 10 deletions(-) > > > > diff --git a/arch/arm64/kvm/hypercalls.c b/arch/arm64/kvm/hypercalls.c > > index 550dfa3e53cd..db6dce3d0e23 100644 > > --- a/arch/arm64/kvm/hypercalls.c > > +++ b/arch/arm64/kvm/hypercalls.c > > @@ -12,13 +12,13 @@ > > int kvm_hvc_call_handler(struct kvm_vcpu *vcpu) { > > u32 func_id = smccc_get_function(vcpu); > > - long val = SMCCC_RET_NOT_SUPPORTED; > > + u32 val[4] = {SMCCC_RET_NOT_SUPPORTED}; > > There is a risk as this u32 value will return here and a u64 value will be > obtained in guest. For example, The val[0] is initialized as -1 of > 0xffffffff and the guest get 0xffffffff then it will be compared with -1 > of 0xffffffffffffffff Also this problem exists for the transfer of address > in u64 type. So the following assignment to "val" should be split into two > u32 value and assign to val[0] and val[1] respectively. > WDYT? Yes, I think you're right that this is a bug, but isn't the solution just to make that an array of 'long'? long val [4]; That will sign-extend the negative error codes as required, while leaving the explicitly unsigned UID constants alone. Will