From nobody Fri Oct 11 17:31:43 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9B454C77B7C for ; Wed, 24 May 2023 16:06:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229476AbjEXQGo (ORCPT ); Wed, 24 May 2023 12:06:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230191AbjEXQGg (ORCPT ); Wed, 24 May 2023 12:06:36 -0400 Received: from esa5.hc3370-68.iphmx.com (esa5.hc3370-68.iphmx.com [216.71.155.168]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2DC6019C for ; Wed, 24 May 2023 09:06:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1684944378; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=tm65vq3RdyIRKBQDq/1y/ORB5HYwi09XnCHiE+t3B2o=; b=JbPF3tOrDbRd4hSGDsjSzW+WlmK6fqZ3ldBZLmCmirBUeyGwCvT2oyOX kRqWuTRvySyJDFrajdBzKFweIfrD1SJAzW2uWDhhp8aHK98cSOGpSFguC LQKUpgTsVvZeG3KNv5UsBptfv7yAUhF9BBcLolojuTQJy0Eg8GpG1vquz 4=; Authentication-Results: esa5.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 4.0 X-MesageID: 109010816 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.123 X-Policy: $RELAYED IronPort-Data: A9a23:ZJU7g65duXdmHzo6yR3dbwxRtHzAchMFZxGqfqrLsTDasY5as4F+v jccWGqBOfbbZmukKIgja4+0pElTusKEydY3SlZu/ng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ShnVRHAxH7xs5TZXa6h7b0Ea7w8dqQ9+epowJZcF qdVJ5XeXKQTEWqWoVzxiKURS6Q7LnyWaf+mZXL5MFDTgbY7L+A2xjMUVlS2r3RfZsZGncA/v 6ehxmvmfHb3fCw7VJy+QKv2nzuMUY01xLoas73gfoMCJy0BMeFCd0TMsxPAC51Qd0iYnWvGi m57w34w/IHwnmP8y/GR7YjskmtjO7AidqaGNwE3NYqLCBQ= IronPort-HdrOrdr: A9a23:o7Kw36o2R/qRvJjUU7PAEJUaV5oJeYIsimQD101hICG9E/bo8v xG+c5wuCMc5wx8ZJhNo7+90dC7MBThHP1OkOss1NWZPDUO0VHARL2Ki7GN/9SKIVycygcy78 Zdmp9FebnN5AhB5voSODPIaerIGuP3iJxAWN2uqUuFkTsaEJ2IMT0JdzpyfSVNNXB7OaY= X-Talos-CUID: =?us-ascii?q?9a23=3AqSPEPWn0YOBFKzhT5B2DEIZaQmvXOVTwwUbMOGq?= =?us-ascii?q?lMjtGcLGyVF6au59dqtU7zg=3D=3D?= X-Talos-MUID: 9a23:E7Tvtggk1lYhpJwDOK5m0MMpE/pl5vjpIVoxlNZFqeSPaTw3PSuyg2Hi X-IronPort-AV: E=Sophos;i="6.00,189,1681185600"; d="scan'208";a="109010816" From: Ross Lagerwall To: , CC: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , , Juergen Gross , Boris Ostrovsky , Peter Jones , "Konrad Rzeszutek Wilk" , Ross Lagerwall Subject: [PATCH] iscsi_ibft: Fix finding the iBFT under Xen Dom 0 Date: Wed, 24 May 2023 17:05:58 +0100 Message-ID: <20230524160558.3686226-1-ross.lagerwall@citrix.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Since firmware doesn't indicate the iBFT in the E820, add a reserved region so that it gets identity mapped when running as Dom 0 so that it is possible to search for it. Move the call to reserve_ibft_region() later so that it is called after the Xen identity mapping adjustments are applied. Finally, instead of using isa_bus_to_virt() which doesn't do the right thing under Xen, use early_memremap() like the dmi_scan code does. Signed-off-by: Ross Lagerwall --- It tested this to work under Xen and native Linux. arch/x86/kernel/setup.c | 2 +- arch/x86/xen/setup.c | 8 +++++++- drivers/firmware/iscsi_ibft_find.c | 24 +++++++++++++++++------- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index 16babff771bd..616b80507abd 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -796,7 +796,6 @@ static void __init early_reserve_memory(void) =20 memblock_x86_reserve_range_setup_data(); =20 - reserve_ibft_region(); reserve_bios_regions(); trim_snb_memory(); } @@ -1032,6 +1031,7 @@ void __init setup_arch(char **cmdline_p) if (efi_enabled(EFI_BOOT)) efi_init(); =20 + reserve_ibft_region(); dmi_setup(); =20 /* diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c index c2be3efb2ba0..daab59df3b99 100644 --- a/arch/x86/xen/setup.c +++ b/arch/x86/xen/setup.c @@ -772,8 +772,14 @@ char * __init xen_memory_setup(void) * UNUSABLE regions in domUs are not handled and will need * a patch in the future. */ - if (xen_initial_domain()) + if (xen_initial_domain()) { xen_ignore_unusable(); + /* Reserve 0.5 MiB to 1 MiB region so iBFT can be found */ + xen_e820_table.entries[xen_e820_table.nr_entries].addr =3D 0x80000; + xen_e820_table.entries[xen_e820_table.nr_entries].size =3D 0x80000; + xen_e820_table.entries[xen_e820_table.nr_entries].type =3D E820_TYPE_RES= ERVED; + xen_e820_table.nr_entries++; + } =20 /* Make sure the Xen-supplied memory map is well-ordered. */ e820__update_table(&xen_e820_table); diff --git a/drivers/firmware/iscsi_ibft_find.c b/drivers/firmware/iscsi_ib= ft_find.c index 94b49ccd23ac..e3c1449987dd 100644 --- a/drivers/firmware/iscsi_ibft_find.c +++ b/drivers/firmware/iscsi_ibft_find.c @@ -52,9 +52,9 @@ static const struct { */ void __init reserve_ibft_region(void) { - unsigned long pos; + unsigned long pos, virt_pos =3D 0; unsigned int len =3D 0; - void *virt; + void *virt =3D NULL; int i; =20 ibft_phys_addr =3D 0; @@ -70,13 +70,20 @@ void __init reserve_ibft_region(void) * so skip that area */ if (pos =3D=3D VGA_MEM) pos +=3D VGA_SIZE; - virt =3D isa_bus_to_virt(pos); + + /* Map page by page */ + if (offset_in_page(pos) =3D=3D 0) { + if (virt) + early_memunmap(virt, PAGE_SIZE); + virt =3D early_memremap_ro(pos, PAGE_SIZE); + virt_pos =3D pos; + } =20 for (i =3D 0; i < ARRAY_SIZE(ibft_signs); i++) { - if (memcmp(virt, ibft_signs[i].sign, IBFT_SIGN_LEN) =3D=3D - 0) { + if (memcmp(virt + (pos - virt_pos), ibft_signs[i].sign, + IBFT_SIGN_LEN) =3D=3D 0) { unsigned long *addr =3D - (unsigned long *)isa_bus_to_virt(pos + 4); + (unsigned long *)(virt + pos - virt_pos + 4); len =3D *addr; /* if the length of the table extends past 1M, * the table cannot be valid. */ @@ -84,9 +91,12 @@ void __init reserve_ibft_region(void) ibft_phys_addr =3D pos; memblock_reserve(ibft_phys_addr, PAGE_ALIGN(len)); pr_info("iBFT found at %pa.\n", &ibft_phys_addr); - return; + goto out; } } } } + +out: + early_memunmap(virt, PAGE_SIZE); } --=20 2.31.1