Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3025530pxb; Sat, 6 Feb 2021 17:04:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJwARtHGZU7XUvWZPKfS0s5kQ3mo2OU1vsU2qAtw2OTbCP9ZgxmkjNIQeOUd5VinCX6q2sS9 X-Received: by 2002:a05:6402:3552:: with SMTP id f18mr10354206edd.111.1612659852937; Sat, 06 Feb 2021 17:04:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612659852; cv=none; d=google.com; s=arc-20160816; b=AigpUHooPiMVdsf8YcE1ii1pEpRtm8vssBJzwTlzAA97BviwrlmsCmBW4jsl7PbA1H sD4MIu4y08pm6mdi4bsfrJ9aetefslN4doXgEpC0j4vIJ9+j2RNY2DvHw0wKWiKlnuMC R7FygMmoG5kD7Id7USxODUnzvxJwpSPYqzqseRAh8MHOpdA08hAGdwj/ruR9W/vfhhTt 00l5zj03N4E+JwA1uGlv7Ri/tpK2Jv/ASR3pUkWQHZQmVAr2RSeAdu1vDDoIb224pHdE 8XWItkmxJCPJez3iYNre00gEQnQPQUhJolFgCvnBl8q/XVoBvlrJtY+nqsLQgQqY9K2Y GzRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:ironport-sdr:ironport-sdr; bh=ALuAmOvZUJR17XWvtRCK2vz1nPJ3RjIbPSWP7RKqGf0=; b=S+O3QChV0FLS0uvyMVlcrzpmuX70e4JwDeANkc4HEsMNzW/uiJz2Q7GCRESBZw/hjC 8rg+UlEdoq7V/yXlZcUn4naYocoVSfmx3nFOWqT4jly7qfdVITEfjGMiKya7NG87Pkv4 sxRGjyraWiHEgnTg+WVoz7JB9SGjSEill+UnCtL5CkcjuSyz2UIw0uFOrSuZPyU4fbsX 6yEcY1rZsSJbggS8mSm7Ligk+L13JuGkJEUq/2qFesHhiDMp1SDrelgmLwcx8vQPiHXF kYnxq7f5f8TUif/EDk3xRZD2uHa/16weGRKhfWnzokbHjlOAOb4lYc1ZQMMCLLozyCDD jqbg== 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 x2si8158825ejw.116.2021.02.06.17.03.48; Sat, 06 Feb 2021 17:04:12 -0800 (PST) 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 S229566AbhBGBDW (ORCPT + 99 others); Sat, 6 Feb 2021 20:03:22 -0500 Received: from mga06.intel.com ([134.134.136.31]:16531 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229506AbhBGBDV (ORCPT ); Sat, 6 Feb 2021 20:03:21 -0500 IronPort-SDR: j4rmBHOzFA5MuRxNDHJi9Vd5iQ4xv1XYnku4fmLTG8ypyR+klsWlAu0HNa5qY14LDFbiZa5M+1 /iYZtFbO0hSg== X-IronPort-AV: E=McAfee;i="6000,8403,9887"; a="243074397" X-IronPort-AV: E=Sophos;i="5.81,158,1610438400"; d="scan'208";a="243074397" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Feb 2021 17:02:40 -0800 IronPort-SDR: 0QNn1KcbZCAkEbemNVtv8L8towttrsVH2qFeevGaJGC96FXisoZnuZdkN3zWNilx30x4jN4Fin QhHDnA84Pmog== X-IronPort-AV: E=Sophos;i="5.81,158,1610438400"; d="scan'208";a="394527495" Received: from likexu-mobl1.ccr.corp.intel.com (HELO [10.238.4.93]) ([10.238.4.93]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Feb 2021 17:02:38 -0800 Subject: Re: [PATCH v2 4/4] KVM: x86: Expose Architectural LBR CPUID and its XSAVES bit To: Paolo Bonzini , Sean Christopherson Cc: Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Like Xu References: <20210203135714.318356-1-like.xu@linux.intel.com> <20210203135714.318356-5-like.xu@linux.intel.com> <8321d54b-173b-722b-ddce-df2f9bd7abc4@redhat.com> <219d869b-0eeb-9e52-ea99-3444c6ab16a3@intel.com> <7698fd6c-94da-e352-193f-e09e002a8961@redhat.com> From: "Xu, Like" Message-ID: <6f733543-200e-9ddd-240b-1f956a003ed6@intel.com> Date: Sun, 7 Feb 2021 09:02:35 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 MIME-Version: 1.0 In-Reply-To: <7698fd6c-94da-e352-193f-e09e002a8961@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/2/5 19:00, Paolo Bonzini wrote: > On 05/02/21 09:16, Xu, Like wrote: >> Hi Paolo, >> >> I am wondering if it is acceptable for you to >> review the minor Architecture LBR patch set without XSAVES for v5.12 ? >> >> As far as I know, the guest Arch LBR  can still work without XSAVES >> support. > > I dopn't think it can work.  You could have two guests on the same > physical CPU and the MSRs would be corrupted if the guests write to the > MSR but they do not enable the LBRs. > > Paolo > Neither Arch LBR nor the old version of LBR have this corruption issue, and we will not use XSAVES for at least LBR MSRs in the VMX transaction. This is because we have reused the LBR save/restore swicth support from the host perf mechanism in the legacy LBR support, which will save/restore the LBR MSRs of the vcpu (thread) when the vcpu is sched in/out. Therefore, if we have two guests on the same physical CPU, the usage of LBR MSRs is isolated, and it's also true when we use LBR to trace the hypervisor on the host. The same thing happens on the platforms which supports Arch LBR. I propose that we don't support using XSAVES to save/restore Arch LRB *in the guest* (just like the guest Intel PT), but use the traditional RD/WRMSR, which still works like the legacy LBR. Since we already have legacy LBR support, we can add a small amount of effort (just two more MSRs emulation and related CPUID exposure) to support Arch LBR w/o XSAVES. I estimate that there are many issues we need to address when we supporting guests to use xsaves instructions. As a rational choice, we could enable the basic Arch LBR. Paolo and Sean, what do you think ? --- thx, likexu