Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2994791imm; Thu, 17 May 2018 01:18:20 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpn8lCi/nNefwpAiETuD/JAPJ268pj+cealxRJ2O08GRzrq9Yhw9s5DxRwY963+e6fBfZZl X-Received: by 2002:a62:22db:: with SMTP id p88-v6mr4293826pfj.239.1526545100905; Thu, 17 May 2018 01:18:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526545100; cv=none; d=google.com; s=arc-20160816; b=0zcWKzgtDLnK17jzj93hqji9FMxxCEnVecjWSt4pRg7bFdjEpTlU+/dUYR7F7aUiZE XonF6Hs04teP8JNOG7rIgfNojjdQb7hDQ7AENkBSLb2yzk4u6tkxtGdov3EB7O9aA8nc HZEp5kCwe7vRquOu6Zsc7HQE9tX9TazE8Z2wPiLzOaIwC6VjipecAFsGTIDvEeZ3LdEt gNntfmHnLfasBp+U8RomNg5zJnHbKMwQORIuMhKNedN9S9rMJihZrv554/9JoFDXQ8rv OueJQ4WWNzaLxypSxYac3mqLb68Wz0uUUyp5aD9/sVy456oAXVfmEE19XV4pSpWhb+W6 x2xA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=eAwWqELKsmCjzJoz44Cfxjaw+PquKwYMr/wKfppTr0U=; b=CV2bTDmlQa7JIcheYVBn7Xwf0amZbWeE6KvWznz/6HukGIskas6yvD22HFAkz+cCg4 5OSJwTNJ/Bw5+J6Auix56q9Cd1jGOCemyNdYxeLpy7urS1uqNgXvTWETILjWWvGh//aZ iHT0KqZISwUXZ0ls3bbVPbOTM3ytdfPoy5aL3JhlBkMv5SGMSfpIOOrcmkPY4yr4tbWm bQ+93PbyWggsNoVXEBFyeniaPVxP2nuTqFk2/yl4hQZYMtJ+TaI/jSxkH3/hkv5v8W8O GpQy/XoQOIM7LOyHngg5QILcceuxRKsaI7FNwZ4YqDKf56tBuNDWhTZsILuia/sEAD9M lQDQ== 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 z73-v6si4952977pfj.197.2018.05.17.01.18.06; Thu, 17 May 2018 01:18:20 -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 S1752175AbeEQIRw (ORCPT + 99 others); Thu, 17 May 2018 04:17:52 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:58800 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750891AbeEQIRu (ORCPT ); Thu, 17 May 2018 04:17:50 -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 BC80A15BF; Thu, 17 May 2018 01:17:49 -0700 (PDT) Received: from [10.1.206.73] (en101.cambridge.arm.com [10.1.206.73]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 4DA333F614; Thu, 17 May 2018 01:17:46 -0700 (PDT) Subject: Re: [PATCH] KVM: arm/arm64: add WARN_ON if size is not PAGE_SIZE aligned in unmap_stage2_range To: Jia He , Christoffer Dall , Marc Zyngier , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu Cc: Andrew Morton , Andrea Arcangeli , Claudio Imbrenda , Arvind Yadav , "David S. Miller" , Minchan Kim , Mike Rapoport , Hugh Dickins , "Paul E. McKenney" , linux-mm@kvack.org, linux-kernel@vger.kernel.org, jia.he@hxt-semitech.com References: <1526537487-14804-1-git-send-email-hejianet@gmail.com> From: Suzuki K Poulose Message-ID: <698b0355-d430-86b8-cd09-83c6d9e566f8@arm.com> Date: Thu, 17 May 2018 09:17:44 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <1526537487-14804-1-git-send-email-hejianet@gmail.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jia, On 17/05/18 07:11, Jia He wrote: > I ever met a panic under memory pressure tests(start 20 guests and run > memhog in the host). Please avoid using "I" in the commit description and preferably stick to an objective description. > > The root cause might be what I fixed at [1]. But from arm kvm points of > view, it would be better we caught the exception earlier and clearer. > > If the size is not PAGE_SIZE aligned, unmap_stage2_range might unmap the > wrong(more or less) page range. Hence it caused the "BUG: Bad page > state" I don't see why we should ever panic with a "positive" size value. Anyways, the unmap requests must be in units of pages. So this check might be useful. Reviewed-by: Suzuki K Poulose > > [1] https://lkml.org/lkml/2018/5/3/1042 > > Signed-off-by: jia.he@hxt-semitech.com > --- > virt/kvm/arm/mmu.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/virt/kvm/arm/mmu.c b/virt/kvm/arm/mmu.c > index 7f6a944..8dac311 100644 > --- a/virt/kvm/arm/mmu.c > +++ b/virt/kvm/arm/mmu.c > @@ -297,6 +297,8 @@ static void unmap_stage2_range(struct kvm *kvm, phys_addr_t start, u64 size) > phys_addr_t next; > > assert_spin_locked(&kvm->mmu_lock); > + WARN_ON(size & ~PAGE_MASK); > + > pgd = kvm->arch.pgd + stage2_pgd_index(addr); > do { > /* >