Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1884527pxv; Fri, 2 Jul 2021 15:07:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxlY+kT+29h/hRcjU8Ba2vx1XYVm00isV7JDNT+ehpyngXPHQmYIet60VVn2G/DS0SSIeyL X-Received: by 2002:aa7:cd9a:: with SMTP id x26mr1951907edv.185.1625263647937; Fri, 02 Jul 2021 15:07:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625263647; cv=none; d=google.com; s=arc-20160816; b=pfecDrOU9KeScWVh8z5ExtxBqKleLzhiMwA3CSd9Sza7OpVBi5E4AInjKgxVA+zfAa EyQk59FCJ/WXoOGd8XNbCbnXHBSZ/A74h+/aXafEw857J2pWjxqZoo46BjFbdBrKrfx9 c/sLzJdoGaJNfL/8OBhvG4nP1E5d8MrzvY0WnKBQnXx/ENKO/M3OzdaDZJsBiP+T4f0l fRNsKAvAjomJwLkNquzqoJlR+936lIOHmTSRq2MUIBfQbiFVyD1Bkm5mpbiBPtOjql/6 6BMXnd1b8dgBcYlQREYBB8sTVfOriE70t0f3oD50AhXppfToMh6Meco/ELN09mcF2FO1 4LpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=lAXPqbMCGM0iwmxjFCBWcCws4mRzXrtD/F/P85hxw2o=; b=hH9x7q3vwGqMV+WB6fF+mCEs5AB0MIK+3BgTQzIwK9noKaVDU4VEJqKx3mRBpUdk/D H97PI0hoc29fgDC3VvFwwlv7/xGLqNbBMU9rScqxWM2NbfHXXppFVVkeNRM3ZSfXM+eq 8AIay3pmwggycCUYzuwCWFK7oh6FAPK4GmcYmiDdB92tTS9+9mljl2NVaexwNlCmVWE6 /3kARTrekFz/C7l4KKqcdncoOPS9ECpd0Q62zXzDEWJ1oMTFYjXOsldSjqLhuEXqZczU dJQpxmQvV1wp8V458BhvxUBGu3c7j5nkRvJcs7DUfPmulobmCiD+PdN59WdaYaQKlNBi OQYQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ht7si4718737ejc.487.2021.07.02.15.07.05; Fri, 02 Jul 2021 15:07:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233497AbhGBWIQ (ORCPT + 99 others); Fri, 2 Jul 2021 18:08:16 -0400 Received: from mga04.intel.com ([192.55.52.120]:41687 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233090AbhGBWH4 (ORCPT ); Fri, 2 Jul 2021 18:07:56 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10033"; a="206962965" X-IronPort-AV: E=Sophos;i="5.83,320,1616482800"; d="scan'208";a="206962965" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jul 2021 15:05:23 -0700 X-IronPort-AV: E=Sophos;i="5.83,320,1616482800"; d="scan'208";a="642814746" Received: from ls.sc.intel.com (HELO localhost) ([143.183.96.54]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jul 2021 15:05:23 -0700 From: isaku.yamahata@intel.com To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H . Peter Anvin" , Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , erdemaktas@google.com, Connor Kuehl , Sean Christopherson , x86@kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: isaku.yamahata@intel.com, isaku.yamahata@gmail.com, Sean Christopherson Subject: [RFC PATCH v2 23/69] KVM: x86: Hoist kvm_dirty_regs check out of sync_regs() Date: Fri, 2 Jul 2021 15:04:29 -0700 Message-Id: <889017a8d31cea46472e0c64b234ef5919278ed9.1625186503.git.isaku.yamahata@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sean Christopherson Move the kvm_dirty_regs vs. KVM_SYNC_X86_VALID_FIELDS check out of sync_regs() and into its sole caller, kvm_arch_vcpu_ioctl_run(). This allows a future patch to allow synchronizing select state for protected VMs. Signed-off-by: Sean Christopherson Signed-off-by: Isaku Yamahata --- arch/x86/kvm/x86.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index d7110d48cbc1..271245ffc67c 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -9729,7 +9729,8 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu) goto out; } - if (kvm_run->kvm_valid_regs & ~KVM_SYNC_X86_VALID_FIELDS) { + if ((kvm_run->kvm_valid_regs & ~KVM_SYNC_X86_VALID_FIELDS) || + (kvm_run->kvm_dirty_regs & ~KVM_SYNC_X86_VALID_FIELDS)) { r = -EINVAL; goto out; } @@ -10264,9 +10265,6 @@ static void store_regs(struct kvm_vcpu *vcpu) static int sync_regs(struct kvm_vcpu *vcpu) { - if (vcpu->run->kvm_dirty_regs & ~KVM_SYNC_X86_VALID_FIELDS) - return -EINVAL; - if (vcpu->run->kvm_dirty_regs & KVM_SYNC_X86_REGS) { __set_regs(vcpu, &vcpu->run->s.regs.regs); vcpu->run->kvm_dirty_regs &= ~KVM_SYNC_X86_REGS; -- 2.25.1