Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3904692pxb; Tue, 17 Nov 2020 06:37:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJyv9y3CSV0i3qrqRiHl8ZJ29kiqJWM4n/2iHO054fIBJfHved/cdqF0zSIVPcx4ZjMjLlQF X-Received: by 2002:a17:906:b7cc:: with SMTP id fy12mr20359406ejb.458.1605623868446; Tue, 17 Nov 2020 06:37:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605623868; cv=none; d=google.com; s=arc-20160816; b=Bi4V3QShPi4YNCc6MG36G3ue+CXOxYaM+n0C0kizR3o6TUZD4jgnYf8q38txn1UXNt ZVtT8RlBoOFuzEMQ/6baA2J/zCbkE6bnrdVJ9Ca9dYdsfek61D/WupBwSbtmOseK/1ot Bd9dZR0DpL9/i3EOjaM9xnwZAQn48zH0NjA9KJcl4IF4HukhNcW2NHspe4O2bqkBLuWu h3VrLx9e3iGD4WRAPi1LrKDTCKzLV8vtNo6CwAVZh5D8J+GkmErNCRlMynUF6BOAn8o+ rQKGA+S1WlGauzGrLG7ymxGd712fJgNeamUlalSQl51s9YrrChD2BIDzIogHPG/0+unY 74FQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=sollcZRLnQJ8RrafQij/FmHLw4zZVs0otZjXpirh3Ew=; b=Md7llcqmbSpo9Iwa6y1Td9DNoLyry7pLUncAeM2gzKHZUF5y0M7S2sUqEJoMMvBT41 epJO1zohCy31Xkc0/YvDX9cTt6CAdXBCXEacEXjnYlPhUdFyj9Owp1xA34jMIp4jXHmD /q3TmzqFr2xnBGBjnPAuJYCIEMYtY0OdqBcui9yi9Hgl6HC+2p84Z4jrDCwi7gSaub67 LMLPv9Tmbwyettc3zSz7dRF1PAMhf3zfZoZor8miLPlI9kxjL+3QIwQ02vA/E0ZknC7n kl1s+7LSaA+dcx8mEYnMlt+66hcHnGZTO2+c4ezd/zinio/wBMoGWrZqb9DlLK8MKQb5 5I3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=XvjFyytA; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id da28si13794013edb.112.2020.11.17.06.37.25; Tue, 17 Nov 2020 06:37:48 -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=@infradead.org header.s=casper.20170209 header.b=XvjFyytA; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728821AbgKQOf7 (ORCPT + 99 others); Tue, 17 Nov 2020 09:35:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727473AbgKQOf6 (ORCPT ); Tue, 17 Nov 2020 09:35:58 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02A55C0613CF; Tue, 17 Nov 2020 06:35:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=sollcZRLnQJ8RrafQij/FmHLw4zZVs0otZjXpirh3Ew=; b=XvjFyytAeKKVlJlLTby1rvMj7n 25wQJIA3xixyu+91CeN1Z5/ShGkAJtd+CJzTFPJiolWrKNipizl3VMKhr7oHyo1FTmQ5fYTgvKVAM KQOEdSuEBBSAbVT+NjTrHu3TnPGXaudIlwsQ0grrNmoUOaLtXyvwkBELbyK63d33XwpRxTA4cr2h9 AdSm5yP9EKmNb3J4WJcnmBhqfZHVgs/44LkqwZzUCQgw1KSdpDXAncle6Zlt4qkpuQP0aG8JFk+by nNuhv/0s15zlKPnxD/q1dYliRnGDDqdYch0pGzRCxnxHD61EAWnVzNL5Q31aqQFqtYbfYoEja8hUY LD+RaDGA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kf24x-00023e-1Z; Tue, 17 Nov 2020 14:35:31 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id D3558307A49; Tue, 17 Nov 2020 15:35:29 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id BDEE220113347; Tue, 17 Nov 2020 15:35:29 +0100 (CET) Date: Tue, 17 Nov 2020 15:35:29 +0100 From: Peter Zijlstra To: Like Xu Cc: Paolo Bonzini , kvm@vger.kernel.org, Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Kan Liang , luwei.kang@intel.com, Thomas Gleixner , wei.w.wang@intel.com, Tony Luck , Stephane Eranian , Mark Gross , Srinivas Pandruvada , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 04/17] perf: x86/ds: Handle guest PEBS overflow PMI and inject it to guest Message-ID: <20201117143529.GJ3121406@hirez.programming.kicks-ass.net> References: <20201109021254.79755-1-like.xu@linux.intel.com> <20201109021254.79755-5-like.xu@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201109021254.79755-5-like.xu@linux.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 09, 2020 at 10:12:41AM +0800, Like Xu wrote: > With PEBS virtualization, the PEBS records get delivered to the guest, > and host still sees the PEBS overflow PMI from guest PEBS counters. > This would normally result in a spurious host PMI and we needs to inject > that PEBS overflow PMI into the guest, so that the guest PMI handler > can handle the PEBS records. > > Check for this case in the host perf PEBS handler. If a PEBS overflow > PMI occurs and it's not generated from host side (via check host DS), > a fake event will be triggered. The fake event causes the KVM PMI callback > to be called, thereby injecting the PEBS overflow PMI into the guest. > > No matter how many guest PEBS counters are overflowed, only triggering > one fake event is enough. The guest PEBS handler would retrieve the > correct information from its own PEBS records buffer. > > If the counter_freezing is disabled on the host, a guest PEBS overflow > PMI would be missed when a PEBS counter is enabled on the host side > and coincidentally a host PEBS overflow PMI based on host DS_AREA is > also triggered right after vm-exit due to the guest PEBS overflow PMI > based on guest DS_AREA. In that case, KVM will disable guest PEBS before > vm-entry once there's a host PEBS counter enabled on the same CPU. How does this guest DS crud work? DS_AREA is a host virtual address; ISTR there was lots of fail trying to virtualize it earlier. What's changed? There's 0 clues here. Why are the host and guest DS area separate, why can't we map them to the exact same physical pages?