Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3050616ybi; Tue, 2 Jul 2019 01:09:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqwpctY1mMdVBTC0tJ3hO9UmCBPswg14YdJ3cXNtoXWNISvcC2erPb83hElQezPGGfrc57Ct X-Received: by 2002:a63:1d53:: with SMTP id d19mr29388172pgm.152.1562054969815; Tue, 02 Jul 2019 01:09:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562054969; cv=none; d=google.com; s=arc-20160816; b=Ao/Lnt06x5CfL/USlHlNQE5XLXNFSR/QF2RULz8lh2T48WYGCdz/S8FjXs3fxvE4JE yHRs2Xc0dzTZmfD0c6XxginmZUTcDsieTRhtx7sggZ0yT1UmWLz2UdGVwfYb7jY60qLU e2Pq+MNFCUFgL2Y2COU+O446mDC/XbIGJKFEMnbOJ2MYaVDgW3rPcruRJsKULIvyxf2B Uf6/CVort1ngwvrw1Nq0vZVkQX1Ty+Q6bDVJnxZTxG3rMez7QWsMjHOyo5ftuk5gqorl YAiHrR+Zs6foIBYLQv9aUtmyR0CYHgDQCHjG3ynNbrSBx51NpYEK3X8l4GCUos3eL81D hFqg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=S+mvaZly7cBzmYtAqNoMT3GySXIGxBmPPFXQGzDAzno=; b=XfdGJdIQDY5Zh8HZH5zF+RNtcTvmYuI57BSgDc0h+pTwBl3qF6vWuGR0qd8xpJaYmW V+H0UWUdRD3ZYpHhO1qbiZGmUxlMzWvd90g2AdIme6nj8Hxcunfa4eaxqbaWQpZ8jixS fs1g1HaeKgtqgZVSUcT4LjH7tg0Eaj4Hr+RjPQ7uIEjhXbFwMqclCAzmXHkhNTD9RAgK 4NP41CyB29EurphWQL2xkcEwzTA0OYiwaGSd/QiTPxn6f+ucVZX9zMLOPm9yp2bD78tV IwKgCufAubuu1gcexU9cBNcckQp5Z97ddlzEwBe81esUAZktRKYSOB5UAtHWK8AfDMrI O4kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yjSertbK; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f1si12450618plf.87.2019.07.02.01.09.15; Tue, 02 Jul 2019 01:09:29 -0700 (PDT) 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=@kernel.org header.s=default header.b=yjSertbK; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727844AbfGBIHD (ORCPT + 99 others); Tue, 2 Jul 2019 04:07:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:54052 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728180AbfGBIHB (ORCPT ); Tue, 2 Jul 2019 04:07:01 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DE54821479; Tue, 2 Jul 2019 08:06:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562054820; bh=PwDS63IozS34PatsKZ+K/OUuNN5/IbEOeNXmXngO5FY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yjSertbKYRHfBX6phdl6zK8JbVJYM9N/96eeJV4hHHGaMTNbpz70WsZeCufsp1LXJ +9jd8SBTw5l3E12krzIYe6XGr34ee6ykvEADqUQq7JF21EAgg7eXrQlY4RQx/jfvg1 ePKCbOrxl18K7ob0+Enb4AXMm2/YRKrgH8dhpcIs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jiri Palecek , Sean Christopherson , Paolo Bonzini Subject: [PATCH 4.19 44/72] KVM: x86/mmu: Allocate PAE root array when using SVMs 32-bit NPT Date: Tue, 2 Jul 2019 10:01:45 +0200 Message-Id: <20190702080126.920551180@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190702080124.564652899@linuxfoundation.org> References: <20190702080124.564652899@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Sean Christopherson commit b6b80c78af838bef17501416d5d383fedab0010a upstream. SVM's Nested Page Tables (NPT) reuses x86 paging for the host-controlled page walk. For 32-bit KVM, this means PAE paging is used even when TDP is enabled, i.e. the PAE root array needs to be allocated. Fixes: ee6268ba3a68 ("KVM: x86: Skip pae_root shadow allocation if tdp enabled") Cc: stable@vger.kernel.org Reported-by: Jiri Palecek Signed-off-by: Sean Christopherson Signed-off-by: Paolo Bonzini Cc: Jiri Palecek Signed-off-by: Greg Kroah-Hartman --- arch/x86/kvm/mmu.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c @@ -5386,7 +5386,16 @@ static int alloc_mmu_pages(struct kvm_vc struct page *page; int i; - if (tdp_enabled) + /* + * When using PAE paging, the four PDPTEs are treated as 'root' pages, + * while the PDP table is a per-vCPU construct that's allocated at MMU + * creation. When emulating 32-bit mode, cr3 is only 32 bits even on + * x86_64. Therefore we need to allocate the PDP table in the first + * 4GB of memory, which happens to fit the DMA32 zone. Except for + * SVM's 32-bit NPT support, TDP paging doesn't use PAE paging and can + * skip allocating the PDP table. + */ + if (tdp_enabled && kvm_x86_ops->get_tdp_level(vcpu) > PT32E_ROOT_LEVEL) return 0; /*