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 50EA2C7EE2F for ; Wed, 31 May 2023 07:24:42 +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=wXIpaccywA9kFwy9Po+y+9Zteo843IJpLGI5o89wRc4=; b=vILprVXoh1UO4Y UDtwcm1ctTMBH8kqUfPfXfWP6nkRzkpd9NDfzamVZTB9C6hXPh/eiKqjcULMXhBdvK8tcqOADk/6w v9JcaODdm8zqAkQ/QZM+vR+onPsCHu+sVTWdJxbkFZoqCdeQPhV8HDmBI7RVmv8JvvOmfi/9NX8C9 r42fraYzwutzZv56bs1gXNGQWr0xQv4+/3I32r6ih/MgJ3Zj4hJFf5s0cHvjHQzItGCbDVG8Jt4vI /j2RO21o48qiLUAQH5MbFWZZsmnEYf+7UuebCPJobbJ1UqVc15LXEKuqDWRu+cnqk4y6s9+nJ4GDA e8LfIbCMyFk9AfZE/DeA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q4GBs-00GQNs-0m; Wed, 31 May 2023 07:24:16 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q4GBp-00GQNG-21 for linux-arm-kernel@lists.infradead.org; Wed, 31 May 2023 07:24:14 +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 dfw.source.kernel.org (Postfix) with ESMTPS id F27B26186A; Wed, 31 May 2023 07:24:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5706DC433EF; Wed, 31 May 2023 07:24:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685517852; bh=cPobS0FDQDC2RM/4dx6AuvjAZHc07sjiueJgxoqErzE=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=V/hAxAD64Ao250VunieA9RR28JaZFX7DF0jJG7DoMp3sg462N9SHobK1FHf4eXC2U 6OkJZC8mFipA2BCETQEuaKm32nYDvfjbW//oHkBvvwZooXCjrZ3B99lHthjg1pJ0OS MhmmS/QEBfHxqv8Ax36yLAvYmkKLP+Ya9GsDZSg0jPunSlmZ5WjA9xuZhSEYqleMYb /w1+iyNj3PimxfaosIQUkblVafFBA0NiXN/iINXNluaW4qBzpJb3y/f2nhknbMCUJI XLKAo7S4TZQinOXsWw/3YaZV6BBhIARzafe5Kn7jA9oi7nMQA/GY6thnu1VKlhkHEX 1gXg1TrzK1umw== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.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 1q4GBl-001Xi0-Vr; Wed, 31 May 2023 08:24:10 +0100 Date: Wed, 31 May 2023 08:24:09 +0100 Message-ID: <864jntc6au.wl-maz@kernel.org> From: Marc Zyngier To: Jing Zhang Cc: KVM , KVMARM , ARMLinux , Oliver Upton , Will Deacon , Paolo Bonzini , James Morse , Alexandru Elisei , Suzuki K Poulose , Fuad Tabba , Reiji Watanabe , Raghavendra Rao Ananta Subject: Re: [PATCH v10 1/5] KVM: arm64: Save ID registers' sanitized value per guest In-Reply-To: References: <20230522221835.957419-1-jingzhangos@google.com> <20230522221835.957419-2-jingzhangos@google.com> <87ttvwok3d.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/28.2 (aarch64-unknown-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: jingzhangos@google.com, kvm@vger.kernel.org, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, oupton@google.com, will@kernel.org, pbonzini@redhat.com, james.morse@arm.com, alexandru.elisei@arm.com, suzuki.poulose@arm.com, tabba@google.com, reijiw@google.com, rananta@google.com 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-20230531_002413_752784_45AE6937 X-CRM114-Status: GOOD ( 24.75 ) 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 Tue, 30 May 2023 19:02:03 +0100, Jing Zhang wrote: [...] > > > +/* > > > + * Set the guest's ID registers with ID_SANITISED() to the host's sanitized value. > > > + */ > > > +void kvm_arm_init_id_regs(struct kvm *kvm) > > > +{ > > > + const struct sys_reg_desc *idreg; > > > + struct sys_reg_params params; > > > + u32 id; > > > + > > > + /* Find the first idreg (SYS_ID_PFR0_EL1) in sys_reg_descs. */ > > > + id = SYS_ID_PFR0_EL1; > > > + params = encoding_to_params(id); > > > + idreg = find_reg(¶ms, sys_reg_descs, ARRAY_SIZE(sys_reg_descs)); > > > + if (WARN_ON(!idreg)) > > > + return; > > > > What is this trying to guard against? Not finding ID_PFR0_EL1 in the > > sysreg table? But this says nothing about the following registers (all > > 55 of them), so why do we need to special-case this one? > Here is to find the first idreg in the array and warn that no idregs > found in the array with the assumption that ID_PFR0_EL1 is the first > one defined and if it is not found, then no other idregs are defined > either. I didn't make my point clear. What we have is a purely static array. Why should we perform such a test on every single VM creation? Any structural validation should only happen once, at KVM init time. > Another way is to go through all the regs in array sys_reg_descs and > do the initialization if it is a idreg. That'd be a waste of precious cycles. This WARN_ON()+early return should go, but the rest is fine. Thanks, 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