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 02A69E7D0AF for ; Thu, 21 Sep 2023 22:15:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231566AbjIUWPu (ORCPT ); Thu, 21 Sep 2023 18:15:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233174AbjIUWPZ (ORCPT ); Thu, 21 Sep 2023 18:15:25 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DCA878331D for ; Thu, 21 Sep 2023 10:37:25 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C0D7FC116CA; Thu, 21 Sep 2023 08:31:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695285062; bh=kB4LhEjqLrRHXbvRoCAvnP5iEiWmIRBRjQ+v51+IXkY=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=UsRlVqGQVju8/qDh03TLqaHEO8aM9FoYk6nyBZGIgwEfoYbvxMR2SzbauwXO6Fm7f 9m+Hs2nV+DG8BANdv1V4rQxVPtivVRVjtc5CdzXdSaSO/+18y5jl5LEcH8TRXH2kn2 I/KWYdKAS1AkADu8xu5Ua2F8MTt/JLwsH8KBabMQkQCgDGwJY57taq5hS04+5fZoak /OXPlGJagdcoQNNMyPXX6pZBnGK0Jh0dFaHvrxPfP9qK+KpGT3A2QFU8RdEbD/yNio YyOe3ADN6Rzo2jvSFqGnsbOmDSIGdW21ghzCOTUeIioepD+YGMhLMA/8cfmMhEQESX zBkqcWAt6DcIQ== Received: from 82-132-232-12.dab.02.net ([82.132.232.12] 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 1qjF5P-00Esfc-SV; Thu, 21 Sep 2023 09:31:00 +0100 Date: Thu, 21 Sep 2023 09:30:27 +0100 Message-ID: <87wmwk2ajg.wl-maz@kernel.org> From: Marc Zyngier To: Oliver Upton Cc: kvmarm@lists.linux.dev, kvm@vger.kernel.org, James Morse , Suzuki K Poulose , Zenghui Yu Subject: Re: [PATCH 1/8] KVM: arm64: Add generic check for system-supported vCPU features In-Reply-To: <20230920195036.1169791-2-oliver.upton@linux.dev> References: <20230920195036.1169791-1-oliver.upton@linux.dev> <20230920195036.1169791-2-oliver.upton@linux.dev> 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 (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: 82.132.232.12 X-SA-Exim-Rcpt-To: oliver.upton@linux.dev, kvmarm@lists.linux.dev, kvm@vger.kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.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 On Wed, 20 Sep 2023 20:50:29 +0100, Oliver Upton wrote: > > To date KVM has relied on kvm_reset_vcpu() failing when the vCPU feature > flags are unsupported by the system. This is a bit messy since > kvm_reset_vcpu() is called at runtime outside of the KVM_ARM_VCPU_INIT > ioctl when it is expected to succeed. Further complicating the matter is > that kvm_reset_vcpu() must tolerate be idemptotent to the config_lock, > as it isn't consistently called with the lock held. > > Prepare to move feature compatibility checks out of kvm_reset_vcpu() with > a 'generic' check that compares the user-provided flags with a computed > maximum feature set for the system. > > Signed-off-by: Oliver Upton > --- > arch/arm64/kvm/arm.c | 16 +++++++++++++--- > 1 file changed, 13 insertions(+), 3 deletions(-) > > diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c > index 4866b3f7b4ea..66f3720cdd3a 100644 > --- a/arch/arm64/kvm/arm.c > +++ b/arch/arm64/kvm/arm.c > @@ -1190,6 +1190,16 @@ int kvm_vm_ioctl_irq_line(struct kvm *kvm, struct kvm_irq_level *irq_level, > return -EINVAL; > } > > +static unsigned long system_supported_vcpu_features(void) > +{ > + unsigned long features = KVM_VCPU_VALID_FEATURES; > + > + if (!cpus_have_const_cap(ARM64_HAS_32BIT_EL1)) I think we can now convert this to a cpus_have_final_cap(), as Mark is getting rid of the helper altogether, see [1]. Thanks, M. [1] https://lore.kernel.org/r/20230919092850.1940729-1-mark.rutland@arm.com -- Without deviation from the norm, progress is not possible.