Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp741476iog; Thu, 30 Jun 2022 09:16:15 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tJ8FlaPml8ALru/DMv785vFKvVq+h0oZA1EYGIKhR04jbHoK/JxWWEMrmaA7Ao5MNhe38y X-Received: by 2002:a05:6402:26d2:b0:435:ccc1:822b with SMTP id x18-20020a05640226d200b00435ccc1822bmr12902663edd.53.1656605775395; Thu, 30 Jun 2022 09:16:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656605775; cv=none; d=google.com; s=arc-20160816; b=l38ESXHNcMWHut0YGCgfAQBWrBR1SeFrKWC3ZGHQhUu1gJNfmdaDKNuA7aNhGafbS4 UFNGRtIYGCSXH9ykNIpSj3n7sYt8f9Wa8FKpcS2Zro0O58mCBu4vNgnnulKeUpQc7R77 JDb8GohzHuKtfUEPnseixMnvNWZFUkjLQcVIXoEW4ThFgjK9/Dp/pAIicWruq8wzqRMD jc+Hqn51+HGYrzAfGplQoQj7DREh+Al/lLyh+afP90dXlnOSCpymnJF/l1eX81hKF5Lw orRS0EVVsFygClqCDNgeJ9R+MdSzwVOcqWDY5V2yjDUYkapfWmZgmkIPvL+/ecQBSXGc oOWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=HIeZ7ZUFR8uUdavug06JIRw9ETH7oXgy29YJGJmtVOc=; b=PO3U/B24lo6k9lP2AjFaO26zTVXxGcyyVem7ZZIYd3IPA3kkAfQu36CKWXks5sp7rl T8prLKEpcAjCGfmVVXl+HvPVEqukKmNyxFQZg6yqbVq0U8vhLdBjAlXzzaOep4MVk2fh NTEWx20vcbZnPa0qa3ZIFp3HOP1UgCx1RsVyII1P4+EiHxc88Ke1n3iXq7aAcv1tJ8DL hNPSAzQuVs3YybqKG8DjjO8jo2meMoaWGiSU0hXPME2cZfa3iqR+9NZBfbY2zDgk0fvD IE3mleu2gTBaz1uy+6YLMtv3UXpH/gTlXhs4Y8XwzPNMYt1BvS0H80BmdfLiyYweVRCI d7YA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=b+M1vpvB; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v1-20020a50d081000000b0043572b5ef82si1179806edd.546.2022.06.30.09.15.48; Thu, 30 Jun 2022 09:16:15 -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=@gmail.com header.s=20210112 header.b=b+M1vpvB; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235603AbiF3QMe (ORCPT + 99 others); Thu, 30 Jun 2022 12:12:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235383AbiF3QMc (ORCPT ); Thu, 30 Jun 2022 12:12:32 -0400 Received: from mail-qv1-xf31.google.com (mail-qv1-xf31.google.com [IPv6:2607:f8b0:4864:20::f31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9F223120B for ; Thu, 30 Jun 2022 09:12:31 -0700 (PDT) Received: by mail-qv1-xf31.google.com with SMTP id q4so30412274qvq.8 for ; Thu, 30 Jun 2022 09:12:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=HIeZ7ZUFR8uUdavug06JIRw9ETH7oXgy29YJGJmtVOc=; b=b+M1vpvBViKPkT7LE/wlsBdInOEtZXiDskB4CB2QW8+u5WsEPZF0c1RMTs2h9V3xZs pfIZKzeFDEP6J/hbU1K0tq5ZovFpcUV+u9+O56dor8++DCNgfXqQc4mnBtSZkGHlVOqh VR/SMgpXHDLtwHmihcb2288zkxNweUUqu76i4ke3qQmQiZLoSYWT/3waOCXJ975kQNp3 G3CDLaQJl45OvtgT5ElISQgnBF3OmbgRogKE2McTxZxpwjXnJHP331Wy5fVKUBr5gVla BADiWcfdnke7tA6xZ3LEGvCAhLh7sb3mtZuJrN+DQ7NMpx5pg3HH8d6AkU+v2ZRj9iHr CSIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=HIeZ7ZUFR8uUdavug06JIRw9ETH7oXgy29YJGJmtVOc=; b=ERdn/Mzx4uKUhhJ04Ycq2k+UCVH0ATzI1F5Op41qFWbN6NeEU6sHqJH6vuPh46H5lx L4b/wyFszMLVxaIPcaMZEYHrJM6qMgsbPdvM07HP9OQiFyBtzQ6BPiq14aTIHqs9j50T NSKQsSXQgdzoLyxw7XCCiYX1DhMwPXHdSuWXOKM+saW6XMlAnRh+g9+AKx2bGD14fqhC B0eteJLGZCZ+GujvpVQf38etSIv91ruAlCX8p+gCNp/cf46Q3EzGZb5mda2drIJy6QP4 mwyOQGulOvT1MxVZG0mt+/vZmjQJh5/Sm4kmB9X3erHOjCiKCMEb7hgQ7BzSolOBisvR +ESg== X-Gm-Message-State: AJIora+zGmN3gf5oisTdiYxXE2A4MQ+VEpq11x2KtAYHf+1FdBjQcOIq i6ZViPZQAU+dZ2DrUUKhsYE= X-Received: by 2002:ac8:5c0c:0:b0:31b:b39b:12b0 with SMTP id i12-20020ac85c0c000000b0031bb39b12b0mr8264577qti.4.1656605550844; Thu, 30 Jun 2022 09:12:30 -0700 (PDT) Received: from MBP.hobot.cc (ec2-13-59-0-164.us-east-2.compute.amazonaws.com. [13.59.0.164]) by smtp.gmail.com with ESMTPSA id m14-20020a05620a24ce00b006af59e9ddeasm6623151qkn.18.2022.06.30.09.12.26 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Jun 2022 09:12:30 -0700 (PDT) From: Schspa Shi To: maz@kernel.org, james.morse@arm.com, alexandru.elisei@arm.com, suzuki.poulose@arm.com, catalin.marinas@arm.com, will@kernel.org Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, Schspa Shi Subject: [PATCH] KVM: arm64: Fix 64 bit mmio handle Date: Fri, 1 Jul 2022 00:12:20 +0800 Message-Id: <20220630161220.53449-1-schspa@gmail.com> X-Mailer: git-send-email 2.29.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 If the len is 8 bytes, we can't get the correct sign extend for be system. 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)) { mask = 1U << ((len * 8) - 1); data = (data ^ mask) - mask; } -- 2.37.0