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 mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by smtp.lore.kernel.org (Postfix) with ESMTP id D3091C43334 for ; Thu, 30 Jun 2022 16:23:33 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 3BAFF402DB; Thu, 30 Jun 2022 12:23:33 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Authentication-Results: mm01.cs.columbia.edu (amavisd-new); dkim=softfail (fail, message has been altered) header.i=@kernel.org Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 4vmnz6boe-Oz; Thu, 30 Jun 2022 12:23:31 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 046644B21A; Thu, 30 Jun 2022 12:23:31 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id BBBCC4B125 for ; Thu, 30 Jun 2022 12:23:29 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id J9sio9-jMF2S for ; Thu, 30 Jun 2022 12:23:28 -0400 (EDT) Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id 58524402DB for ; Thu, 30 Jun 2022 12:23:28 -0400 (EDT) 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 ams.source.kernel.org (Postfix) with ESMTPS id B41D4B82A7D; 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 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") 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 Cc: will@kernel.org, catalin.marinas@arm.com, linux-kernel@vger.kernel.org, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu 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. _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F38E4C43334 for ; Thu, 30 Jun 2022 16:24:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Subject:Cc:To:From:Message-ID:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=XHRI0+IpVhWDfzk/UYxs20tyUOH/6smF8+k6gdkxgDc=; b=4w7gc+NMN5+M70 DwNZcZ6bjoi4K76Tu5osbOYr0ZxFlgoPMto1tHQsPNJsbl4yZrzrV6JUZBbolkSsM4zi6qNptcZrW lFW8Z4LjXS5DHL5XzCnYuxpSTWkzKgKmg2YbbzADaqXNndrYEZxPlChVnVfOXFfUHSGt9KFJfbkWQ DzYfL1RjiXt7X+bKmpq8hdxMIyaOz4Q5K42X5jtDffLdpvR79kQ24rq2vasPYaJ9JaliEyTliyyMs je/BV4jrwQT/TXaZGpub44np62GqoNLYW23fQQMZ4xzz3GlKbdXTHYMIirPPFMOfZfHEWHqzlYBTj 9o9godXAhdMd/EahA3jQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o6wx2-000bp1-Bh; Thu, 30 Jun 2022 16:23:32 +0000 Received: from ams.source.kernel.org ([2604:1380:4601:e00::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o6wwy-000bnl-2Y for linux-arm-kernel@lists.infradead.org; Thu, 30 Jun 2022 16:23:29 +0000 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 ams.source.kernel.org (Postfix) with ESMTPS id B41D4B82A7D; 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") 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220630_092328_313224_37AE0524 X-CRM114-Status: GOOD ( 25.16 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 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. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel 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.