Received: by 10.223.148.5 with SMTP id 5csp6109794wrq; Wed, 17 Jan 2018 09:29:04 -0800 (PST) X-Google-Smtp-Source: ACJfBoudqWgBsnKEu/Rz+jx0dQjNRnqlIvDKZObh08caLNlnqvQGvW4+AhskVOJrcmjDXW4lgR41 X-Received: by 10.99.104.194 with SMTP id d185mr30074051pgc.404.1516210144010; Wed, 17 Jan 2018 09:29:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516210143; cv=none; d=google.com; s=arc-20160816; b=RvoYt8OK0xRZLXB3F/TsCyJfyLo6MAhitKS7Vx7YN2GhE4jU/52R+dL7YTphUwGelK jeuMz12ZnN2HMgcYLMMThOyqSmfUZ9P3WY1T/dcepcWhi89WCECddTPE42+wvUpdjkn9 YNnhvDbreI754LOxl6uO1xZ4Yl6wtHw95RBtOuBrVlUjiR2W5b/nBvivBPnULkUm6R5x xFjXOHVDceui5btXjNl1Hx/0iBrtDls4C1/rZj2jwy7wQ2cl/4H5XUvcU8+skC5sX2Wg GxbMxjXDRUK4W7CJUyWKh+XP+OPNqzjnFgdIWR7JLeChtM+9v+bODq/v8WPVBTcV/6kC DqKQ== 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:mime-version :message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=Ek0iH6HVm2poop8zNl1Rzf9N7T0v9/XEUkq7p5j9t2I=; b=T3LyNVexOScwGvdufVTckfH6woukSjIvMjzXEbcXvv5lbFbGB4pGvL0XYfm/Ondgxo 3bblv0npXpJIbiSMGwtPc7xFrk4d0jcuopQlQK6+baXY0RVs4SVxaHoquC9wIE12Dqbc DQ9H4APr1WoMaHYqLT+5TCg1OXdHVO/I1DQHk3kwlQN3xuPfQWmtcTjE/IZ990+DB9lc NVMLA2xx5LZ2DEebbECtAt6Ghzwdw5xPOZtwON9ybR/80QksDJ0RqywUAkHjtZXiVDyn NgInb0g1VMZWAFXcyuTIS/J6ny1817msvtAx5Z2gC8IPXBfU4SvLa6YbELFO+p0p9Z47 UTeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.de header.s=amazon201209 header.b=EtJZvAsT; 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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k196si4300986pgc.385.2018.01.17.09.28.49; Wed, 17 Jan 2018 09:29:03 -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; dkim=pass header.i=@amazon.de header.s=amazon201209 header.b=EtJZvAsT; 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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754013AbeAQR1t (ORCPT + 99 others); Wed, 17 Jan 2018 12:27:49 -0500 Received: from smtp-fw-6002.amazon.com ([52.95.49.90]:65087 "EHLO smtp-fw-6002.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750969AbeAQR1r (ORCPT ); Wed, 17 Jan 2018 12:27:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1516210067; x=1547746067; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=Ek0iH6HVm2poop8zNl1Rzf9N7T0v9/XEUkq7p5j9t2I=; b=EtJZvAsTjI7gXlb0FQF+E5wXRh6yTnh4hInQVrhG4AfIwBXfwxdrFa7m adQ/PIU0tBW3B/47hCf00ZqktAyPBW+zgqa/rxz13v5aSjEDxv9VGL9xr 8JPuZt8+KxHv/+4B5IWKUbPL/ARPHUnYmfXocuIRlnLCIVc2z5rXFFbe4 c=; X-IronPort-AV: E=Sophos;i="5.46,372,1511827200"; d="scan'208";a="327689924" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-2c-6f38efd9.us-west-2.amazon.com) ([10.43.8.6]) by smtp-border-fw-out-6002.iad6.amazon.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 17 Jan 2018 17:26:17 +0000 Received: from u54e1ad5160425a4b64ea.ant.amazon.com (pdx2-ws-svc-lb17-vlan2.amazon.com [10.247.140.66]) by email-inbound-relay-2c-6f38efd9.us-west-2.amazon.com (8.14.7/8.14.7) with ESMTP id w0HHQCi9070003 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 17 Jan 2018 17:26:14 GMT Received: from u54e1ad5160425a4b64ea.ant.amazon.com (localhost [127.0.0.1]) by u54e1ad5160425a4b64ea.ant.amazon.com (8.15.2/8.15.2/Debian-3) with ESMTP id w0HHQB4S018672; Wed, 17 Jan 2018 18:26:11 +0100 Received: (from karahmed@localhost) by u54e1ad5160425a4b64ea.ant.amazon.com (8.15.2/8.15.2/Submit) id w0HHQApx018668; Wed, 17 Jan 2018 18:26:10 +0100 From: KarimAllah Ahmed To: kvm@vger.kernel.org Cc: KarimAllah Ahmed , Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , linux-kernel@vger.kernel.org Subject: [PATCH] kvm: Map PFN-type memory regions as writable (if possible) Date: Wed, 17 Jan 2018 18:26:05 +0100 Message-Id: <1516209965-18614-1-git-send-email-karahmed@amazon.de> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; -- 2.7.4