From patchwork Tue Jan 29 19:12:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 157010 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp5035518jaa; Tue, 29 Jan 2019 11:12:45 -0800 (PST) X-Google-Smtp-Source: ALg8bN6RfjdDStzkx/Dnj4N9k158lTDJRVFFzDkgKmcyXafn+g3hqGbqHCZnCOo6HNwaIFWZbdx8 X-Received: by 2002:a63:3f89:: with SMTP id m131mr25348473pga.115.1548789165630; Tue, 29 Jan 2019 11:12:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548789165; cv=none; d=google.com; s=arc-20160816; b=Gz7o/3oFdEDWxKNrWZ2fMoZxva4CsDGCS+nktLQqvCLQZoxdq6UN2ah7yeBXV0tQbX Okyue3KCkUQsLI/vGPSRsXUYfm3w61+CtCQc7Ly31bW5M3/yXbvlcd0SxF8RuSoxuHEU Iw/B/+s1TSVG9ovLj87BpIPbzlS0FMvL5xF7iAkGNcJx5OIaVeZc5xKSl52mPhdePi7g h5JIQUev7Fdru9TJ8V2nJq5bq9MCpOsUd3IQGkkEyei1KuA7YqKAPGBdfxatSGXp66Gb Dx2w2vufJTt2hdzIlCMiH7vHvjZnXabf8ZTQ/fGyA9OJ/fS2tfMn9D+YpDH0MFw6nf65 eywA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=X0f5KXqHcVbGyKTaqVeB29Rrf5KWFw++s99wQZk+LYc=; b=uYTEWhGoQek+UfPxulnXS1UcFz9e3wh42fK1It76tCjcU8cyqD904oTLQkKO0A7vL7 jRDPCP2bj15TrnwKhcxUzzwMni8ASJT8rdJYBqtyltx7xs0avBqkUDIs4aPW/PO6cHY5 duJ7KBoHWpjk86+ccU6A0zPLi4Asx7xMPofIKmo0syX61D95WRTrHsYwBurhxIcmK91/ ZSGzpFJDPOgz09ORIvdSrwPWpFw9J/3WcOZgXWEsis/jhkE2TG9yAmnNsjCu1J6vp8ZA zWycLIQ+UReZPolTOktHkM+AQ/IABAVw+5RMjHQ1WqYxG/8JNPhEjr2XOzo8pPZI32cA Mg1A== ARC-Authentication-Results: i=1; mx.google.com; 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 a193si31235959pfa.214.2019.01.29.11.12.45; Tue, 29 Jan 2019 11:12:45 -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; 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 S1729368AbfA2TMn (ORCPT + 31 others); Tue, 29 Jan 2019 14:12:43 -0500 Received: from foss.arm.com ([217.140.101.70]:43218 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726984AbfA2TMn (ORCPT ); Tue, 29 Jan 2019 14:12:43 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A3BF4A78; Tue, 29 Jan 2019 11:12:42 -0800 (PST) Received: from en101.cambridge.arm.com (en101.cambridge.arm.com [10.1.196.93]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 2A67C3F557; Tue, 29 Jan 2019 11:12:41 -0800 (PST) From: Suzuki K Poulose To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu, cdall@kernel.org, Suzuki K Poulose , Christoffer Dall , Marc Zyngier Subject: [PATCH] kvm: arm64: Relax the restriction on using stage2 PUD huge mapping Date: Tue, 29 Jan 2019 19:12:17 +0000 Message-Id: <1548789137-4446-1-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We restrict mapping the PUD huge pages in stage2 to only when the stage2 has 4 level page table, leaving the feature unused with the default IPA size. But we could use it even with a 3 level page table, i.e, when the PUD level is folded into PGD, just like the stage1. Relax the condition to allow using the PUD huge page mappings at stage2 when it is possible. Cc: Christoffer Dall Cc: Marc Zyngier Signed-off-by: Suzuki K Poulose --- virt/kvm/arm/mmu.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) -- 2.7.4 diff --git a/virt/kvm/arm/mmu.c b/virt/kvm/arm/mmu.c index fbdf3ac..30251e2 100644 --- a/virt/kvm/arm/mmu.c +++ b/virt/kvm/arm/mmu.c @@ -1695,11 +1695,14 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, vma_pagesize = vma_kernel_pagesize(vma); /* - * PUD level may not exist for a VM but PMD is guaranteed to - * exist. + * The stage2 has a minimum of 2 level table (For arm64 see + * kvm_arm_setup_stage2()). Hence, we are guaranteed that we can + * use PMD_SIZE huge mappings (even when the PMD is folded into PGD). + * As for PUD huge maps, we must make sure that we have at least + * 3 levels, i.e, PMD is not folded. */ if ((vma_pagesize == PMD_SIZE || - (vma_pagesize == PUD_SIZE && kvm_stage2_has_pud(kvm))) && + (vma_pagesize == PUD_SIZE && kvm_stage2_has_pmd(kvm))) && !force_pte) { gfn = (fault_ipa & huge_page_mask(hstate_vma(vma))) >> PAGE_SHIFT; }