Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp795921ybh; Wed, 22 Jul 2020 13:34:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwMP7D11bTOhnhKlKU6CXqUlT/rrfX+4HHUZK3M5HIlrruzkVfWBUWE69HZNoMAEaRwko8Q X-Received: by 2002:a17:906:ca43:: with SMTP id jx3mr1287241ejb.208.1595450041762; Wed, 22 Jul 2020 13:34:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595450041; cv=none; d=google.com; s=arc-20160816; b=VMcmJce69YSZBF+rhJ/qgPcYJYBMQfW3xYaZJbCgY1DYcZcDPxalrz/172qAi8xR4H /VPFvPE86NVrlQoeC82xy3yehUDvVVjb/w/3lho2bebR1pZntAg63jfe3U4SOV7pZlyL mijxe9tfb7z4ZMF68T+liJAn6k09Oe6w101dLZY1hNplmRagSKWSaYz+SV1MbRGcHWvl tgHqNauPP79OsZIPCb1S47sGrneZ38WhFLPUjO+kpif87kP8nqB37T6tGYcJjmN2JIge okeSIBp2dyj0+9RZ4TORAsApnCpjeNlh+iQovFM3bQw8D/xX4TtgtWKhfEshVlwzVEFJ zpUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:ironport-sdr:ironport-sdr; bh=fVFqdUPCayhJ6L6Z3W4g6cdskPxuVYS5VHUuz37OxAo=; b=v0iUaQwbNK637RXc0AowAQNdqogVRnKbgy3ZZkd9FxtFkmqKyD+Rnz8rgW5Exa9Mkm Mlf5Jv8k4gfUSM0F1lr1pHRwkVzvpWtaXykBZWdsEvPzag7nCLL98YaZZaV3Gtm2nD3O 0ax5AabNc5mGiuh3lY9STPre6aLzkAYB555edbEsC43H31sk3TGszfBzb0o01VFw4JAM WTAEnFYnRxxCYWtAp3vvnZFPQBExioV2ge5EnXr6JpfrtCKlhHqPuVP9mKJ6rATQHn/5 WvekfnEImU15WprNEzvbKsRQI8OAHeGDm583squjq1oKvn4oAdTRRsPCRtF1ZFaKh3ql 2tsA== 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 o3si626656ejm.346.2020.07.22.13.33.38; Wed, 22 Jul 2020 13:34:01 -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 S1732922AbgGVUcq (ORCPT + 99 others); Wed, 22 Jul 2020 16:32:46 -0400 Received: from mga07.intel.com ([134.134.136.100]:34992 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726447AbgGVUcq (ORCPT ); Wed, 22 Jul 2020 16:32:46 -0400 IronPort-SDR: jiXj/a9LaqWJqy8qlku6zsM4Oz9CQT0ooOeMvVO378bT6ex/+nxpWuBWw8YPhzOFK2JuilMbT8 Qvs6FXGtEHhg== X-IronPort-AV: E=McAfee;i="6000,8403,9690"; a="215045946" X-IronPort-AV: E=Sophos;i="5.75,383,1589266800"; d="scan'208";a="215045946" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jul 2020 13:32:45 -0700 IronPort-SDR: 8yKgNfCi3/8G/Oq7P71tWxhlFKpxRnZ+tszPoYSoQ4Ma1iaTLU6hAj3oaYiFdGPQ3cljuLY0Hm YtIvsy1SmKIA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,383,1589266800"; d="scan'208";a="326802777" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.152]) by FMSMGA003.fm.intel.com with ESMTP; 22 Jul 2020 13:32:45 -0700 Date: Wed, 22 Jul 2020 13:32:45 -0700 From: Sean Christopherson To: Yang Weijiang Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, pbonzini@redhat.com, jmattson@google.com, yu.c.zhang@linux.intel.com Subject: Re: [RESEND v13 06/11] KVM: x86: Load guest fpu state when access MSRs managed by XSAVES Message-ID: <20200722203244.GG9114@linux.intel.com> References: <20200716031627.11492-1-weijiang.yang@intel.com> <20200716031627.11492-7-weijiang.yang@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200716031627.11492-7-weijiang.yang@intel.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 16, 2020 at 11:16:22AM +0800, Yang Weijiang wrote: > From: Sean Christopherson > > A handful of CET MSRs are not context switched through "traditional" > methods, e.g. VMCS or manual switching, but rather are passed through > to the guest and are saved and restored by XSAVES/XRSTORS, i.e. in the > guest's FPU state. > > Load the guest's FPU state if userspace is accessing MSRs whose values > are managed by XSAVES so that the MSR helper, e.g. vmx_{get,set}_msr(), > can simply do {RD,WR}MSR to access the guest's value. > > Note that guest_cpuid_has() is not queried as host userspace is allowed > to access MSRs that have not been exposed to the guest, e.g. it might do > KVM_SET_MSRS prior to KVM_SET_CPUID2. No comments on the patch itself. Added a blurb to the changelog to call out the vcpu==NULL case is possible due to KVM_GET_MSRS also being a device scope ioctl(). > Signed-off-by: Sean Christopherson > Co-developed-by: Yang Weijiang > Signed-off-by: Yang Weijiang