From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 99B1D378 for ; Sat, 24 Jun 2023 00:45:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 185FDC433C9; Sat, 24 Jun 2023 00:45:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1687567552; bh=VGM5jdVPKFZOPSSWK/p2rJbl4Q/ezdeR2fPyQs+NKzA=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=RUwLWHUgwGZRtmNhcr/KFY2JNKCfKMBFhXgaMZ5XP51C1WpA5CJcDeiKjPPp9+cqK gOW3Gp9AXY6FQce2ED55K9N5c6Bp4zo1vNTjWVkQfA+ww5QicgiV32vE6JbUEscDqr bQrdue7GuKcthz1qkSQc+UAzZXQ7GUOXvVYcHuW1SjsxHVPw6DNuuepXMuiPivW3Za 3znhDscvA8vAGI6GKj9Dv+91kFCxUvUXKIWdSelN78AhlRBnM3akhxHW7ekm4Zjdtz S6YjE0iWyVugJaLSGF1OBIauIMSrzgL8yZ0joovHtwKo3Cth2po5Pn6AhUvday7WNZ /Y8eS7D7y0oBA== Received: from [206.0.71.13] (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 1qCrPQ-007teZ-R6; Sat, 24 Jun 2023 01:45:49 +0100 Date: Sat, 24 Jun 2023 01:45:43 +0100 Message-ID: <87pm5lpu14.wl-maz@kernel.org> From: Marc Zyngier To: Oliver Upton Cc: kvmarm@lists.linux.dev, James Morse , Suzuki K Poulose , Zenghui Yu , Jing Zhang , Reiji Watanabe Subject: Re: [PATCH 4/4] KVM: arm64: Always return generic v8 as the preferred target In-Reply-To: <20230623194258.2648987-5-oliver.upton@linux.dev> References: <20230623194258.2648987-1-oliver.upton@linux.dev> <20230623194258.2648987-5-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) Precedence: bulk X-Mailing-List: kvmarm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 206.0.71.13 X-SA-Exim-Rcpt-To: oliver.upton@linux.dev, kvmarm@lists.linux.dev, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, jingzhangos@google.com, reijiw@google.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false On Fri, 23 Jun 2023 20:42:58 +0100, Oliver Upton wrote: > > Userspace selecting an implementation-specific vCPU target has been > completely useless for a very long time. Let's go whole hog and start > returning the generic v8 target across all implementations as the > preferred target. > > Uphold the pre-existing behavior by tolerating either the generic target > or an implementation-specific target if the vCPU happens to be running > on one of the lucky few parts. > > Signed-off-by: Oliver Upton > --- > arch/arm64/kvm/arm.c | 3 ++- > arch/arm64/kvm/guest.c | 4 +--- > 2 files changed, 3 insertions(+), 4 deletions(-) > > diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c > index 3fa63fdbbf34..5a3b8b2e779b 100644 > --- a/arch/arm64/kvm/arm.c > +++ b/arch/arm64/kvm/arm.c > @@ -1250,7 +1250,8 @@ static int kvm_vcpu_set_target(struct kvm_vcpu *vcpu, > { > int ret; > > - if (init->target != kvm_target_cpu()) > + if (init->target != KVM_ARM_TARGET_GENERIC_V8 && > + init->target != kvm_target_cpu()) > return -EINVAL; > > ret = kvm_vcpu_init_check_features(vcpu, init); > diff --git a/arch/arm64/kvm/guest.c b/arch/arm64/kvm/guest.c > index 20280a5233f6..6b099a914fd4 100644 > --- a/arch/arm64/kvm/guest.c > +++ b/arch/arm64/kvm/guest.c > @@ -886,8 +886,6 @@ u32 __attribute_const__ kvm_target_cpu(void) > > void kvm_vcpu_preferred_target(struct kvm_vcpu_init *init) > { > - u32 target = kvm_target_cpu(); > - > memset(init, 0, sizeof(*init)); > > /* > @@ -896,7 +894,7 @@ void kvm_vcpu_preferred_target(struct kvm_vcpu_init *init) > * specific features available for the preferred > * target type. > */ > - init->target = (__u32)target; > + init->target = KVM_ARM_TARGET_GENERIC_V8; > } Should we take the opportunity to simply get rid of this function altogether? Something like the untested hack below. Thanks, M. diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index bad7dfe9c16d..67038b4e97e4 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -890,7 +890,6 @@ struct kvm_vcpu_stat { u64 exits; }; -void kvm_vcpu_preferred_target(struct kvm_vcpu_init *init); unsigned long kvm_arm_num_regs(struct kvm_vcpu *vcpu); int kvm_arm_copy_reg_indices(struct kvm_vcpu *vcpu, u64 __user *indices); int kvm_arm_get_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg); diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index c2c14059f6a8..6fc147bd8f05 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -1588,9 +1588,9 @@ int kvm_arch_vm_ioctl(struct file *filp, unsigned int ioctl, unsigned long arg) return kvm_vm_ioctl_set_device_addr(kvm, &dev_addr); } case KVM_ARM_PREFERRED_TARGET: { - struct kvm_vcpu_init init; - - kvm_vcpu_preferred_target(&init); + struct kvm_vcpu_init init = { + .target = KVM_ARM_TARGET_GENERIC_V8; + }; if (copy_to_user(argp, &init, sizeof(init))) return -EFAULT; diff --git a/arch/arm64/kvm/guest.c b/arch/arm64/kvm/guest.c index 20280a5233f6..95f6945c4432 100644 --- a/arch/arm64/kvm/guest.c +++ b/arch/arm64/kvm/guest.c @@ -884,21 +884,6 @@ u32 __attribute_const__ kvm_target_cpu(void) return KVM_ARM_TARGET_GENERIC_V8; } -void kvm_vcpu_preferred_target(struct kvm_vcpu_init *init) -{ - u32 target = kvm_target_cpu(); - - memset(init, 0, sizeof(*init)); - - /* - * For now, we don't return any features. - * In future, we might use features to return target - * specific features available for the preferred - * target type. - */ - init->target = (__u32)target; -} - int kvm_arch_vcpu_ioctl_get_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu) { return -EINVAL; -- Without deviation from the norm, progress is not possible.