From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753872AbcEaNFV (ORCPT ); Tue, 31 May 2016 09:05:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54285 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753014AbcEaNFP (ORCPT ); Tue, 31 May 2016 09:05:15 -0400 Date: Tue, 31 May 2016 15:05:10 +0200 From: Radim =?utf-8?B?S3LEjW3DocWZ?= To: Paolo Bonzini Cc: kmeaw@yandex-team.ru, "Gabriel L. Somlo" , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, gleb@kernel.org Subject: Re: [PATCH] KVM: Handle MSR_IA32_PERF_CTL Message-ID: <20160531130510.GA30721@potion> References: <770161464247923@webcorp02g.yandex-team.ru> <20160526203931.GB25334@potion> <20160526204439.GF2186@HEDWIG.INI.CMU.EDU> <920591464331762@webcorp02f.yandex-team.ru> <20160527152224.GA11721@potion> <20160527153850.GC11721@potion> <1189746463.18391609.1464681232913.JavaMail.zimbra@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1189746463.18391609.1464681232913.JavaMail.zimbra@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 31 May 2016 13:05:15 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2016-05-31 03:53-0400, Paolo Bonzini: > > 2016-05-27 17:22+0200, Radim Krčmář: > > > (I wonder why MacOS X doesn't read IA32_PERF_STATUS, though.) > > > > Oh, it maybe does ... we already emulate status and return 0x1000 in its > > bottom 16 bits. I have no idea what is that supposed to mean, but I > > think we should return 0x1000 in IA32_PERF_CTL then. > > It's 1000, not 0x1000 (instead, on real hardware the value is typically a > multiple of 256). It was added for Darwin too. Ah, thanks. (Drivers say that bottom 8 bits are not used.) > Returning different values is okay, because they are different on real > hardware too: > > (sudo dd if=/dev/cpu/0/msr skip=$((0x198)) iflag=skip_bytes bs=8 count=1; > sudo dd if=/dev/cpu/0/msr skip=$((0x199)) iflag=skip_bytes bs=8 count=1) | od -tx8 > 0000000 00001f3900001100 0000000000001300 > ^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ > PERF_STATUS PERF_CTL > > And perhaps if we returned non-zero values for PERF_CTL Darwin would try to > write to it. So returning zero is fine, I think. There is no correct answer... Yeah, 0 seems fine. PERF_CTL the target value for PERF_STATUS, but OS shouldn't put much trust in those values ... especially under KVM, where those MSRs make little sense.