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 EE593C43461 for ; Tue, 15 Sep 2020 23:09:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BCA2C20936 for ; Tue, 15 Sep 2020 23:09:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600211391; bh=kqWVoB6h2CFpmY55/s5EOL3IJKW4VIsT2Cg+XF1ceas=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=tIHTDKFzGI3+IP6VB8KHoTi301X8jWJ2tZCsPnFaxGE8O3nVfa1v/q2r8rDQVVJUM tRC5OrsPYZkvKPftMcVZGtUCxoFdFVc2Mq1AxsJIlLeAkeDNlfiIzmzrMjkYyBpwOA sBottAzBbUDZtcyiaC++l4TtXbewTgSAWsHh97wA= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727439AbgIOXJr (ORCPT ); Tue, 15 Sep 2020 19:09:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:48766 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727298AbgIOOlg (ORCPT ); Tue, 15 Sep 2020 10:41:36 -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 176D52224D; Tue, 15 Sep 2020 14:31:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600180287; bh=kqWVoB6h2CFpmY55/s5EOL3IJKW4VIsT2Cg+XF1ceas=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Dso/cic9ktB13Dvp9phT6UZot/2FpzOvbxA5f4U40aMp2lRDJg5xHmez02XHDQlbF 5ETnrm2Psr9x+ewTX41bFXMAHszU6YylO8aQBhanlbDvFZj5wyu853Z2dyUcQILPaW /HOeFg/qBIS9ufFHP3tSDORM+rPt7Xleg2iOlMcI= 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.8 156/177] KVM: arm64: Do not try to map PUDs when they are folded into PMD Date: Tue, 15 Sep 2020 16:13:47 +0200 Message-Id: <20200915140701.167300561@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200915140653.610388773@linuxfoundation.org> References: <20200915140653.610388773@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: 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 --- arch/arm64/kvm/mmu.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) --- a/arch/arm64/kvm/mmu.c +++ b/arch/arm64/kvm/mmu.c @@ -1968,7 +1968,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);