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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5A591C43334 for ; Thu, 30 Jun 2022 16:23:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234403AbiF3QX3 (ORCPT ); Thu, 30 Jun 2022 12:23:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229756AbiF3QX1 (ORCPT ); Thu, 30 Jun 2022 12:23:27 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80AFE2EA19 for ; Thu, 30 Jun 2022 09:23:26 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1C82861FF9 for ; Thu, 30 Jun 2022 16:23:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6AA2DC34115; Thu, 30 Jun 2022 16:23:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1656606205; bh=/wIBdp+oiWjbA0nGQcK+9VOFJYvNFoz6aGVh1eVQH1I=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=jWKF7Wa7cMz+Kx72y/2aMd7nmgeQoVG8ZAee0gJulRMYq3hsvEXe5rUeHe0rIYOhC +uwuG7cqqBHm6sVDp5uWxdJtZ8dlz+2R6hgSr+NaeA8b60phd2b6OZ/aFEJ1ansi6C X5xWGE+xDHZGb6Gg8q3UDFcdl0IDjRQ3MhXZt3MubyH2fsb+hT4mDGWKhuFjA54uEI lWLBb2C8n5HZJd0+khfAy4UDaWL6UQPOuzPnbrbi7seq71ItgtpNkEcnavHknFs0me s8O09VAp5TVb1VGoK1On4ywkykYMJP79ox6tKXwQ454z911FFs1OP+11AF9Gxei7nC 3QARVhcbJ1/rw== Received: from sofa.misterjones.org ([185.219.108.64] helo=why.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1o6wwt-004OZO-DN; Thu, 30 Jun 2022 17:23:23 +0100 Date: Thu, 30 Jun 2022 17:23:23 +0100 Message-ID: <87mtdu15ok.wl-maz@kernel.org> From: Marc Zyngier To: Schspa Shi Cc: james.morse@arm.com, alexandru.elisei@arm.com, suzuki.poulose@arm.com, catalin.marinas@arm.com, will@kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org Subject: Re: [PATCH] KVM: arm64: Fix 64 bit mmio handle In-Reply-To: <20220630161220.53449-1-schspa@gmail.com> References: <20220630161220.53449-1-schspa@gmail.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: schspa@gmail.com, james.morse@arm.com, alexandru.elisei@arm.com, suzuki.poulose@arm.com, catalin.marinas@arm.com, will@kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 30 Jun 2022 17:12:20 +0100, Schspa Shi wrote: > > If the len is 8 bytes, we can't get the correct sign extend for > be system. I'm afraid you'll have to give me a bit more details. > > Fix the mask type len and the comparison of length. > > Signed-off-by: Schspa Shi > --- > arch/arm64/kvm/mmio.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/arch/arm64/kvm/mmio.c b/arch/arm64/kvm/mmio.c > index 3dd38a151d2a6..0692f8b18f35c 100644 > --- a/arch/arm64/kvm/mmio.c > +++ b/arch/arm64/kvm/mmio.c > @@ -81,8 +81,8 @@ unsigned long kvm_mmio_read_buf(const void *buf, unsigned int len) > int kvm_handle_mmio_return(struct kvm_vcpu *vcpu) > { > unsigned long data; > + unsigned long mask; > unsigned int len; > - int mask; > > /* Detect an already handled MMIO return */ > if (unlikely(!vcpu->mmio_needed)) > @@ -97,7 +97,7 @@ int kvm_handle_mmio_return(struct kvm_vcpu *vcpu) > data = kvm_mmio_read_buf(run->mmio.data, len); > > if (kvm_vcpu_dabt_issext(vcpu) && > - len < sizeof(unsigned long)) { > + len <= sizeof(unsigned long)) { If you're reading an 8 byte quantity, what is there to sign-extend? Sign extension only makes sense if what you're reading is *smaller* than the size of the register you are targeting. I must be missing something. And how is that related to running BE? BE in the host? The guest? Please convince me. M. -- Without deviation from the norm, progress is not possible.