Received: by 10.223.148.5 with SMTP id 5csp6142171wrq; Wed, 17 Jan 2018 09:57:23 -0800 (PST) X-Google-Smtp-Source: ACJfBosmcMVnaK/Qj3IZy3SbpFDt+iuUt/0CIJQuafiZllWORoK4eHneQL0o1UMC3yB/5RdIbwjn X-Received: by 10.84.136.129 with SMTP id 1mr30388065pll.203.1516211843499; Wed, 17 Jan 2018 09:57:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516211843; cv=none; d=google.com; s=arc-20160816; b=cSHNv4Znh4Oktm9rguXHH2m5isHI7vwEtW3h4eJc7ASj/J54B3UVhBI9OMv5+yl+PT J3v3uhaCLTujnulZRIg9EKkb24b3NSQvf8wmrU8SbBT/x9xI85RhewJA0vhXz2XUlvTL vm9aLaR/4I4nQGsQ0vLUGmzGObABOMzEVxCFoK1As9cW1cLT6LkygPsTHsMDsN62mU9F M4d4RUEcp+mvCh/HViB5cIczdLGhLT4oz3jyViawY/oxVhNXqplTvE2pxV3z2N6jNJKA zXe6ZGI+yVTJ46iFLMuPuM0B5F+88MWuuef3Eryicvr6ZrFp48QPea2wVqf9Lc1MzfJi 3SFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=62x1K5mxtP9GreC9Upw4n/fdILQmnEgK+Bfsbb0QtZ0=; b=Izl6lsGbGtVmFKikrutvTWwcOF8pJVwP+vHlLl6WsRLMvkP7GEIPalb8SE+V3oY8LT 4MJDps8BYmceMz8x/k72oAh7aaEmk7Enjq5GXux2sRVPN4quz5n35NwxIH+2CQYyCic1 Mnki5waX0EuugRi7TADR2GqkL6VhTu0PFkY5FGBWvsJK9c0OIZSkeB7RtLtssNvdcPtY JLz0BeRilUVvXVgKeCCy72e2b9644oza3Y5t1rj59/U1XEXaWNIJmzYDopjPEdh1/0hj x3P6jaK7tRHcCbXKHhb9xn7AghD8qOusJw7Y2sxO89WvcpQkJqdExfidKFrZT5mM1uKJ Lt+w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q3si4370064pgr.290.2018.01.17.09.57.09; Wed, 17 Jan 2018 09:57:23 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754363AbeAQR4p (ORCPT + 99 others); Wed, 17 Jan 2018 12:56:45 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52660 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753910AbeAQR4n (ORCPT ); Wed, 17 Jan 2018 12:56:43 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B9209C01B3E7; Wed, 17 Jan 2018 17:56:43 +0000 (UTC) Received: from [10.36.117.142] (ovpn-117-142.ams2.redhat.com [10.36.117.142]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 759A560577; Wed, 17 Jan 2018 17:56:42 +0000 (UTC) Subject: Re: [PATCH] kvm: Map PFN-type memory regions as writable (if possible) To: KarimAllah Ahmed , kvm@vger.kernel.org Cc: =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , linux-kernel@vger.kernel.org References: <1516209965-18614-1-git-send-email-karahmed@amazon.de> From: Paolo Bonzini Message-ID: <64411cad-77ee-2f6e-d431-78e853cae65d@redhat.com> Date: Wed, 17 Jan 2018 18:56:40 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <1516209965-18614-1-git-send-email-karahmed@amazon.de> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 17 Jan 2018 17:56:43 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 17/01/2018 18:26, KarimAllah Ahmed wrote: > For EPT-violations that are triggered by a read, the pages are also mapped with > write permissions (if their memory region is also writable). That would avoid > getting yet another fault on the same page when a write occurs. > > This optimization only happens when you have a "struct page" backing the memory > region. So also enable it for memory regions that do not have a "struct page". > > Cc: Paolo Bonzini > Cc: Radim Krčmář > Cc: kvm@vger.kernel.org > Cc: linux-kernel@vger.kernel.org > Signed-off-by: KarimAllah Ahmed > --- > virt/kvm/kvm_main.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > index 97da45e..0efb089 100644 > --- a/virt/kvm/kvm_main.c > +++ b/virt/kvm/kvm_main.c > @@ -1534,6 +1534,8 @@ static kvm_pfn_t hva_to_pfn(unsigned long addr, bool atomic, bool *async, > goto retry; > if (r < 0) > pfn = KVM_PFN_ERR_FAULT; > + if (writable) > + *writable = true; > } else { > if (async && vma_is_valid(vma, write_fault)) > *async = true; > Looks good, but it should be in hva_to_pfn_remapped. Paolo