Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp65810ima; Thu, 31 Jan 2019 12:29:35 -0800 (PST) X-Google-Smtp-Source: ALg8bN69kGpCJGlTTcmicK/dMdRGRxehEAbWaaKTKfCrJvwMNHTIbcfLeyX7tb0zzNzck71qUQ57 X-Received: by 2002:a17:902:9a04:: with SMTP id v4mr36831931plp.34.1548966575078; Thu, 31 Jan 2019 12:29:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548966575; cv=none; d=google.com; s=arc-20160816; b=ccQoC455/D0yxkSrTyIYp6c4bJ6k4aUT2a/JedoOei95QecfBugz+4a4Y1SFdrW+jv wZ7pEdWT2NGRrXRovouXuP4bU3e071hAsXn7RHy83H8zEYzPkxnw+rAlElBxsIprsVCs JoUMMDopoIG+Mq1h3ut64C5EIukmvLIwauzo+ZgWmO1bzVGpsC7QBr6NgKxVtP3l4yIb 0gSPO0/oYoVWtV4WlqI2SCoKanzPTb+uw3ODXlVYzl0eTur81QyjOVp46SKkgkRVB/eE rReYCOE90/4Zl6pZE8PIqg0qr34KSztTAIbu6p+lTzlb/N1R1/OpW0SQIk3QpPjWm5wC Jc7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=6FryeP5zW/W8eKl4Lc0QwnIwqwlVY+oDxaL0wA5absw=; b=yAKoyIF/yMctcMBHAbJXyCmtHi13pTJryRVn5NJeqa7YYwGiV6adG0vaEPiDIDwjlU EDoVNqQVaGnyYZQW9xmq7/TRgJ2DByZz7nZQDy/oZwo1+qeYNvienQyPHXAVU8eQFJqd FiECEhLAo5nUJkOWeqy99pfS1oS4joweN1dLHz5KGekDd3L7fnpj7lbnv7mUtZ0PE6F6 n1UAEOBG0WAcaLCRh5ZBUiW5vghq8pzZG3EUZ2ER9yiCNTNe27haMp++a/qR5+WTkyfn oVQbdwW9ESjNps9wcW65Y1EedCXtjasNaZ9+zEXG6UCp7LBtUcT4DWILbiJW4uqHG1n5 pCZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.de header.s=amazon201209 header.b=OOVnKzZx; 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 f4si4940600pgg.492.2019.01.31.12.29.19; Thu, 31 Jan 2019 12:29:35 -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=OOVnKzZx; 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 S1727714AbfAaU04 (ORCPT + 99 others); Thu, 31 Jan 2019 15:26:56 -0500 Received: from smtp-fw-6002.amazon.com ([52.95.49.90]:49881 "EHLO smtp-fw-6002.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725802AbfAaU04 (ORCPT ); Thu, 31 Jan 2019 15:26:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1548966415; x=1580502415; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=6FryeP5zW/W8eKl4Lc0QwnIwqwlVY+oDxaL0wA5absw=; b=OOVnKzZxVOkruDarVz7QLxzT+dUSyagA+GUkMhMIMT8ZpBURvT1r3EW4 vYcjAG1GEYVhZXntI6K/xRXLoAL0bU9iacHDbpDuzBU59pQ7LhgNmMGyn yMxmVBxLwg2GQyWW1S+/K757X99FuwE8u1/ecnKBPiBgjAKjj8H5TwgWl c=; X-IronPort-AV: E=Sophos;i="5.56,545,1539648000"; d="scan'208";a="384482626" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1d-f273de60.us-east-1.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-6002.iad6.amazon.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 31 Jan 2019 20:26:54 +0000 Received: from u54e1ad5160425a4b64ea.ant.amazon.com (iad7-ws-svc-lb50-vlan2.amazon.com [10.0.93.210]) by email-inbound-relay-1d-f273de60.us-east-1.amazon.com (8.14.7/8.14.7) with ESMTP id x0VKQnw9084336 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 31 Jan 2019 20:26:51 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 x0VKQl3I028888; Thu, 31 Jan 2019 21:26:47 +0100 Received: (from karahmed@localhost) by u54e1ad5160425a4b64ea.ant.amazon.com (8.15.2/8.15.2/Submit) id x0VKQkXx028887; Thu, 31 Jan 2019 21:26:46 +0100 From: KarimAllah Ahmed To: x86@kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Paolo Bonzini Cc: KarimAllah Ahmed Subject: [PATCH v6 02/14] X86/nVMX: Update the PML table without mapping and unmapping the page Date: Thu, 31 Jan 2019 21:24:32 +0100 Message-Id: <1548966284-28642-3-git-send-email-karahmed@amazon.de> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1548966284-28642-1-git-send-email-karahmed@amazon.de> References: <1548966284-28642-1-git-send-email-karahmed@amazon.de> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Update the PML table without mapping and unmapping the page. This also avoids using kvm_vcpu_gpa_to_page(..) which assumes that there is a "struct page" for guest memory. As a side-effect of using kvm_write_guest_page the page is also properly marked as dirty. Signed-off-by: KarimAllah Ahmed Reviewed-by: David Hildenbrand Reviewed-by: Konrad Rzeszutek Wilk --- v1 -> v2: - Use kvm_write_guest_page instead of kvm_write_guest (pbonzini) - Do not use pointer arithmetic for pml_address (pbonzini) --- arch/x86/kvm/vmx/vmx.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 4341175..a3da75a 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -7206,9 +7206,7 @@ static int vmx_write_pml_buffer(struct kvm_vcpu *vcpu) { struct vmcs12 *vmcs12; struct vcpu_vmx *vmx = to_vmx(vcpu); - gpa_t gpa; - struct page *page = NULL; - u64 *pml_address; + gpa_t gpa, dst; if (is_guest_mode(vcpu)) { WARN_ON_ONCE(vmx->nested.pml_full); @@ -7228,15 +7226,13 @@ static int vmx_write_pml_buffer(struct kvm_vcpu *vcpu) } gpa = vmcs_read64(GUEST_PHYSICAL_ADDRESS) & ~0xFFFull; + dst = vmcs12->pml_address + sizeof(u64) * vmcs12->guest_pml_index; - page = kvm_vcpu_gpa_to_page(vcpu, vmcs12->pml_address); - if (is_error_page(page)) + if (kvm_write_guest_page(vcpu->kvm, gpa_to_gfn(dst), &gpa, + offset_in_page(dst), sizeof(gpa))) return 0; - pml_address = kmap(page); - pml_address[vmcs12->guest_pml_index--] = gpa; - kunmap(page); - kvm_release_page_clean(page); + vmcs12->guest_pml_index--; } return 0; -- 2.7.4