From patchwork Wed Apr 10 15:23:51 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: 162030 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp6335909jan; Wed, 10 Apr 2019 08:24:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqziJcSbcrTDuT4fMtxnOe2tettNrbXXJ7oHi102Ij5AkO4U1UJfTl5/vSiCdLqk8iHeruIz X-Received: by 2002:a62:e10e:: with SMTP id q14mr43166192pfh.161.1554909849236; Wed, 10 Apr 2019 08:24:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554909849; cv=none; d=google.com; s=arc-20160816; b=sJrbZHyIKHn2vJlfCu3g4IZMt2WrNVfYoBh5OltyZ7mRVBvvuO3C9OJVT/WIHmE0qM tuKfYZFoRR4PI7z7QAlSZqaNnFYr2FS7OrDxGHCgNF+bP0kyAQMdUIXaS6v6jyaR2WMu t52w8Kkm4uPuZr8wJgO3PzQaNfLLkK1Kh2avY3MzcKhohELfngUSS7y1rNZp1+DUSFqS HJZ5MbSvty9Q0/6mn177dFa9niaVcc3CeziI74CUB38pj+uRPdWkC40kkD0uzMXS19O2 cQ+xPOwBcWlD1gnFsEizl+d4JXW6d5EXamX/6RtNOECFZym8J3r2LyteXv7b9KmqVTAR XCmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=tL+3qIrgEXpKC3HQpPApCnB7ekJMmCm8ZNf8EMvopvg=; b=y0IOcZATzUdpf3pxiMEvepsG24yiPiN/Ln9AYMY7xtNjFvvKAn4zKaosFGq1qtVWWL zVAjmkY7z56saKTfZ7laCx8Xk8MKvxA0xwEdZEt5lwbGtUzWg9YJDEOtCWEngSldyO3E WA0WwN/agdXDbWu9L1qrAn6/9kub31hwqUkD1pDKFY9HWqTiBcJlHVxt0havFkWr/pEz X7a/fw2bK9DraSmj6zP7gptot4PelOlXq/6dwvNTARDAJDV07UrHpfmCKKFSgFEOShN9 bNod7bZNqkXWZ4S3fle8/V0ARRC1N3WrTvm1nTmGvrh8dZ5jd83Z+7GJqIJMSI7acVl6 c2Ng== 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 194si28550176pfu.48.2019.04.10.08.24.08; Wed, 10 Apr 2019 08:24:09 -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 S1730094AbfDJPYH (ORCPT + 31 others); Wed, 10 Apr 2019 11:24:07 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:56590 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729827AbfDJPYD (ORCPT ); Wed, 10 Apr 2019 11:24:03 -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 85312EBD; Wed, 10 Apr 2019 08:24:03 -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 4479A3F59C; Wed, 10 Apr 2019 08:24:01 -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 1/2] kvm: arm: Clean up the checking for huge mapping Date: Wed, 10 Apr 2019 16:23:51 +0100 Message-Id: <1554909832-7169-2-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554909832-7169-1-git-send-email-suzuki.poulose@arm.com> References: <1554909297-6753-1-git-send-email-suzuki.poulose@arm.com> <1554909832-7169-1-git-send-email-suzuki.poulose@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If we are checking whether the stage2 can map PAGE_SIZE, we don't have to do the boundary checks as both the host VMA and the guest memslots are page aligned. Bail the case easily. Cc: Christoffer Dall Cc: Marc Zyngier Signed-off-by: Suzuki K Poulose --- virt/kvm/arm/mmu.c | 4 ++++ 1 file changed, 4 insertions(+) -- 2.7.4 diff --git a/virt/kvm/arm/mmu.c b/virt/kvm/arm/mmu.c index a39dcfd..6d73322 100644 --- a/virt/kvm/arm/mmu.c +++ b/virt/kvm/arm/mmu.c @@ -1624,6 +1624,10 @@ static bool fault_supports_stage2_huge_mapping(struct kvm_memory_slot *memslot, hva_t uaddr_start, uaddr_end; size_t size; + /* The memslot and the VMA are guaranteed to be aligned to PAGE_SIZE */ + if (map_size == PAGE_SIZE) + return true; + size = memslot->npages * PAGE_SIZE; gpa_start = memslot->base_gfn << PAGE_SHIFT;