From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6262EC433E2 for ; Tue, 15 Sep 2020 14:32:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 22A5B22268 for ; Tue, 15 Sep 2020 14:32:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600180338; bh=npowRYLuVsqwIs2iKviDedMlhH1m545qXbGi+p31kdI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=MP5F75KQwPNEVkyCtbi8tpcFpaSKOnHbX9DGpUWMUTQzy+SH2lS0uH1/ObV9f5QBq 6Ldlxvd+JkCiVJ1BPDcrFmxl5IWBNeW/clnkPl7MA4DjDmguoKd1xL1fl2gXcusHeC xTZvv/mIMrliLH6DC7iYIA/RBhElkIl9EKrkM0JQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727073AbgIOObx (ORCPT ); Tue, 15 Sep 2020 10:31:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:46456 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727044AbgIOOba (ORCPT ); Tue, 15 Sep 2020 10:31:30 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 BCADA22268; Tue, 15 Sep 2020 14:23:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600179783; bh=npowRYLuVsqwIs2iKviDedMlhH1m545qXbGi+p31kdI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ri6BVl4a9bBUHOgjAkssBKrkWOfFCmY06CYLYeidx28WKHITVd4K/qH0yBGsokq/0 J6ceYfOJfe3M4iugmpflNNTINyPNMhB3y/Kf1tK0OkYjTb2ZlbyBpa7fBH65f6IeJt iA+N2tiN5SpNS8hxExQtyjt8yTdbgjznUVHZQsUw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Gavin Shan , Eric Auger , Alexandru Elisei , Marc Zyngier Subject: [PATCH 5.4 116/132] KVM: arm64: Do not try to map PUDs when they are folded into PMD Date: Tue, 15 Sep 2020 16:13:38 +0200 Message-Id: <20200915140649.922172560@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200915140644.037604909@linuxfoundation.org> References: <20200915140644.037604909@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Marc Zyngier commit 3fb884ffe921c99483a84b0175f3c03f048e9069 upstream. For the obscure cases where PMD and PUD are the same size (64kB pages with 42bit VA, for example, which results in only two levels of page tables), we can't map anything as a PUD, because there is... erm... no PUD to speak of. Everything is either a PMD or a PTE. So let's only try and map a PUD when its size is different from that of a PMD. Cc: stable@vger.kernel.org Fixes: b8e0ba7c8bea ("KVM: arm64: Add support for creating PUD hugepages at stage 2") Reported-by: Gavin Shan Reported-by: Eric Auger Reviewed-by: Alexandru Elisei Reviewed-by: Gavin Shan Tested-by: Gavin Shan Tested-by: Eric Auger Tested-by: Alexandru Elisei Signed-off-by: Marc Zyngier Signed-off-by: Greg Kroah-Hartman --- virt/kvm/arm/mmu.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) --- a/virt/kvm/arm/mmu.c +++ b/virt/kvm/arm/mmu.c @@ -1814,7 +1814,12 @@ static int user_mem_abort(struct kvm_vcp (fault_status == FSC_PERM && stage2_is_exec(kvm, fault_ipa, vma_pagesize)); - if (vma_pagesize == PUD_SIZE) { + /* + * If PUD_SIZE == PMD_SIZE, there is no real PUD level, and + * all we have is a 2-level page table. Trying to map a PUD in + * this case would be fatally wrong. + */ + if (PUD_SIZE != PMD_SIZE && vma_pagesize == PUD_SIZE) { pud_t new_pud = kvm_pfn_pud(pfn, mem_type); new_pud = kvm_pud_mkhuge(new_pud);