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=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,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 E2CB8C433DB for ; Wed, 3 Mar 2021 19:05:40 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 818F664EEC for ; Wed, 3 Mar 2021 19:05:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 818F664EEC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:MIME-Version:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Message-Id:Date:Subject:Cc:To:From:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=o1xlL6JAXKtHsY7Ntlp5dqHwQReBCye/CWjQAihghK8=; b=dVE2XyRgR5btt8/L3Sequs/psS HrkyGRkekvw2Yj9aDSvI0Zz1ddJZ7ryoUIeJbABcVue6ja6Ydcp8tG6zESL6IaYs3CVtPvjPKeZUz 81kY3CUwUmQ0RTgzJnQ9FHdMRh54iC5Z8Z3lKVjqoKAQsqq3iHgWbkRMMfjVxHiuVjsUaH5vp8TWJ xre9zwdclTs0dqIVcj/MHeLBHYztGDD+qyrwqobcX2FV4sVV3Axq37FW83T643br8nfkc8I4wplyc ACKy4ane4lwxd1ViSWdm8TQ/8xtl37b3qPdpZ75GAgO4LcnPiDWpWQP3xJFZ4cJxMQWQAOmPhuzmV /AXhcHFA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lHWmU-0068GE-1W; Wed, 03 Mar 2021 19:03:34 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lHT2F-005Hf7-Sx for linux-arm-kernel@desiato.infradead.org; Wed, 03 Mar 2021 15:03:36 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To:References; bh=9T2ezwB6CkjSZItt+EJ9fqiZZ93ihCDh4qqXuS62XQo=; b=RA8Szo7qhrsjGDw9zPJodTB0lI q2bgkX4J0o4iJPRk7jnWEc1s0c8i8/Nt8b247sOM2s4Kj5sCMXqbT5exNdfLu+A9DjJpO4A/15ACT uuHEE3bZpvqYrHScsfqjJJzG7C4K2eSL3Uir4UaGF5eyA+KpUvO93qLD55pVDjsmbfg9oz+MqWS6M ngzcJ4A59uezVAEbubqeRcxD6k0VW+wBuY/zqfB+9sL27MwO1QZwvg6cjpeMwuQQxuDeEZSPv6U3k B4pGPwqWntCtcsSqbJhFjdOuyX7LqkQoqtTIvTkX85f0hPR4TLKI5Tohpbz/UHT0EUh37Ysmwkcjl lbWpcmcg==; Received: from foss.arm.com ([217.140.110.172]) by casper.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lHHTN-0011kx-7A for linux-arm-kernel@lists.infradead.org; Wed, 03 Mar 2021 02:42:50 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8D8B71FB; Tue, 2 Mar 2021 18:42:38 -0800 (PST) Received: from entos-ampere-02.shanghai.arm.com (entos-ampere-02.shanghai.arm.com [10.169.214.110]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id A34EE3F73B; Tue, 2 Mar 2021 18:42:34 -0800 (PST) From: Jia He To: Marc Zyngier , kvmarm@lists.cs.columbia.edu Cc: James Morse , Julien Thierry , Suzuki K Poulose , Catalin Marinas , Will Deacon , Gavin Shan , Yanan Wang , Quentin Perret , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Jia He Subject: [PATCH] KVM: arm64: Fix unaligned addr case in mmu walking Date: Wed, 3 Mar 2021 10:42:25 +0800 Message-Id: <20210303024225.2591-1-justin.he@arm.com> X-Mailer: git-send-email 2.17.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210303_024250_717324_116C5DF2 X-CRM114-Status: GOOD ( 10.53 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org If the start addr is not aligned with the granule size of that level. loop step size should be adjusted to boundary instead of simple kvm_granual_size(level) increment. Otherwise, some mmu entries might miss the chance to be walked through. E.g. Assume the unmap range [data->addr, data->end] is [0xff00ab2000,0xff00cb2000] in level 2 walking and NOT block mapping. And the 1st part of that pmd entry is [0xff00ab2000,0xff00c00000]. The pmd value is 0x83fbd2c1002 (not valid entry). In this case, data->addr should be adjusted to 0xff00c00000 instead of 0xff00cb2000. Without this fix, userspace "segment fault" error can be easily triggered by running simple gVisor runsc cases on an Ampere Altra server: docker run --runtime=runsc -it --rm ubuntu /bin/bash In container: for i in `seq 1 100`;do ls;done Reported-by: Howard Zhang Signed-off-by: Jia He --- arch/arm64/kvm/hyp/pgtable.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c index bdf8e55ed308..4d99d07c610c 100644 --- a/arch/arm64/kvm/hyp/pgtable.c +++ b/arch/arm64/kvm/hyp/pgtable.c @@ -225,6 +225,7 @@ static inline int __kvm_pgtable_visit(struct kvm_pgtable_walk_data *data, goto out; if (!table) { + data->addr = ALIGN_DOWN(data->addr, kvm_granule_size(level)); data->addr += kvm_granule_size(level); goto out; } -- 2.17.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel