From mboxrd@z Thu Jan 1 00:00:00 1970 From: Radim =?utf-8?B?S3LEjW3DocWZ?= Subject: Re: [PATCH] KVM: Handle MSR_IA32_PERF_CTL Date: Tue, 31 May 2016 15:05:10 +0200 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-Transfer-Encoding: QUOTED-PRINTABLE Cc: kmeaw@yandex-team.ru, "Gabriel L. Somlo" , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, gleb@kernel.org To: Paolo Bonzini Return-path: Content-Disposition: inline In-Reply-To: <1189746463.18391609.1464681232913.JavaMail.zimbra@redhat.com> Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org 2016-05-31 03:53-0400, Paolo Bonzini: > > 2016-05-27 17:22+0200, Radim Kr=C4=8Dm=C3=A1=C5=99: > > > (I wonder why MacOS X doesn't read IA32_PERF_STATUS, though.) > >=20 > > Oh, it maybe does ... we already emulate status and return 0x1000 i= n 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. >=20 > It's 1000, not 0x1000 (instead, on real hardware the value is typical= ly 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 rea= l > hardware too: >=20 > (sudo dd if=3D/dev/cpu/0/msr skip=3D$((0x198)) iflag=3Dskip_bytes bs=3D= 8 count=3D1; > sudo dd if=3D/dev/cpu/0/msr skip=3D$((0x199)) iflag=3Dskip_bytes bs=3D= 8 count=3D1) | od -tx8 > 0000000 00001f3900001100 0000000000001300 > ^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ > PERF_STATUS PERF_CTL >=20 > 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 correc= t 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, wher= e those MSRs make little sense.