Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp7562120ybl; Tue, 24 Dec 2019 04:55:41 -0800 (PST) X-Google-Smtp-Source: APXvYqxjoqL/sD3cJqkZG/fUDt/GcTBDx3xY8DV//ozw/5bzb3fbm4Cs4EryR4VIc9/3e3Nnlozf X-Received: by 2002:a9d:12f1:: with SMTP id g104mr39806233otg.334.1577192141607; Tue, 24 Dec 2019 04:55:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577192141; cv=none; d=google.com; s=arc-20160816; b=sAmEQ0A+oysl+DxJhYp+3uZdcjiBnqzQkPmAmVWT1p80Eb6PpDFW9yBCASxxTpCl2l ihYuPlYJ4VesYiZUwf5vt5QFJpGG+Bmq6wg9Dzi5WZnh2/BFGTQsbvpiZpG1ZUIFTCFm NnCfA6eJ8nsdpbE27YI9/mPIpQVakqldABADQvdHoCOtFNSekYUcVhfwfzmWCHjaiu2f ENa8/SBVoau/7YPRbbxFTp7sVXSNjy0J8HHpLBZwtv7GpXiGqnhTbaYfmbg1eM89TdWM z6i+xxy1zavzO9HfiyBf31a2N0Ka9HmGsD0xPxQdz0obPf3yTIwuQKW/0ctEyKdzBdgW +p4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=NlUKdXohSmDzxbJ27TYETkzSOC1HtAC8lS5IuraMIAI=; b=P2b5f+WckectJYbwllLdqBSLDlwr9JnhygQUT3aj3g8uqpcBmKDUr+hk3jdU+BfUaM YCjq6pOE08/KI2LZ4hmRnMydYYuvz6Y072xh9BOs6Z5F0XOETUiew1t3FC+g6NGoDvdh UO3ZO80gd+VBzhFk+yq2N0EXIdy0ICk0NhDZ/KTSIdLYMaEmrnfQyRumTLhnZUBp1MpT oScHRiBhJnhWs0y4dc+OqWgq5JZl9febBvCrHh6bc2++fuiY/PBIuYWF4V/aJLkOCvNI G3klMVGB8UFZ1ShzcXaLToftxLCONw2+pm7uAbm+CpF369tWQBLrm1YgCmJBhT48MbWo 2WjA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 45si9344200oty.188.2019.12.24.04.55.30; Tue, 24 Dec 2019 04:55:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726262AbfLXMyx (ORCPT + 99 others); Tue, 24 Dec 2019 07:54:53 -0500 Received: from foss.arm.com ([217.140.110.172]:51908 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726157AbfLXMyw (ORCPT ); Tue, 24 Dec 2019 07:54:52 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 171021FB; Tue, 24 Dec 2019 04:54:52 -0800 (PST) Received: from localhost (unknown [10.37.6.20]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7F5C43F534; Tue, 24 Dec 2019 04:54:51 -0800 (PST) Date: Tue, 24 Dec 2019 12:54:49 +0000 From: Andrew Murray To: Mark Rutland Cc: Marc Zyngier , Catalin Marinas , Will Deacon , Sudeep Holla , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 00/18] arm64: KVM: add SPE profiling support Message-ID: <20191224125449.GL42593@e119886-lin.cambridge.arm.com> References: <20191220143025.33853-1-andrew.murray@arm.com> <20191220175524.GC25258@lakrids.cambridge.arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191220175524.GC25258@lakrids.cambridge.arm.com> User-Agent: Mutt/1.10.1+81 (426a6c1) (2018-08-26) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Dec 20, 2019 at 05:55:25PM +0000, Mark Rutland wrote: > Hi Andrew, > > On Fri, Dec 20, 2019 at 02:30:07PM +0000, Andrew Murray wrote: > > This series implements support for allowing KVM guests to use the Arm > > Statistical Profiling Extension (SPE). > > > > It has been tested on a model to ensure that both host and guest can > > simultaneously use SPE with valid data. E.g. > > > > $ perf record -e arm_spe/ts_enable=1,pa_enable=1,pct_enable=1/ \ > > dd if=/dev/zero of=/dev/null count=1000 > > $ perf report --dump-raw-trace > spe_buf.txt > > What happens if I run perf record on the VMM, or on the CPU(s) that the > VMM is running on? i.e. > > $ perf record -e arm_spe/ts_enable=1,pa_enable=1,pct_enable=1/ \ > lkvm ${OPTIONS_FOR_GUEST_USING_SPE} > By default perf excludes the guest, so this works as expected, just recording activity of the process when it is outside the guest. (perf report appears to give valid output). Patch 15 currently prevents using perf to record inside the guest. > ... or: > > $ perf record -a -c 0 -e arm_spe/ts_enable=1,pa_enable=1,pct_enable=1/ \ > sleep 1000 & > $ taskset -c 0 lkvm ${OPTIONS_FOR_GUEST_USING_SPE} & > > > As we save and restore the SPE context, the guest can access the SPE > > registers directly, thus in this version of the series we remove the > > trapping and emulation. > > > > In the previous series of this support, when KVM SPE isn't supported > > (e.g. via CONFIG_KVM_ARM_SPE) we were able to return a value of 0 to > > all reads of the SPE registers - as we can no longer do this there isn't > > a mechanism to prevent the guest from using SPE - thus I'm keen for > > feedback on the best way of resolving this. > > When not providing SPE to the guest, surely we should be trapping the > registers and injecting an UNDEF? Yes we should, I'll update the series. > > What happens today, without these patches? > Prior to this series MDCR_EL2_TPMS is set and E2PB is unset resulting in all SPE registers being trapped (with NULL handlers). > > It appears necessary to pin the entire guest memory in order to provide > > guest SPE access - otherwise it is possible for the guest to receive > > Stage-2 faults. > > AFAICT these patches do not implement this. I assume that's what you're > trying to point out here, but I just want to make sure that's explicit. That's right. > > Maybe this is a reason to trap+emulate if there's something more > sensible that hyp can do if it sees a Stage-2 fault. Yes it's not really clear to me at the moment what to do about this. Thanks, Andrew Murray > > Thanks, > Mark.