Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4160477pxj; Tue, 11 May 2021 22:20:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz6M4bvMR80Zf/2I5jvuNL50TJJA0LkmygewbcTrxYIErknc4AXEv1P3BRZyuia8qQEzTwa X-Received: by 2002:a92:c085:: with SMTP id h5mr25851184ile.37.1620796828010; Tue, 11 May 2021 22:20:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620796828; cv=none; d=google.com; s=arc-20160816; b=LNZsKq4grEO1DNbaBA9g+5zEBJK+lV5vtm27ap6JDTvgbhVBASxfSyZlPILNMEJkTF TPeClaFxzfB5mAuRLrG3qVcMFiiEIU+mNp3ecrSjx/Z8DL9bOzdplAnIayjX4ukEsAtB txsfq9VibIs/I2eu2PmHDGb0g37XmxLiAsu0IbIsH49J1UdoMpwlLIctBUzrumrP/+DF rs5MIbuVtJ1fQqH5fMGJzqdXyIHK5qpdDDpp6MXu5LH/E6dKkZyrUQyjckdHV3LkvCtu QxKsxNtxp35NnnoQb5UsnQHbpXIml3KJzShrMdyrFZ/TH4WjYe4YKdtWlLAxacpVyHQN CL2g== 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=LkTowV/S8lsl4Vkit6HcfhYRksvKaUWk6C/zsMTbJGA=; b=F/xpbxYV703mPt9IKfMMfHUf3bVsDm6+EuWP/SE7hVsfgETqWtOjyAxa2E7LbF+au1 XGNCBCf+JyatnPta7TZqRbAFKPvKnE9CgGlDzrs6H9emvDH22w5SZNHy3C8GQ2opHmiD wgAlPAl2u2fOcZH6j1ihxZ0KGR3jDRdhYZRupa/se8ZGoY3vT1VJ6v7h6X9QwdFl7Ylm r+ZHUi0HU8YUwhNJJ7Fgsdch/SKJdwKD8+PDbATUQKLfpd+y8XCeSDAerhi/D0yYlHhh IkVIcHh8ULWWcvxzvyo5B3TOqGk5EsWKMXK2JmlMZra0lVQpvow1TExYLgfiEkU9u4dE 2njQ== 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 e10si20804669jam.126.2021.05.11.22.20.03; Tue, 11 May 2021 22:20:28 -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 S229994AbhELFRZ (ORCPT + 99 others); Wed, 12 May 2021 01:17:25 -0400 Received: from mga03.intel.com ([134.134.136.65]:45309 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229580AbhELFRY (ORCPT ); Wed, 12 May 2021 01:17:24 -0400 IronPort-SDR: y+coDPJ48ShC7ojQHe5xmi8/uAIEdfYqp8uIri11BRKgqSa6RXaGl7WyvKu/lu5jQv5wqy0gCI EDhoKRHaVcnA== X-IronPort-AV: E=McAfee;i="6200,9189,9981"; a="199669477" X-IronPort-AV: E=Sophos;i="5.82,293,1613462400"; d="scan'208";a="199669477" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2021 22:16:16 -0700 IronPort-SDR: YleV+Nw6O3LvC1QvlvOsQSPuPEls/NC9HzTbJV3KjN6qs/pclckvippAAwo/tbT3/Ooc90UBZh gFIQJ0Pn+1+w== X-IronPort-AV: E=Sophos;i="5.82,293,1613462400"; d="scan'208";a="437019326" 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; 11 May 2021 22:16:11 -0700 Subject: Re: [PATCH v6 08/16] KVM: x86/pmu: Add IA32_DS_AREA MSR emulation to support guest DS To: Peter Zijlstra , Paolo Bonzini Cc: Borislav Petkov , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , weijiang.yang@intel.com, Kan Liang , ak@linux.intel.com, wei.w.wang@intel.com, eranian@google.com, liuxiangdong5@huawei.com, linux-kernel@vger.kernel.org, x86@kernel.org, kvm@vger.kernel.org, Like Xu References: <20210511024214.280733-1-like.xu@linux.intel.com> <20210511024214.280733-9-like.xu@linux.intel.com> From: "Xu, Like" Message-ID: <329b4cc8-d42c-d2f0-7f25-e28c5049397a@intel.com> Date: Wed, 12 May 2021 13:16:09 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <20210511024214.280733-9-like.xu@linux.intel.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/5/11 10:42, Like Xu wrote: > @@ -3908,7 +3911,7 @@ static struct perf_guest_switch_msr *intel_guest_get_msrs(int *nr, void *data) > .guest = intel_ctrl & (~cpuc->intel_ctrl_host_mask | ~pebs_mask), > }; > > - if (!x86_pmu.pebs) > + if (!pmu || !x86_pmu.pebs_vmx) > return arr; > > /* > @@ -3931,6 +3934,12 @@ static struct perf_guest_switch_msr *intel_guest_get_msrs(int *nr, void *data) > if (!x86_pmu.pebs_vmx) > return arr; > > + arr[(*nr)++] = (struct perf_guest_switch_msr){ > + .msr = MSR_IA32_DS_AREA, > + .host = (unsigned long)ds, > + .guest = pmu->ds_area, > + }; > + > arr[*nr] = (struct perf_guest_switch_msr){ > .msr = MSR_IA32_PEBS_ENABLE, > .host = cpuc->pebs_enabled & ~cpuc->intel_ctrl_guest_mask, Sorry, this part should be: @@ -3928,9 +3931,15 @@ static struct perf_guest_switch_msr *intel_guest_get_msrs(int *nr, void *data)                 return arr;         } -       if (!x86_pmu.pebs_vmx) +       if (!pmu || !x86_pmu.pebs_vmx)                 return arr; +       arr[(*nr)++] = (struct perf_guest_switch_msr){ +               .msr = MSR_IA32_DS_AREA, +               .host = (unsigned long)ds, +               .guest = pmu->ds_area, +       }; +         arr[*nr] = (struct perf_guest_switch_msr){                 .msr = MSR_IA32_PEBS_ENABLE,                 .host = cpuc->pebs_enabled & ~cpuc->intel_ctrl_guest_mask,