Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp2027519pxb; Mon, 23 Aug 2021 10:15:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxPujy1aObXYArF9CqDb6vIm4xLc8IsP3vR/Mahe5XAZ678aCNihnGIPuFesTM6NCTNANxj X-Received: by 2002:a05:6402:1c1d:: with SMTP id ck29mr38366337edb.39.1629738936350; Mon, 23 Aug 2021 10:15:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629738936; cv=none; d=google.com; s=arc-20160816; b=dx52fYAzZOt38L01cPaqqxua9qWHogWVt3WZ8kFuqnbKyaPPIF5WgzZlqRwpDZDT8e OdXwOK0L3PmsFv4nqAAch6Nl0lMWmwMyUILz/HOuqgvlUiNo3QtHb5LblX3rye8vOH5M AmyIYfwMQPXenr2wHDFrslWA14poO3+cAIJJW6uCG1YTrHZxnXDT5k20A14CttDR4Pi/ mFPtp58uk9hzrc3CGXQa7Uzidl4gRWtv12xmdnETqHxADEgiN8JB1UwYbEyQi3yMP6Wa O4l1fVLQU1BsMwRe/+t5he1c27QV6xsNp4iVv5Cdl+3P9pFrpvHhEoc0BAwz7Soe9t7B chGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from; bh=Q6lg7TmTs2VXTdL2+roPadHAGrKG4lulaNXdyVt7y+I=; b=Xud9fwNfgvfov16z1u6LPHt3z/9kbiwZ5UEVki3++E10dWluiGp11akYxl1pUQPFGK pkKEhPTVJMpJsPHNjVoFjsTbKxYZQHZv98RSAh+vpQ7XRxl/0dN64hKGIPwFHrFMtc+6 tahbP0ZCggkIfXwo5a8BIZQ5kyhmMJqq74IMkCOG4aC8oz0rYmbd6tTDpaZ7eVRjmU0y uywlRwdCNNn8/wUyZlAY7/RPFGgSDN9JtBOe40S+bR+f7/hAWTpFBXNGU9DoqU1YNtwT n0mqBASJs2smVKHVaDX4N6pf4PMOv7fZcRZJTWefyxu6k2OmS0AtPtaLI2mQtFGcp/5D cjbw== 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 ox26si7996940ejb.200.2021.08.23.10.15.12; Mon, 23 Aug 2021 10:15:36 -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 S230314AbhHWRMh (ORCPT + 99 others); Mon, 23 Aug 2021 13:12:37 -0400 Received: from mga02.intel.com ([134.134.136.20]:64991 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229479AbhHWRMe (ORCPT ); Mon, 23 Aug 2021 13:12:34 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10085"; a="204342899" X-IronPort-AV: E=Sophos;i="5.84,344,1620716400"; d="scan'208";a="204342899" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Aug 2021 10:11:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,344,1620716400"; d="scan'208";a="507325544" Received: from um.fi.intel.com (HELO um) ([10.237.72.62]) by orsmga001.jf.intel.com with ESMTP; 23 Aug 2021 10:11:48 -0700 From: Alexander Shishkin To: Sean Christopherson Cc: Paolo Bonzini , Peter Zijlstra , Arnaldo Carvalho de Melo , Ingo Molnar , linux-kernel@vger.kernel.org, Jiri Olsa , kvm@vger.kernel.org, Artem Kashkanov , alexander.shishkin@linux.intel.com Subject: Re: [PATCH] kvm/x86: Fix PT "host mode" In-Reply-To: References: <20210823134239.45402-1-alexander.shishkin@linux.intel.com> Date: Mon, 23 Aug 2021 20:11:47 +0300 Message-ID: <87zgt8hyr0.fsf@ashishki-desk.ger.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Sean Christopherson writes: > On Mon, Aug 23, 2021, Alexander Shishkin wrote: > >> Signed-off-by: Alexander Shishkin >> Fixes: ff9d07a0e7ce7 ("KVM: Implement perf callbacks for guest sampling") > > This should be another clue that the fix isn't correct. > That patch is from 2010, Right, this should have been 8479e04e7d6b1 ("KVM: x86: Inject PMI for KVM guest") instead. > Intel PT was announced in 2013 and merged in 2019. Technically, 2019 is when kvm started breaking host PT. > This is not remotely correct. vmx.c's "pt_mode", which is queried via this path, > is modified by hardware_setup(), a.k.a. kvm_x86_ops.hardware_setup(), which runs > _after_ this code. And as alluded to above, these are generic perf callbacks, > installing them if and only if Intel PT is enabled in a specific mode completely > breaks "regular" perf. I see your point, the callchain code will catch fire. > I'll post a small series, there's a bit of code massage needed to fix this > properly. The PMI handler can also be optimized to avoid a retpoline when PT is > not exposed to the guest. The actual PMU handler also needs to know that kvm won't be needing it so it can call the regular PT handler. One could unset cbs->handle_intel_pt_intr() or one could have it return different things depending on whether it was actually taken in kvm. But both are rather disgusting. Regards, -- Alex