From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755768AbcEaHyE (ORCPT ); Tue, 31 May 2016 03:54:04 -0400 Received: from mx3-phx2.redhat.com ([209.132.183.24]:45766 "EHLO mx3-phx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755337AbcEaHyB convert rfc822-to-8bit (ORCPT ); Tue, 31 May 2016 03:54:01 -0400 Date: Tue, 31 May 2016 03:53:52 -0400 (EDT) From: Paolo Bonzini To: Radim =?utf-8?B?S3LEjW3DocWZ?= Cc: kmeaw@yandex-team.ru, "Gabriel L. Somlo" , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, gleb@kernel.org Message-ID: <1189746463.18391609.1464681232913.JavaMail.zimbra@redhat.com> In-Reply-To: <20160527153850.GC11721@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> Subject: Re: [PATCH] KVM: Handle MSR_IA32_PERF_CTL MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT X-Originating-IP: [10.4.164.1, 10.5.100.50] X-Mailer: Zimbra 8.0.6_GA_5922 (ZimbraWebClient - FF46 (Linux)/8.0.6_GA_5922) Thread-Topic: Handle MSR_IA32_PERF_CTL Thread-Index: vti6Nsnv+QxrdqLQa/6UrTvjGZrs5A== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > 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. 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... Paolo > (Would be nice to understand how that 0x1000 happened ... we might want > 0 in both.) >