Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753194AbcCDN1K (ORCPT ); Fri, 4 Mar 2016 08:27:10 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46067 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751213AbcCDN1H (ORCPT ); Fri, 4 Mar 2016 08:27:07 -0500 Date: Fri, 4 Mar 2016 14:27:03 +0100 From: Radim =?utf-8?B?S3LEjW3DocWZ?= To: David Matlack Cc: "linux-kernel@vger.kernel.org" , kvm list , Paolo Bonzini , =?utf-8?B?SmnFmcOtIE9sxaFh?= , stable@vger.kernel.org Subject: Re: [PATCH] KVM: x86: disable PEBS before a guest entry Message-ID: <20160304132702.GE2294@potion.brq.redhat.com> References: <1457031201-31723-1-git-send-email-rkrcmar@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1233 Lines: 28 2016-03-03 13:32-0800, David Matlack: > On Thu, Mar 3, 2016 at 10:53 AM, Radim Krčmář wrote: >> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c >> @@ -1767,6 +1767,13 @@ static void clear_atomic_switch_msr(struct vcpu_vmx *vmx, unsigned msr) >> return; >> } >> break; >> + case MSR_IA32_PEBS_ENABLE: >> + /* PEBS needs a quiescent period after being disabled (to write >> + * a record). Disabling PEBS through VMX MSR swapping doesn't >> + * provide that period, so a CPU could write host's record into >> + * guest's memory. >> + */ >> + wrmsrl(MSR_IA32_PEBS_ENABLE, 0); > > Should this go in add_atomic_switch_msr instead of clear_atomic_switch_msr? Yes, it could be cleared in both (in case guest PEBS can be non-zero), but I wanted to have it only in add_atomic_switch_msr(). Thank you! v2 underway. (In case it makes you wonder how it was tested: I have a bad habit of trying whether a patch can be improved before posting and this one went awry, because I already returned the machine with reproducer and the change seemed simple enough.)