From patchwork Wed Sep 20 19:50:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Upton X-Patchwork-Id: 13393360 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 F07DFC04FEE for ; Wed, 20 Sep 2023 19:51:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230178AbjITTvF (ORCPT ); Wed, 20 Sep 2023 15:51:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230170AbjITTvD (ORCPT ); Wed, 20 Sep 2023 15:51:03 -0400 Received: from out-213.mta0.migadu.com (out-213.mta0.migadu.com [IPv6:2001:41d0:1004:224b::d5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0244BD6 for ; Wed, 20 Sep 2023 12:50:57 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1695239455; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=C3t7Tx6eEZI7zC55Ut5AMznCQ8vTN93NHvrb/xhr1po=; b=NhbhCjDhoYAgg50q+TYrMfp1oB8IBdZCbWxM+y2agTmhjW7nhLZYJQ4i87MgqdSeck6DWD nf7g15DE0411PUv5AGVc4myh1vhv0F37Gi8dAr3jW+dAsE2AxWG5i0KDv67fTaNnU0u/zy 6QsCtFuli602EcHWO0jolCWBQ5dWc4Y= From: Oliver Upton To: kvmarm@lists.linux.dev Cc: kvm@vger.kernel.org, Marc Zyngier , James Morse , Suzuki K Poulose , Zenghui Yu , Oliver Upton Subject: [PATCH 6/8] KVM: arm64: Hoist NV+SVE check into KVM_ARM_VCPU_INIT ioctl handler Date: Wed, 20 Sep 2023 19:50:34 +0000 Message-ID: <20230920195036.1169791-7-oliver.upton@linux.dev> In-Reply-To: <20230920195036.1169791-1-oliver.upton@linux.dev> References: <20230920195036.1169791-1-oliver.upton@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Move the feature check out of kvm_reset_vcpu() so we can make the function succeed uncondtitionally. Signed-off-by: Oliver Upton --- arch/arm64/kvm/arm.c | 5 +++++ arch/arm64/kvm/reset.c | 8 +------- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index ef92c2f2de70..cae7a2df52ab 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -1239,6 +1239,11 @@ static int kvm_vcpu_init_check_features(struct kvm_vcpu *vcpu, test_bit(KVM_ARM_VCPU_PTRAUTH_GENERIC, &features)) return -EINVAL; + /* Disallow NV+SVE for the time being */ + if (test_bit(KVM_ARM_VCPU_HAS_EL2, &features) && + test_bit(KVM_ARM_VCPU_SVE, &features)) + return -EINVAL; + if (!test_bit(KVM_ARM_VCPU_EL1_32BIT, &features)) return 0; diff --git a/arch/arm64/kvm/reset.c b/arch/arm64/kvm/reset.c index bbcf5bbd66d9..edffbfab5e7b 100644 --- a/arch/arm64/kvm/reset.c +++ b/arch/arm64/kvm/reset.c @@ -208,12 +208,6 @@ int kvm_reset_vcpu(struct kvm_vcpu *vcpu) if (loaded) kvm_arch_vcpu_put(vcpu); - /* Disallow NV+SVE for the time being */ - if (vcpu_has_nv(vcpu) && vcpu_has_feature(vcpu, KVM_ARM_VCPU_SVE)) { - ret = -EINVAL; - goto out; - } - if (!kvm_arm_vcpu_sve_finalized(vcpu)) { if (test_bit(KVM_ARM_VCPU_SVE, vcpu->arch.features)) kvm_vcpu_enable_sve(vcpu); @@ -267,7 +261,7 @@ int kvm_reset_vcpu(struct kvm_vcpu *vcpu) /* Reset timer */ ret = kvm_timer_vcpu_reset(vcpu); -out: + if (loaded) kvm_arch_vcpu_load(vcpu, smp_processor_id()); preempt_enable();