From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48586) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a1xlp-0006uv-Ir for qemu-devel@nongnu.org; Thu, 26 Nov 2015 09:43:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a1xlm-0000O4-As for qemu-devel@nongnu.org; Thu, 26 Nov 2015 09:43:37 -0500 Received: from mx1.redhat.com ([209.132.183.28]:35088) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a1xlm-0000NK-4q for qemu-devel@nongnu.org; Thu, 26 Nov 2015 09:43:34 -0500 References: <1448464821-8199-1-git-send-email-asmetanin@virtuozzo.com> <1448464821-8199-7-git-send-email-asmetanin@virtuozzo.com> <5655E748.4080503@redhat.com> <5655E800.5030309@virtuozzo.com> <5655EC83.4090201@redhat.com> <5656CBAA.3050803@virtuozzo.com> From: Paolo Bonzini Message-ID: <56571A7F.6080504@redhat.com> Date: Thu, 26 Nov 2015 15:43:11 +0100 MIME-Version: 1.0 In-Reply-To: <5656CBAA.3050803@virtuozzo.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v1 6/7] kvm/x86: Hyper-V SynIC message slot pending clearing at SINT ack List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: asmetanin@virtuozzo.com, kvm@vger.kernel.org Cc: Gleb Natapov , Haiyang Zhang , qemu-devel@nongnu.org, Roman Kagan , "Denis V. Lunev" , Vitaly Kuznetsov , "K. Y. Srinivasan" On 26/11/2015 10:06, Andrey Smetanin wrote: >=20 >=20 > On 11/25/2015 08:14 PM, Paolo Bonzini wrote: >> >> >> On 25/11/2015 17:55, Andrey Smetanin wrote: >>>> >>>> + gpa =3D synic->msg_page & PAGE_MASK; >>>> + page =3D kvm_vcpu_gfn_to_page(vcpu, gpa >> PAGE_SHIFT); >>>> + if (is_error_page(page)) { >>>> + vcpu_err(vcpu, "Hyper-V SynIC can't get msg page, gpa >>>> 0x%llx\n", >>>> + gpa); >>>> + return; >>>> + } >>>> + msg_page =3D kmap_atomic(page); >>> >>> But the message page is not being pinned, is it? >>> >>> Actually I don't know anything about pinning. >>> Is it pinning against page swapping ? >> >> Yes. Unless the page is pinned, kmap_atomic can fail. > kmap_atomic() can't fail for a valid page struct. Does > kvm_vcpu_gfn_to_page() can provide invalid page(swapped page) struct > which may pass is_error_page(page) check but can leads to incorrect > behavior inside kmap_atomic()? No, you're right. Nevermind, I was confused because I thought you needed kmap_atomic rather than kmap. Here using kmap_atomic is just an optimization, so it's okay. (If you needed kmap_atomic, the problem would have been that kvm_vcpu_gfn_to_page() can sleep). In patch 7/7 you're also not in atomic context, so kvm_vcpu_gfn_to_page is okay. Shouldn't have reviewed the patch when tired. :) Then the patches look good, I think. With a testcase I can try them out and hopefully merge them for Linux 4.5 / QEMU 2.6. Paolo