From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752205AbdJFMly (ORCPT ); Fri, 6 Oct 2017 08:41:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60564 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750950AbdJFMlx (ORCPT ); Fri, 6 Oct 2017 08:41:53 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com EDFA280472 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=rkrcmar@redhat.com Date: Fri, 6 Oct 2017 14:41:49 +0200 From: Radim =?utf-8?B?S3LEjW3DocWZ?= To: Boqun Feng Cc: Paolo Bonzini , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, "Paul E. McKenney" , Peter Zijlstra , Wanpeng Li , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org Subject: Re: [PATCH] kvm/x86: Avoid async PF to end RCU read-side critical section early in PREEMPT=n kernel Message-ID: <20171006124148.GA16466@flask> References: <20171003133653.1178-1-boqun.feng@gmail.com> <83be0b1a-24ee-28d2-3011-85c2c40e1442@redhat.com> <20171006013349.bgwpd3djojyxn7al@tardis> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171006013349.bgwpd3djojyxn7al@tardis> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 06 Oct 2017 12:41:53 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2017-10-06 09:33+0800, Boqun Feng: > On Tue, Oct 03, 2017 at 02:11:08PM +0000, Paolo Bonzini wrote: > > I'd prefer a slight change in subject and topic: > > > > ------- 8< -------- > > Subject: [PATCH] kvm/x86: Avoid async PF preempting the kernel incorrectly > > > > Currently, in PREEMPT_COUNT=n kernel, kvm_async_pf_task_wait() could call > > schedule() to reschedule in some cases. This could result in > > accidentally ending the current RCU read-side critical section early, > > causing random memory corruption in the guest, or otherwise preempting > > the currently running task inside between preempt_disable and > > preempt_enable. > > > > The difficulty to handle this well is because we don't know whether an > > async PF delivered in a preemptible section or RCU read-side critical section > > for PREEMPT_COUNT=n, since preempt_disable()/enable() and rcu_read_lock/unlock() > > are both no-ops in that case. > > > > To cure this, we treat any async PF interrupting a kernel context as one > > that cannot be preempted, preventing kvm_async_pf_task_wait() from choosing > > the schedule() path in that case. > > > > To do so, a second parameter for kvm_async_pf_task_wait() is introduced, > > so that we know whether it's called from a context interrupting the > > kernel, and the parameter is set properly in all the callsites. > > > > Cc: "Paul E. McKenney" > > Cc: Peter Zijlstra > > Cc: Wanpeng Li > > Cc: stable@vger.kernel.org > > Signed-off-by: Boqun Feng > > ------- 8< -------- > > > > It's more concise and accurate now! > > Learned a lot from your modification of commit messages, thanks! Applied with the updated commit message, thanks.