From nobody Wed May 15 10:24:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1695706457; cv=none; d=zohomail.com; s=zohoarc; b=IC1glh9dZhxG7awhv/7vN8G02SfRPOPbek9dLbvjCRvE2iwMKeBpxd8uP4JOr54kpNN/OYjSoBqzs+JoalEIonSGl0YAzTXUNu1SkCdH9eMvvPvGEktBVPPBsj6C3CUO5r70E2hZXVyWzVSprGPZOou5hdBpIXN0FCAGBAwIPA0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695706457; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=g3M7ToDVJ5VYoL9D1uZMV9wLB8oef6j3CycvzdRrAB0=; b=eoXJkll21F185U/ZhzDKmre6cTyAdv0K3Rdi82sJRXETcCkT5+koyKqjBGMhAdwb24VSif3uNcQhXfPy+GAvrtbcMLLQmEHYI6ILVuoJTqfDqi+irOcdVV0zuB+HDnAeUGQzNWMkfU4+rUEBpBtF1gwCUghKROOAYh+EeUW/Qlo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1695706457869278.569377066112; Mon, 25 Sep 2023 22:34:17 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.608273.946632 (Exim 4.92) (envelope-from ) id 1ql0hi-0006mK-3p; Tue, 26 Sep 2023 05:33:50 +0000 Received: by outflank-mailman (output) from mailman id 608273.946632; Tue, 26 Sep 2023 05:33:50 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ql0hi-0006lu-11; Tue, 26 Sep 2023 05:33:50 +0000 Received: by outflank-mailman (input) for mailman id 608273; Tue, 26 Sep 2023 05:33:49 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ql0hh-0006lo-1E for xen-devel@lists.xenproject.org; Tue, 26 Sep 2023 05:33:49 +0000 Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [2607:f8b0:4864:20::52e]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 43b17470-5c2e-11ee-878a-cb3800f73035; Tue, 26 Sep 2023 07:33:48 +0200 (CEST) Received: by mail-pg1-x52e.google.com with SMTP id 41be03b00d2f7-578e33b6fb7so5125386a12.3 for ; Mon, 25 Sep 2023 22:33:48 -0700 (PDT) Received: from leoy-yangtze.lan ([128.1.74.161]) by smtp.gmail.com with ESMTPSA id a13-20020a17090a8c0d00b002633fa95ac2sm10737988pjo.13.2023.09.25.22.33.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 22:33:45 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 43b17470-5c2e-11ee-878a-cb3800f73035 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1695706426; x=1696311226; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=g3M7ToDVJ5VYoL9D1uZMV9wLB8oef6j3CycvzdRrAB0=; b=D2UZvbgWL7faEk+c+z9UlrXNnBIghGuYPLcuitSWQkDkGDVoYtnTvpGi0Ap1SXbE5S olb4hI0r+U8ysKsiq/ID1O7/HHFRj1Io4SzuTf/5s1h4dPr7pEcZ7bKBWFrDieCxixI9 X/WVgJUGK/uCOPeMSFmz2Jym63gF7uB/qjHeIbKpngcdwBpFhcTsnB7aXFSmTgmJThyA ugPqN+Nauy33DxJA9t3G3qkrtr46hQdqI0RODnn6BXt1qoaluODfBBP/OlS1g5Eg+oZx C0l/Eiz6DaK52nzn2Rkfrio1R7HKjLDaMbb98eOgh8q3SvTRO84oRWmr3i9eF3ebC30F Sltg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695706426; x=1696311226; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=g3M7ToDVJ5VYoL9D1uZMV9wLB8oef6j3CycvzdRrAB0=; b=hxzQ/aNCklhf2WMR4665YyuVCdqKDCYPCPRMtjLygdaLBHAkWsysOcjugW/fQcJUOn x/mDrNHgddXge0475MMIcbTxZpnDJqV+7luqw4612ANyqRVM7gp3FoL5Tl5VJyyT94KR DDfaauUDvBkNGfpGrft3gMU8Esu/1Rx/DtnSn7KU2dGs0NszsW1ELjU4uSmiwErUSeZx nySAXa67DY3S4nBaNUfzu3LHCOTrRqVDqFazSH1QJPR+gS1Dm6a2jAFJ8/aOiEmoZXph qN4k743F0FoAJqNA2cyI9IC+pymsi/nLYCkS3hMo5BkW0MvChjsBgZFa/wwyxObOgJvF U2yQ== X-Gm-Message-State: AOJu0Yz1hrwwSj404owC3whEDIghJUBJ1zvqjEqIgXzxCcv0JkYpMvYE O2O39eLpaMoWwhq6/UqLaSfihcp4Ro7eU2/NXPazL3qS X-Google-Smtp-Source: AGHT+IH639S5nEscI5IDBimvYY1HIwZMv0vrV2Bh8N2fmTNs5vHmmiFP30j9D0xE08WM963twdQAYA== X-Received: by 2002:a17:90a:ba95:b0:277:37fc:6e89 with SMTP id t21-20020a17090aba9500b0027737fc6e89mr4776700pjr.0.1695706426207; Mon, 25 Sep 2023 22:33:46 -0700 (PDT) From: Leo Yan To: xen-devel@lists.xenproject.org Cc: Stefano Stabellini , Julien Grall , Bertrand Marquis , Volodymyr Babchuk , Leo Yan Subject: [PATCH] xen/arm: Skip memory nodes if not enabled Date: Tue, 26 Sep 2023 13:33:33 +0800 Message-Id: <20230926053333.180811-1-leo.yan@linaro.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1695706460083100001 Content-Type: text/plain; charset="utf-8" During the Linux kernel booting, an error is reported by the Xen hypervisor: (XEN) arch/arm/p2m.c:2202: d0v0: Failing to acquire the MFN 0x1a02dc The kernel attempts to use an invalid memory frame number, which can be converted to: 0x1a02dc << PAGE_SHIFT, resulting in 0x1_a02d_c000. The invalid memory frame falls into a reserved memory node, which is defined in the device tree as below: reserved-memory { #address-cells =3D <0x02>; #size-cells =3D <0x02>; ranges; ... ethosn_reserved { compatible =3D "shared-dma-pool"; reg =3D <0x01 0xa0000000 0x00 0x20000000>; status =3D "disabled"; no-map; }; ... }; Xen excludes all reserved memory regions from the frame management through the dt_unreserved_regions() function. On the other hand, the reserved memory nodes are passed to the Linux kernel. However, the Linux kernel ignores the 'ethosn_reserved' node since its status is "disabled". This leads to the Linux kernel to allocate pages from the reserved memory range. As a result, when the kernel passes the data structure residing in the frame 0x1_a02d_c000 in the Xen hypervisor, the hypervisor detects that it misses to manage the frame and reports the error. Essentially, this issue is caused by the Xen hypervisor which misses to handle the status for the memory nodes (for both the normal memory nodes and the reserved memory nodes) and transfers them to the Linux kernel. This patch introduces a function memory_node_is_available(). If it detects a memory node is not enabled, the hypervisor will not add the memory region into the memory lists. In the end, this avoids to generate the memory nodes from the memory lists sent to the kernel and the kernel cannot use the disabled memory nodes any longer. Signed-off-by: Leo Yan --- xen/arch/arm/bootfdt.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/xen/arch/arm/bootfdt.c b/xen/arch/arm/bootfdt.c index 2673ad17a1..b46dde06a9 100644 --- a/xen/arch/arm/bootfdt.c +++ b/xen/arch/arm/bootfdt.c @@ -206,11 +206,27 @@ int __init device_tree_for_each_node(const void *fdt,= int node, return 0; } =20 +static bool __init memory_node_is_available(const void *fdt, unsigned long= node) +{ + const char *status =3D fdt_getprop(fdt, node, "status", NULL); + + if (!status) + return true; + + if (!strcmp(status, "ok") || !strcmp(status, "okay")) + return true; + + return false; +} + static int __init process_memory_node(const void *fdt, int node, const char *name, int depth, u32 address_cells, u32 size_cells, void *data) { + if (!memory_node_is_available(fdt, node)) + return 0; + return device_tree_get_meminfo(fdt, node, "reg", address_cells, size_c= ells, data, MEMBANK_DEFAULT); } --=20 2.39.2