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=-11.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable 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 A5C2FC433E0 for ; Mon, 27 Jul 2020 11:39:47 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 72E0020714 for ; Mon, 27 Jul 2020 11:39:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="DIlp+rDI"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="zO7gFLOA" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 72E0020714 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=V00FZWFnzVe5B1FQDb2wcOrUpiZXbbsaNzWr8+KMobI=; b=DIlp+rDIq8vfjCdQjVMAxQeCt HH7p1s7enccLntgAjrkz5a7iebWZPLEYkWIabkatRKmnjApXX6i9llKD9RnTtGOZYBzDGUaFqt7Y3 k3VcLYXZrqR4xgkQkdYyKy4MOOEMrBFvTpea3igOOmHhMM0bwGqG16hk27K/ZXG91QwojFcfe2nq9 9HlWCARrSyOcKTrgbqzbSg6eEu3gYVV45skr3WjWV2NwQovvyRCoTOJuIJP+tcdxVSt41UDBGN36Y /yNJ6eTNLdTuawMg0n/3ykjc8kxIeNY1J+Ifur6jpsJZFqnlNCsSkm/luZyGxuaJ6zoHOi88l+7u5 qsCaRdKrw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k01Sh-000651-7W; Mon, 27 Jul 2020 11:38:31 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k01Sf-00064I-0D for linux-arm-kernel@lists.infradead.org; Mon, 27 Jul 2020 11:38:29 +0000 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 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-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200727_073829_130767_FE5FEFB9 X-CRM114-Status: GOOD ( 20.64 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , "maz@kernel.org" , Justin He , Wei Chen , "kvm@vger.kernel.org" , Suzuki Poulose , "netdev@vger.kernel.org" , "richardcochran@gmail.com" , Steve Capper , "linux-kernel@vger.kernel.org" , "sean.j.christopherson@intel.com" , Steven Price , Kaly Xin , "john.stultz@linaro.org" , "yangbo.lu@nxp.com" , "pbonzini@redhat.com" , "tglx@linutronix.de" , nd , "kvmarm@lists.cs.columbia.edu" , "linux-arm-kernel@lists.infradead.org" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel