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 33874C433F5 for ; Wed, 9 Feb 2022 12:15:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232787AbiBIMPd (ORCPT ); Wed, 9 Feb 2022 07:15:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232825AbiBIMPN (ORCPT ); Wed, 9 Feb 2022 07:15:13 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D52B5E030195 for ; Wed, 9 Feb 2022 04:04:42 -0800 (PST) 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 82350B82081 for ; Wed, 9 Feb 2022 12:04:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 301CEC340EF; Wed, 9 Feb 2022 12:04:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1644408280; bh=X3JslEcts3201WhkIsOB99xq0WjL+sdJPjqwAwvB/GM=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=auMFBMIykaOHfvoauJj/NIr2wF7cNLi5UIVz2VN/IJU18jra87XpEWCDWuoiZX973 EK61tfJW86VSmprbpkN1ID0T99CV7/txtPJmvS1e+FGRC7BaQCeSpbNmghg9h16UIo KfS3Jdml8NOApQDxYBDfhszZLRj4Pfu4EBwKGZoMgyfDU6YqsED9oi679t5pHT2ojK ObUrk9sJdiw2WFP/OQsJIOFu5U4EXuJ9NFi7Tk9u9q/mppphaM06s1/N9LlbGdthgu TTvnp3BthD7vamWqes9g06zNHljN8MteT755QGNJEBXIG8FO3dvCmEDl/H9lecjMr3 5q8DHRn9hNa4w== 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.94.2) (envelope-from ) id 1nHli9-006bcc-Rn; Wed, 09 Feb 2022 12:04:38 +0000 Date: Wed, 09 Feb 2022 12:04:37 +0000 Message-ID: <875ypo5jqi.wl-maz@kernel.org> From: Marc Zyngier To: Reiji Watanabe Cc: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, Linux ARM , James Morse , Alexandru Elisei , Suzuki K Poulose , Paolo Bonzini , Will Deacon , Peter Shier , Ricardo Koller , Oliver Upton , Jing Zhang , Raghavendra Rao Anata Subject: Re: [PATCH v2 1/2] KVM: arm64: mixed-width check should be skipped for uninitialized vCPUs In-Reply-To: References: <20220118041923.3384602-1-reijiw@google.com> <87a6f15skj.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.219.108.64 X-SA-Exim-Rcpt-To: reijiw@google.com, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, james.morse@arm.com, alexandru.elisei@arm.com, suzuki.poulose@arm.com, pbonzini@redhat.com, will@kernel.org, pshier@google.com, ricarkol@google.com, oupton@google.com, jingzhangos@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 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Hi Reiji, On Wed, 09 Feb 2022 05:32:36 +0000, Reiji Watanabe wrote: > > Hi Marc, > > On Tue, Feb 8, 2022 at 6:41 AM Marc Zyngier wrote: > > > > In [1], I suggested another approach that didn't require extra state, > > and moved the existing checks under the kvm lock. What was wrong with > > that approach? > > With that approach, even for a vcpu that has a broken set of features, > which leads kvm_reset_vcpu() to fail for the vcpu, the vcpu->arch.features > are checked by other vCPUs' vcpu_allowed_register_width() until the > vcpu->arch.target is set to -1. > Due to this, I would think some or possibly all vCPUs' kvm_reset_vcpu() > may or may not fail (e.g. if userspace tries to configure vCPU#0 with > 32bit EL1, and vCPU#1 and #2 with 64 bit EL1, KVM_ARM_VCPU_INIT > for either vCPU#0, or both vCPU#1 and #2 should fail. But, with that > approach, it doesn't always work that way. Instead, KVM_ARM_VCPU_INIT > for all vCPUs could fail or KVM_ARM_VCPU_INIT for vCPU#0 and #1 could > fail while the one for CPU#2 works). > Also, even after the first KVM_RUN for vCPUs are already done, > (the first) KVM_ARM_VCPU_INIT for another vCPU could cause the > kvm_reset_vcpu() for those vCPUs to fail. > > I would think those behaviors are odd, and I wanted to avoid them. OK, fair enough. But then you need to remove most of the uses of KVM_ARM_VCPU_EL1_32BIT so that it is only used as a userspace interface and maybe not carried as part of the vcpu feature flag anymore. Also, we really should turn all these various bits in the kvm struct into a set of flags. I have a patch posted there[1] for this, feel free to pick it up. Thanks, M. [1] https://lore.kernel.org/r/20211004174849.2831548-2-maz@kernel.org -- Without deviation from the norm, progress is not possible.