From patchwork Wed Apr 10 15:14:57 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: 162027 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp6326122jan; Wed, 10 Apr 2019 08:15:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqxPZce3aDKXrR/35zZ+3dvEVrEh8vq2fP/UvT6X2y+OkafOeOC6zoGdq1/LoAJ6/oshDt/f X-Received: by 2002:a17:902:e7:: with SMTP id a94mr44439867pla.114.1554909325005; Wed, 10 Apr 2019 08:15:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554909324; cv=none; d=google.com; s=arc-20160816; b=zwbVsQDdEMRW0uymR8j75pBbrKRjH1G5S9vp8t4DUMymn1H3v7hwi3Ew4VNZqcTyIO gmmSy4j5W0rc7Cc2bdTjpDdFpWzzqZNKplKpKQthvieGBAUCBuC7yewKDWoliCso1XOB Z0Xuy8GqcUXyTcr4AkaZ5lop3yB/SEISsxmaa+vpdwcLaP4F+UmhpJiScwj7v0814O4V njfX8aPb4PPSFydkbgdcTwnf7IXaxqAjPh9RyA2pFmmvpAQNMbe7Rwc0G40UFO9b1TJn BLkPaAFY47rT/C3ZVHaDpP1ImW7WKTHqAYBzhqY9hDCwUksVsMZdD6+cry0LEetH2H41 TbZQ== 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=kOfAKLFRBBdtTN1W9cUh8yeKCudY9go4snz9wU7mtbg=; b=Ef98gQ7Xl/spAZK8HKwQtnazVkmhoEqPGyOugJO6dLbLSJ+1dxnhXqhcoDW39WuTDc 5EvPNEWbco7qsZrcVzUrQlicoXuZILVndenbeNl4WeoF7916EUN6s4idnTVqrlc6Ksqt dWLA1kO65j/VIAKOUbuw0mAdjtl1nJHxvdhsZAgUqgeyJEk6XyzsbTHMFmE/kc4K7Tk9 8uP3eepmn27P6SUOJP9TvCe9H0mZP15W8m0gafJ5kXTOE75vI5giaCVjmvh1hW+P9Bhm qMZOzVYlEsW8aYWXfee2mX7MTpe602lvso1UiqwXvgQQ2sFVlbXpA4sNPFFtqRfUQPsQ zcGw== 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 u79si29437683pfa.6.2019.04.10.08.15.24; Wed, 10 Apr 2019 08:15:24 -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; 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 S1733080AbfDJPPW (ORCPT + 31 others); Wed, 10 Apr 2019 11:15:22 -0400 Received: from foss.arm.com ([217.140.101.70]:56450 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732911AbfDJPPW (ORCPT ); Wed, 10 Apr 2019 11:15:22 -0400 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 B2E30374; Wed, 10 Apr 2019 08:15:21 -0700 (PDT) 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 7B4C33F59C; Wed, 10 Apr 2019 08:15:19 -0700 (PDT) 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, julien.thierry@arm.com, christoffer.dall@arm.com, marc.zyngier@arm.com, andrew.murray@arm.com, eric.auger@redhat.com, zhengxiang9@huawei.com, yuzenghui@huawei.com, wanghaibin.wang@huawei.com, Suzuki K Poulose Subject: [PATCH v2] kvm: arm: Skip stage2 huge mappings for unaligned ipa backed by THP Date: Wed, 10 Apr 2019 16:14:57 +0100 Message-Id: <1554909297-6753-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 With commit a80868f398554842b14, we no longer ensure that the THP page is properly aligned in the guest IPA. Skip the stage2 huge mapping for unaligned IPA backed by transparent hugepages. Fixes: a80868f398554842b14 ("KVM: arm/arm64: Enforce PTE mappings at stage2 when needed") Reported-by: Eric Auger Cc: Marc Zyngier Cc: Chirstoffer Dall Cc: Zenghui Yu Cc: Zheng Xiang Cc: Andrew Murray Cc: Eric Auger Signed-off-by: Suzuki K Poulose --- Changes since V1: - Zenghui Yu reported that the first version misses the boundary check for the end address. Lets reuse the existing helper to check it. --- virt/kvm/arm/mmu.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/virt/kvm/arm/mmu.c b/virt/kvm/arm/mmu.c index 27c9583..a39dcfd 100644 --- a/virt/kvm/arm/mmu.c +++ b/virt/kvm/arm/mmu.c @@ -1781,8 +1781,12 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, * Only PMD_SIZE transparent hugepages(THP) are * currently supported. This code will need to be * updated to support other THP sizes. + * + * Make sure the host VA and the guest IPA are sufficiently + * aligned and that the block is contained within the memslot. */ - if (transparent_hugepage_adjust(&pfn, &fault_ipa)) + if (fault_supports_stage2_huge_mapping(memslot, hva, PMD_SIZE) && + transparent_hugepage_adjust(&pfn, &fault_ipa)) vma_pagesize = PMD_SIZE; }