Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp772099iog; Thu, 30 Jun 2022 09:50:36 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tOUfzqC7esKj5siio5Q29+3qwVtsiaqzVfq94Lu8So4RBD+uUAuOhWdBJEj529m35jjDQv X-Received: by 2002:a17:907:d05:b0:6f4:3729:8e36 with SMTP id gn5-20020a1709070d0500b006f437298e36mr9994892ejc.475.1656607836564; Thu, 30 Jun 2022 09:50:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656607836; cv=none; d=google.com; s=arc-20160816; b=q0B3OFK3v7b/1W0Zlk0SViqzd4rXZBqXClhtY5dfj8d4rEDpJBRrlOblstV5VNOZ9s 9cknesHZQwd6CVxMGWioZBhXT6iJt+hBd7BLZVoGx/PODiMJmUs/0b4UpIozvQxhgvUB dK3vekBrW2Io9mKO7h0wGAIcL4bYQWynX12vNFXS8Nv+JaWjepiUgpoFQmzMU6QI05TX AAHpMhpOeQ2Bvipfq6C2wlsW8pYgufC2C9LD2Lz64SL3RhaczHMYRhUh749zxLoorO++ 2dYrl34gy1xdm1B4gp0m+MdaK9TVZEKQ7nSXV3oNpS3oXocrpDBtbWMUdc/Uru58Q4DP fU+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature; bh=w+8iImmytwz/UkseL6FyO1sDy1udOtexLbCIYNueSpY=; b=S1jKd/ID95ozyavbgKGY5yhkg0IunT8pNtmIGFS4vnoJc833f+hd86/e5Q364T0jvR YVMWL8JjBYYDHsclniMo+2Q0KjFzFr6AyekdsRV1MFi92eLPtFhUx/Jc6XYrL4emWmf7 zMYQWsx0xcuNsDAv0TyQ/Mr7tPfWzCiZXiQY47r+sHOzWVvXckQ8Z4Ba81z9pXvZJhXR dCidVASOQEW25tSrEk3QutBXS87GoRA0R6d4Rwc8f+vgdg3DKYFHc220olgv/bu2VtU5 IwNy7EF/u3N0JK3MhrzBYgzU4r0ovjgcL9VblF3aK9t5YRCjtwrzA0FJuUwB7XHsQQ1+ Dftw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jWKF7Wa7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w16-20020aa7da50000000b004358173ccc6si7174189eds.304.2022.06.30.09.50.04; Thu, 30 Jun 2022 09:50:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jWKF7Wa7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S233902AbiF3QX2 (ORCPT + 99 others); Thu, 30 Jun 2022 12:23:28 -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 X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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.