Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3889804pxb; Mon, 8 Feb 2021 02:44:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJyP70sNwNvTN5KTnsFZPsGAHjQ0xiL/nXVIQrjL3POif3Kp3Y/YIAxzg8WIDtgL69gmU7xB X-Received: by 2002:a17:906:3499:: with SMTP id g25mr9360434ejb.367.1612781087101; Mon, 08 Feb 2021 02:44:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612781087; cv=none; d=google.com; s=arc-20160816; b=tKBFVU7hnvI3HzO7hOqmzUdgX23vssv1TOvGU0+K4T1kkfRq1meJRWAE5as9AyXa1Z jPH5Rn0Y36o1DR/6eLNSP0eHwbC82GpTtIIrZr2ajaiZ45t48xlUQXO/PcS4sfBIrEAN +X5cX77oFVd4NsXH1q9t702D5WpTcW7XjqUK/bkECgoVLux2bH7V32s3LsXys+8Qjgvz x+lod+soB/Jxt4unwDaEnMl9CUrdZrwz7kMZEy6oEaCWaYs0wqqezbZa4CSv8OeiFeRx K306pYKOn4ASvtkKFhKXHk7tI/1Eq7j9TegLadcBYHcqIlNOp1qJcPt56cf1NuDsu+sb UVXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=K05zC1EUlyTezUmZ1LkF+HhqGZkbRd0Cfn1SraZHoC4=; b=tlC7wFwQakeo/JGBjMlToNxTP8GRwBA1pWYBB0fb/BlhVCHPW5YWTYn5vgsvP8CQgf wQ4faBKOn+hSWCOgMiNpRmfS1qdyUv03CfmpnGGRN3qhSxR35Kqbkq0C19eZ9dsZQWAU KoMzcUAC4ygT/yXabXcZhcSMPCZi6Q7pxEwv8MpuiOUojNS1JZgmJKMOyQMwUMRyCjht m7O+x2cAPvaZ57Xtx7EDBTUO8AHFyYERKgApI9HrzXWiUxBNS5loHlYlE8AyBNNML5SG mM3T/5NflFQ22kH68WQDufhUQY0N1CEwVNgLuCMN7TWgnTQOd5L8cNVQvgCaPuGUVapF 0Yag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Oh3CSr4n; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k21si8541596ejx.367.2021.02.08.02.44.22; Mon, 08 Feb 2021 02:44:47 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Oh3CSr4n; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232607AbhBHKmT (ORCPT + 99 others); Mon, 8 Feb 2021 05:42:19 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:26698 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232456AbhBHKdI (ORCPT ); Mon, 8 Feb 2021 05:33:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612780302; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=K05zC1EUlyTezUmZ1LkF+HhqGZkbRd0Cfn1SraZHoC4=; b=Oh3CSr4n3qZQStBSeLcQI9X4PkgXcmVMYRWE0XVBU75pesOkVlxLYWl5sYQrWbclW9JkI3 SzZqPF2JpIANH1stSHyI2h3u/oyVcyuInosbwbt3mlbAx7xwV2b2JdzN15PkwSnDqkr59o I1oXPGXVpo/CBMM6G2rXvydHaUrbsxw= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-285-Gt5ZKkYEOY6VZXZmuDY3eQ-1; Mon, 08 Feb 2021 05:31:40 -0500 X-MC-Unique: Gt5ZKkYEOY6VZXZmuDY3eQ-1 Received: by mail-wr1-f72.google.com with SMTP id u3so12639900wri.19 for ; Mon, 08 Feb 2021 02:31:40 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=K05zC1EUlyTezUmZ1LkF+HhqGZkbRd0Cfn1SraZHoC4=; b=ieeQNfzjOy1HMgzijvaPhRZe0H4vtqD/KraWtde3hvq5F92YcpBs/M+HAhK1/numzP cnOE8qFA3Z9crwqD0oJTUqE6KbOQudJsJhnnlzHS++Q8gZ3p3G6b7D41h6pWPomfHij3 2vcCIXeOrlxEWMKN4Lf5mDgVvHZ1XZ3SdvipxYULHJyEYT41X99ErnqmL7nyKeU7rWRp qBzXrw/OZGUkyTA3Tmcm2IwatnQquClaPa9v6WkZK0GWoHC0RjpEhg6iKboUa2NgChLJ ulcK8+w/pHXDEk6wP/DIyCUA4Jl5bnG7VfxC/61Flta9PCAcL7NxTH5fRyJxN9RXmEZ5 EgHg== X-Gm-Message-State: AOAM532BHP2CneWDjsT6s731jxuFQd09Zvl7zd1ilzSdiWo31wjZNw1H THQZzSyaap7B1QKmveVTsYJf/2g5LdiD/rChAx826pkVEyfTrChg8A/j+ttnhi/rJehtISFbztV SS19VLGIlL4jGiOsxIcHJSkgW X-Received: by 2002:a5d:4f84:: with SMTP id d4mr18901196wru.374.1612780299173; Mon, 08 Feb 2021 02:31:39 -0800 (PST) X-Received: by 2002:a5d:4f84:: with SMTP id d4mr18901170wru.374.1612780298938; Mon, 08 Feb 2021 02:31:38 -0800 (PST) Received: from ?IPv6:2001:b07:6468:f312:5e2c:eb9a:a8b6:fd3e? ([2001:b07:6468:f312:5e2c:eb9a:a8b6:fd3e]) by smtp.gmail.com with ESMTPSA id d3sm31485720wrp.79.2021.02.08.02.31.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 08 Feb 2021 02:31:38 -0800 (PST) Subject: Re: [PATCH v2 4/4] KVM: x86: Expose Architectural LBR CPUID and its XSAVES bit To: "Xu, Like" , 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> <6f733543-200e-9ddd-240b-1f956a003ed6@intel.com> From: Paolo Bonzini Message-ID: Date: Mon, 8 Feb 2021 11:31:36 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <6f733543-200e-9ddd-240b-1f956a003ed6@intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07/02/21 02:02, Xu, Like wrote: > 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. Ok, this makes sense. I'll review the patches more carefully, looking at 5.13 for the target. Paolo > 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 >