From mboxrd@z Thu Jan 1 00:00:00 1970 From: Radim =?utf-8?B?S3LEjW3DocWZ?= Subject: Re: [PATCH v4 2/2] KVM: x86: KVM_CAP_SYNC_REGS Date: Fri, 2 Feb 2018 22:04:35 +0100 Message-ID: <20180202210434.GC27896@flask> References: <20180201000336.154170-1-hofsass@google.com> <20180201000336.154170-3-hofsass@google.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: David Hildenbrand , kvm@vger.kernel.org, pbonzini@redhat.com, jmattson@google.com To: Ken Hofsass Return-path: Received: from mx1.redhat.com ([209.132.183.28]:7520 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751878AbeBBVFB (ORCPT ); Fri, 2 Feb 2018 16:05:01 -0500 Content-Disposition: inline In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: 2018-02-01 14:05+0100, David Hildenbrand: > > @@ -7351,6 +7363,17 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) > > goto out; > > } > > > > + if (vcpu->run->kvm_valid_regs) { > > You can check directly, without this if. (and not sure if the extra > function is needed here). Right, it's unlikely that we'll be doing more checks on kvm_valid_regs, so I've moved it here and replaced the block with if (vcpu->run->kvm_valid_regs & ~KVM_SYNC_X86_VALID_FIELDS) { r = -EINVAL; goto out; } You can see the result in kvm/queue. Btw. the userspace doesn't know what the next userspace exit is going to be, so it the purpose of kvm_valid_regs to avoid needless writes of registers on old userspaces? Thanks. > > + r = check_valid_regs(vcpu); > > + if (r != 0) > > + goto out; > > + }