Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp2149271imw; Wed, 6 Jul 2022 00:31:38 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t1goQmnb/5aoNKsWe0JO9ZX390ZYtO8sADlD3esCaBz55XyEcsw45/2Gdbs/nbE1iecNS7 X-Received: by 2002:a63:6a43:0:b0:411:4fd7:c381 with SMTP id f64-20020a636a43000000b004114fd7c381mr33280088pgc.46.1657092698756; Wed, 06 Jul 2022 00:31:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657092698; cv=none; d=google.com; s=arc-20160816; b=QjdFHwVjpAsdZuLnDxZeR8RvHFtVZi7V/ESiC6ZW8nj+izYJ4e4i9tIhnfhk0roBLl cTHE8iGPMPxhYeURwhCM26lVerL7CHqj2XN+7SZiSVE3SR+1QSzAp0ioFtD2TvEcEDkr 9ChBc3pMDQGVGomCF9tVmeBUTYHgk/bX987A/M+KX0V98J9CyUwgD9alCZdcHYhuN1oY 2ew7RBZUbZ/EsciPQyqomUJgMKx3MC0+ERjBKMetpAQllxUYxGE9qmIiiIZj67mGxVo8 5NeIBRJPoJq0T4InkILltzgBSy8/4sw+/2RpFerdd6OK5Uyrm1SPIxRSE7l16/cjUcRi T0EA== 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=zDEh6HxDNS06DoCbuD0ylt0bvcx85ij8YhJUAsRzdUs=; b=jRKwsXDy6W7SFd5YhjSru4F93MxHuGKsumVFTrr92w/vf+d6efS36D0XT1zp9/2SrJ l6Ww95Jx3LQEpWtm3avXf0hSQ7PXjA6nxOxy005qC5xMnHhrhqP7pk4+bfUsucvqFj3w TdovYr3/CRU6XDkK8QlF8unf6UDmb/qO4IY5srXJFq0SIUD8cNpChfF5bA5P5M552XB9 qKmRW5xbJtosrpxb3nKP+cqhggsyDfSQZXmC2O1EBOwNrl0eQwKabI32xtTxr8Q3+KIH CRXcUi8MRq7UPmEYeI2hMplgKw5GN2Vw2aXrbLGdvG2m6eq/dEtiZQYUdWDPdo/tdA5z gRbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=axxVzqO4; 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 u1-20020a170902b28100b0016bdc4f42c1si12257010plr.508.2022.07.06.00.31.26; Wed, 06 Jul 2022 00:31:38 -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=axxVzqO4; 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 S229779AbiGFHMs (ORCPT + 99 others); Wed, 6 Jul 2022 03:12:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229459AbiGFHMr (ORCPT ); Wed, 6 Jul 2022 03:12:47 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE8A321AC for ; Wed, 6 Jul 2022 00:12:46 -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 ams.source.kernel.org (Postfix) with ESMTPS id 75607B81AE7 for ; Wed, 6 Jul 2022 07:12:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0252FC3411C; Wed, 6 Jul 2022 07:12:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1657091564; bh=MKCelLRGo19jxP5YyzzSs6MDJt/u2Z/VZUjRwVgwoe4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=axxVzqO41y4qRoNIUf/mTmfLsicFzHjqLDXncKogvoPMRQOzBYkmYW6mvLSrOsYVQ QpHD9X6+hn5uJgzWaaLyDlkpZvF2gB6Z8QZoDTluWRvlDgv3VeKf/Bgc6fj2DgS9Vp MaoQHhsRQD242OMsoADmgvJdgLDahqMLL0vwjXNbLCCT7DednMdlaXJFSBa4oooAjq YhLEGBZkY6NRdctft1uUNxWvaRkbPMhp/tLzUFpaYqbYo4AeVlM+ESdtYcSIJWsHS3 cJCs2ABe9cqlS9ARTJgs+ZOY9Pe7HREj3vElhi5+i/q8KdyYcG6Fmqk4zexqU+yRkg IgmvUPuQ/B2EQ== Received: from ip-185-104-136-29.ptr.icomera.net ([185.104.136.29] helo=wait-a-minute.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 1o8zDF-005YP1-Pa; Wed, 06 Jul 2022 08:12:41 +0100 Date: Wed, 06 Jul 2022 08:11:46 +0100 Message-ID: <87edyyn2a5.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: References: <20220630161220.53449-1-schspa@gmail.com> <87mtdu15ok.wl-maz@kernel.org> <87letd0wqm.wl-maz@kernel.org> 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.104.136.29 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.8 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 Fri, 01 Jul 2022 15:22:51 +0100, Schspa Shi wrote: > > > Marc Zyngier writes: > > >> > >> I have running some static code analysis software upon Kernel code. > >> Seeing there is possible overflow. > >> > >> maks << 1U << ((len * 8) -1); > >> > >> The AI don't know, len is only the value of 1, 2, 4, and make this > >> a warnings > >> > >> I tring to analysis this, but didn't realize the real scenario of > >> sign extension, and finally sent this problematic patch. > >> > >> I do see some uninitialized memory reads (the values are not used > >> in the end, just as temporary space for API execution), > >> do we need to fix these? > > > > You need to be more descriptive here. What uninitialised reads? In > > general, pointing at the code and providing a full description of > > what > > you think is incorrect would really help... > > > > M. > One example is > int vgic_v3_has_attr_regs(struct kvm_device *dev, struct > kvm_device_attr *attr) > { > ... > case KVM_DEV_ARM_VGIC_GRP_CPU_SYSREGS: { > u64 reg, id; > > id = (attr->attr & KVM_DEV_ARM_VGIC_SYSREG_INSTR_MASK); > return vgic_v3_has_cpu_sysregs_attr(vcpu, 0, id, ®); > } > > } > > The funcion vgic_v3_has_cpu_sysregs_attr will read reg's value to > params without initialization. There should have no problems, > because the register value never used. Thanks for pointing this out. I spent some time looking at this, and this is only the tip of the iceberg. The whole userspace interaction with the GIC sysregs is ugly (at best), and needs some love. I've written a small series[1] cleaning things up, which needs testing (I've just checked that it was compiling correctly). I'd appreciate you running your tool on it. M. [1] https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms.git/log/?h=kvm-arm64/sysreg-cleanup-5.20 -- Without deviation from the norm, progress is not possible.