Received: by 2002:a5d:925a:0:0:0:0:0 with SMTP id e26csp283710iol; Thu, 9 Jun 2022 03:57:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxLNoOkdMlv2D/y94HG+EO2ga3HT50nr54EzGuLk9uss2eQ6fSg4fwi6oF5VsmJxBpkJJAD X-Received: by 2002:a17:902:b090:b0:167:7ae5:e13b with SMTP id p16-20020a170902b09000b001677ae5e13bmr20647074plr.170.1654772244894; Thu, 09 Jun 2022 03:57:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654772244; cv=none; d=google.com; s=arc-20160816; b=Sa9Kvp0HNose+rQCS/1U0j1Q0gF9IjLwqvND+kE1q6XwlB3dAQFuKQt86/+Pz8avJO IlwgvrM+CKS3lFuj921YIWTIN5XBxtKZMnsqcSKTs7trP219nU6COCAELPcUcvkWr6gg NdR/Pzd73/hLjIYc3ZuIqOWZNBtEZY806JL+l6bHwbVv03yIA7jp4SOPZJ42d1R6QOIy LUnB/JaVbPam2FhhSDdmRKHpiK53Zu7GlDdyPZ3XiLA65tam2YU2WImBEkr88K++O+tq 1F7NAvqPoWz7gNa07HU2xLFD2qhMnJHQCJbf6s3kf9m3KzJQLRfnJEpzg+rzbpF8Lvks Ukow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=rRNr5XYZfOxem3tYBkmgRxtT15D8rmuqmOTTo7DAEhA=; b=gpA6jiNfm5F3WGPQnHXwUlMyYrRIdfdNSiBV3cpySNVEWGqZqP11x30NCqrd0gtERf Erw3bIqSNZmDkjF30mUsAEbBqzbu6xJ8Y/zQ6EBXivB4Gr/qg9DvKgQaxA3B/s4+5mIJ 2lKVbuM2dGEUU/iU7p6ooqPYMQyEzxlx2kwJm0xWLcisKgrsTwbCvZgiMgN3fZdNDAp7 4C/DOK4h2R/bIeT9n/P65iP+Z+VloE7Dh7u/l/OXXuQ6DJNY6pQWcCEzQAUJcxcrRtGG Wsf/A9Sk00rYZbVxcZyq65O7rffmCjioiFDDXodXBe7+D9r43Ad72DmMT771ZocuPfYB AjYQ== 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=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a16-20020a170902ecd000b0015cb564e4d5si36570529plh.242.2022.06.09.03.57.09; Thu, 09 Jun 2022 03:57:24 -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=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241156AbiFIK0I (ORCPT + 99 others); Thu, 9 Jun 2022 06:26:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233741AbiFIK0G (ORCPT ); Thu, 9 Jun 2022 06:26:06 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CFFD312D140; Thu, 9 Jun 2022 03:26:04 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 8D46BB82C86; Thu, 9 Jun 2022 10:26:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0D37CC34114; Thu, 9 Jun 2022 10:25:58 +0000 (UTC) Date: Thu, 9 Jun 2022 11:25:55 +0100 From: Catalin Marinas To: Will Deacon Cc: Kefeng Wang , Vasily Averin , Naresh Kamboju , Shakeel Butt , Linux ARM , Stephen Rothwell , Linux-Next Mailing List , open list , regressions@lists.linux.dev, lkft-triage@lists.linaro.org, linux-mm , Andrew Morton , Ard Biesheuvel , Arnd Bergmann , Raghuram Thammiraju , Mark Brown , Roman Gushchin , Qian Cai Subject: Re: [next] arm64: boot failed - next-20220606 Message-ID: References: <20220607162504.7fd5a92a@canb.auug.org.au> <2a4cc632-c936-1e42-4fdc-572334c58ee1@openvz.org> <44530040-0384-796e-143f-b7293886753c@huawei.com> <20220609101153.GB2187@willie-the-truck> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220609101153.GB2187@willie-the-truck> X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 On Thu, Jun 09, 2022 at 11:11:54AM +0100, Will Deacon wrote: > On Thu, Jun 09, 2022 at 11:44:09AM +0800, Kefeng Wang wrote: > > On 2022/6/9 10:49, Vasily Averin wrote: > > > mem_cgroup_from_obj(): > > > ffff80000836cf40: d503245f bti c > > > ffff80000836cf44: d503201f nop > > > ffff80000836cf48: d503201f nop > > > ffff80000836cf4c: d503233f paciasp > > > ffff80000836cf50: d503201f nop > > > ffff80000836cf54: d2e00021 mov x1, #0x1000000000000 // #281474976710656 > > > ffff80000836cf58: 8b010001 add x1, x0, x1 > > > ffff80000836cf5c: b25657e4 mov x4, #0xfffffc0000000000 // #-4398046511104 > > > ffff80000836cf60: d34cfc21 lsr x1, x1, #12 > > > ffff80000836cf64: d37ae421 lsl x1, x1, #6 > > > ffff80000836cf68: 8b040022 add x2, x1, x4 > > > ffff80000836cf6c: f9400443 ldr x3, [x2, #8] > > > > > > x5 : ffff80000a96f000 x4 : fffffc0000000000 x3 : ffff80000ad5e680 > > > x2 : fffffe00002bc240 x1 : 00000200002bc240 x0 : ffff80000af09740 > > > > > > x0 = 0xffff80000af09740 is an argument of mem_cgroup_from_obj() > > > according to System.map it is init_net > > > > > > This issue is caused by calling virt_to_page() on address of static variable init_net. > > > Arm64 consider that addresses of static variables are not valid virtual addresses. > > > On x86_64 the same API works without any problem. > > This just depends on whether or not the kernel is running out of the linear > mapping or not. On arm64, we use the vmalloc area for the kernel image and > so virt_to_page() won't work, just like it won't work for modules on other > architectures. > > How are module addresses handled by mem_cgroup_from_obj()? It doesn't look like they are handled in any way. It just expects the pointer to be a linear map one. Something like below: diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 27cebaa53472..795bf3673fa7 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -2860,6 +2860,11 @@ struct mem_cgroup *mem_cgroup_from_obj(void *p) if (mem_cgroup_disabled()) return NULL; + if (is_module_address((unsigned long)p)) + return NULL; + else if (is_kernel((unsigned long)p)) + return NULL; + folio = virt_to_folio(p); /* -- Catalin