Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2064658pxa; Fri, 7 Aug 2020 02:05:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzT7DIZLquxs7V0RGFaIG+iu3rtenqNOVu+Z75JXjf9vKgsYWSf1udZW955PMpjJmGkLYfG X-Received: by 2002:a05:6402:1b1c:: with SMTP id by28mr8092630edb.89.1596791141667; Fri, 07 Aug 2020 02:05:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596791141; cv=none; d=google.com; s=arc-20160816; b=AGcFsEGT9vRZ5lYDtpNnDjfES7Y+dcu4jTS1LAQYsn/krZ/w7w3NtawuioXI2SA5Eh EIGFxdLjHv275tvLZzdaM1cvqnvpxVA1zs+y3wqKK8UDoBxSDj+u1/Eu4++w3WUjv5VU rA3sz5AKba6koX25IDF22zigrdX7ZLyy/c3bWD9fQHYUerDcbRCRMFrm+f3NMxasEOeI 3T12FHEi9/fXBA1UCblnIp65b0pCuTMXojSTBj9E9kBZulIGL8rDvhuah3eVdNnKzPJJ j9j2E8bhCUaFaIgz4OUN9xUDH01tOJiV7n5BUXsxlB6Bc19ryzSZmozLcDeVazBK478P a1vA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=nfuR7h4BdrYTNwZ8exemfWhn1G8l1pg1R8rsohtYXAc=; b=Yuh9sOzCEGVsa2uKIbGZ1RbYLkHWYgcY6T7WaFRO4FVhX+sWhz/LsGjfaxQasghGv0 CN8+DCN0kc921Dy4gUQ3vCSZFMtT4nA0eh1dxL2At/7x50ztMekHsjvgzHmLfAGH0Dpw TsgdZp8MU6+sLQ2iHN6RFtWPleyXZ6vJb6h4EKH0tmtUP2a/51WGqSPO3iGW8zyH84lX AH0pIlQla/qKmgR9g9cZf9xE7SKl7/bDnZN5vOUPWG9K9pSYoLNDZhKHdO8sU9WnPr5o OF/6HcQmfFOWS3uDYGyRDd9JFHALxzCsrXOzMmqjksVMzdYPWqEo/S4d0xKj6NGtuO9r rKfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=DUBsOSFt; 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 lk20si5174792ejb.703.2020.08.07.02.05.17; Fri, 07 Aug 2020 02:05:41 -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; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=DUBsOSFt; 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 S1727855AbgHGJCn (ORCPT + 99 others); Fri, 7 Aug 2020 05:02:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726660AbgHGJCm (ORCPT ); Fri, 7 Aug 2020 05:02:42 -0400 Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34B8AC061574 for ; Fri, 7 Aug 2020 02:02:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.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=nfuR7h4BdrYTNwZ8exemfWhn1G8l1pg1R8rsohtYXAc=; b=DUBsOSFtwBsOrNANpC8WMiM1oU 4jKuWxDwLylGposCFoqmk3EWtqMA+Vdr7HXGi6rrteBP9NWRyfm4sPZtltxku2JOXtn6aGPLufdNF /3iOo2cmQy7jzHHcYEKpLJyWdmNHtG5GeVx7CxfBklExVmS1Ux8sXc1DwE0Ac0WznVlpVIVQXqlgj sJ+kcVTJKIL1FOpMt2FukLMr3JUnVY0JPMA61YM8NUar6IGffF2PXCuQqGlW1WncmAgfkw2W0JqxK eLGVQ5Vr3wyinB3CZnDimrB7WtBtbvG8h4A3gx5lCPru7uS2bocRVfqu4nIpSVDyNVHMbTPJ4+OmD yonjmmGA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1k3yGn-000813-Qc; Fri, 07 Aug 2020 09:02:34 +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 440EA300446; Fri, 7 Aug 2020 11:02:32 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 1248B213C48A5; Fri, 7 Aug 2020 11:02:32 +0200 (CEST) Date: Fri, 7 Aug 2020 11:02:32 +0200 From: peterz@infradead.org To: "Jin, Yao" Cc: mingo@redhat.com, oleg@redhat.com, acme@kernel.org, jolsa@kernel.org, Linux-kernel@vger.kernel.org, ak@linux.intel.com, kan.liang@intel.com, yao.jin@intel.com, alexander.shishkin@linux.intel.com, mark.rutland@arm.com Subject: Re: [PATCH v1 2/2] perf/core: Fake regs for leaked kernel samples Message-ID: <20200807090232.GE2674@hirez.programming.kicks-ass.net> References: <20200731025617.16243-1-yao.jin@linux.intel.com> <20200731025617.16243-2-yao.jin@linux.intel.com> <20200804114900.GI2657@hirez.programming.kicks-ass.net> <4c958d61-11a7-9f3e-9e7d-d733270144a1@linux.intel.com> <20200805124454.GP2657@hirez.programming.kicks-ass.net> <797aa4de-c618-f340-ad7b-cef38c96b035@linux.intel.com> <20200806091827.GY2674@hirez.programming.kicks-ass.net> <20200806110046.GF35926@hirez.programming.kicks-ass.net> <1d03d443-b187-bc1f-2601-a54037a64eff@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1d03d443-b187-bc1f-2601-a54037a64eff@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 07, 2020 at 02:24:30PM +0800, Jin, Yao wrote: > Hi Peter, > > On 8/6/2020 7:00 PM, peterz@infradead.org wrote: > > On Thu, Aug 06, 2020 at 11:18:27AM +0200, peterz@infradead.org wrote: > > > > > Suppose we have nested virt: > > > > > > L0-hv > > > | > > > G0/L1-hv > > > | > > > G1 > > > > > > And we're running in G0, then: > > > > > > - 'exclude_hv' would exclude L0 events > > > - 'exclude_host' would ... exclude L1-hv events? > > > - 'exclude_guest' would ... exclude G1 events? > > > > So in arch/x86/events/intel/core.c we have: > > > > static inline void intel_set_masks(struct perf_event *event, int idx) > > { > > struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events); > > > > if (event->attr.exclude_host) > > __set_bit(idx, (unsigned long *)&cpuc->intel_ctrl_guest_mask); > > if (event->attr.exclude_guest) > > __set_bit(idx, (unsigned long *)&cpuc->intel_ctrl_host_mask); > > if (event_is_checkpointed(event)) > > __set_bit(idx, (unsigned long *)&cpuc->intel_cp_status); > > } > > > > exclude_host is now set by guest (pmc_reprogram_counter, > arch/x86/kvm/pmu.c). When enabling the event, we can check exclude_host to > know if it's a guest. > > Otherwise we may need more flags in event->attr to indicate the status. > > > which is, afaict, just plain wrong. Should that not be something like: > > > > if (!event->attr.exclude_host) > > __set_bit(idx, (unsigned long *)&cpuc->intel_ctrl_host_mask); > > if (!event->attr.exclude_guest) > > __set_bit(idx, (unsigned long *)&cpuc->intel_ctrl_guest_mask); > > > > > > How can we know it's guest or host even if exclude_host is set in guest? I'm not following you, consider: xh xg h g h' g' 0 0 0 0 1 1 0 1 1 0 1 0 1 0 0 1 0 1 1 1 1 1 0 0 So the 0,0 and 1,1 cases get flipped. I have a suspicion, but this _really_ should have fat comments all over :-( What a sodding trainwreck..