Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp633018rwn; Thu, 8 Sep 2022 06:49:07 -0700 (PDT) X-Google-Smtp-Source: AA6agR7+uMfr+2X7UM/cQrYuM1PuupQ/hJFi3a/GMThY3XNrPfe39WFGxSA7x5URKefYf+bsxIuX X-Received: by 2002:a63:6683:0:b0:42b:34a5:e66f with SMTP id a125-20020a636683000000b0042b34a5e66fmr8149629pgc.117.1662644946877; Thu, 08 Sep 2022 06:49:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662644946; cv=none; d=google.com; s=arc-20160816; b=kz0LRh09RmYD1UB5Aqd6B2hZ5yJgfjFjKLPhXfOUOFDXQwkUL1CEWL3BdrFMA8PYQU V+ce9Rq9HdJQKFBtKSmSj3Aqfoo8z6XjnEhySveLIwJjQTa+DDt+yAKkdL9c+9d+Tlj6 JlEF8F3Y8C9ADktinMABce1rzsJwoaEBGLcqOqDJjRSu+Ggc29rP1pkAneMHRRcPIoNO GLTZXnZFBGvR2E1vU6RqE1uhCBGjWKfuCdHq/3ELL7HXOAzAKNMAyl8upLS3yyvSWVbn F6jqVjhCWb24PLOd+rweKotvbUeLwn32zSpnMYcgwk4PR/xwgeL0tBZ1YPuJBCs2goo7 yTIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=p8ra/doBD+K8vNStbe/BYlPNiV+x3W54NSRkOdjgf40=; b=iP8RJOf2Eo9CIQHpsbhHmy/SkhK8cdU++9olX+ojkHWx9IzK1VmLKLtNPqJ8MDx1GW stSLwdHY06LFT7ixBOlTFqDf/hV8NLudvS8KpsSDbgrXkf8f24EROQyQBFBJu0kTRG1L luhnli553o/WxKB4+/0gZvgtKkuxG9YSjypyHTyhUDS3PFPu51od7oEyojcVRx5yAwLw kCN3NuK/Mdld9IujzzDqnylqsmBIyE9ezTqi4/lbPxnEgW5qKgJj7sjq6tktolgM4zNm bRrR/RDMyaJ7618aYbK5zH4FfzuPrxyHNuD6buXvDwxWqL3ES9Kfxv3Y44/SpYCqOEMw zaOw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qe6-20020a17090b4f8600b001f303395c8esi108689pjb.141.2022.09.08.06.48.54; Thu, 08 Sep 2022 06:49:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230476AbiIHNJ2 (ORCPT + 99 others); Thu, 8 Sep 2022 09:09:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231189AbiIHNJY (ORCPT ); Thu, 8 Sep 2022 09:09:24 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94F8FB959D for ; Thu, 8 Sep 2022 06:09:19 -0700 (PDT) Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.53]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4MNfVv31CBz14QPc; Thu, 8 Sep 2022 21:05:27 +0800 (CST) Received: from kwepemm600007.china.huawei.com (7.193.23.208) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 8 Sep 2022 21:09:17 +0800 Received: from DESKTOP-8RFUVS3.china.huawei.com (10.174.185.179) by kwepemm600007.china.huawei.com (7.193.23.208) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 8 Sep 2022 21:09:15 +0800 From: Zenghui Yu To: , , CC: , , , , , , , , Zenghui Yu Subject: [PATCH] KVM: arm64: Use kmemleak_free_part_phys() to unregister hyp_mem_base Date: Thu, 8 Sep 2022 21:06:59 +0800 Message-ID: <20220908130659.2021-1-yuzenghui@huawei.com> X-Mailer: git-send-email 2.23.0.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.174.185.179] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemm600007.china.huawei.com (7.193.23.208) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org With commit 0c24e061196c ("mm: kmemleak: add rbtree and store physical address for objects allocated with PA"), kmemleak started to put the objects allocated with physical address onto object_phys_tree_root tree. The kmemleak_free_part() therefore no longer worked as expected on physically allocated objects (hyp_mem_base in this case) as it attempted to search and remove things in object_tree_root tree. Fix it by using kmemleak_free_part_phys() to unregister hyp_mem_base. This fixes an immediate crash when booting a KVM host in protected mode with kmemleak enabled. Signed-off-by: Zenghui Yu --- arch/arm64/kvm/arm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index 09e726711631..951070c4831d 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -2114,7 +2114,7 @@ static int finalize_hyp_mode(void) * at, which would end badly once inaccessible. */ kmemleak_free_part(__hyp_bss_start, __hyp_bss_end - __hyp_bss_start); - kmemleak_free_part(__va(hyp_mem_base), hyp_mem_size); + kmemleak_free_part_phys(hyp_mem_base, hyp_mem_size); return pkvm_drop_host_privileges(); } -- 2.33.0