From nobody Tue Oct 25 15:33:03 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4MxbYX14fmz4g6yS; Tue, 25 Oct 2022 15:33:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4MxbYX0XY0z43VT; Tue, 25 Oct 2022 15:33:04 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1666711984; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=6JWC2sxWjl2Bnkn7eQRSldqpRDSvWaU6H1TgkOPM42c=; b=NIV4wczciTSAw43xf6ilXqUiYjN9P6enJPoW2gsIDtA1hV3vdZcyF3iMZrUUkFrauiVzRr DJ5VgEYkfnAV4Y3L+UAmCvcYJ3V+4pm8AKU0X0t0ob0IZTBcw7D+Djb2iugKttRw+0pTWy urukdw7c9SHXtcOXssKvU6q/eE2O0XJVUkohOtWI3oxHr/09SfExVx5t0Bwdi6iZN4EfY0 RdZbhZvurW0mVr8VdOmnU6XFojGBsTuYniz4DQ3Y7aWzUIEuEuaN3CAjioeLVWmukJX4b1 JIGiO61ZuPjCvfZiDTZxTrsafYle+j2r2AD0qdmWcmTmjBRNMt3r4j0VXUVcbw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4MxbYW6N2mzjbZ; Tue, 25 Oct 2022 15:33:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 29PFX3Og051288; Tue, 25 Oct 2022 15:33:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 29PFX3Ld051287; Tue, 25 Oct 2022 15:33:03 GMT (envelope-from git) Date: Tue, 25 Oct 2022 15:33:03 GMT Message-Id: <202210251533.29PFX3Ld051287@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: ecb167daf761 - main - efi: Add linux memory reserve table defniitions List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ecb167daf761b75e71607e3b216e162cad99dad0 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1666711984; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=6JWC2sxWjl2Bnkn7eQRSldqpRDSvWaU6H1TgkOPM42c=; b=WHy4nbpOq9WGxmIZIhOJSj6pFUWEyK4QJzsin5DtEBmTknDVa4NtX8F0Tsii+ImI6TY2xp Mzk27KN7JT+NCuN9qoI02D99Hid5ZVgpUDS+aHtAOR3pWKrx+LtgUv5qwPaJRG8zGeOQ19 DheDuhAjifUFNjuYxKAbHsqHg81bZtVnPvFlZcBpVKjVPOEp8dGGoT+YsCUfzawhCT8Jug ZDy87EHcLaP93nYAGHoaJ4KiXRKQeWEgLBKP5Dw66nx7egB/WYGiVKE/zCr0CDizOeORoX kGs/Td0WrTRhK+eYk/XUo6v3jv0RlL5O4MOYu3bwhkWZD2tTXSoy04l3qkGY6g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1666711984; a=rsa-sha256; cv=none; b=dOMr+I6p2gSOPstqJ1U8aqPFbMi/XbLAdaL38Zz34DpfavYEPkP8VU3rey2DjkXMmenqo/ +Fxk2cytm1CFUB137ieotjqn742lzc/flQ4MFTtuBS7YBa6TUeX0mlche1JTEXRtZIfwt6 V96WFKzdzjBaGEhFzSVHlCQ3xR33pOQTwPh/moe00b9mS4r0ebi1IfQ5H+sSn2Qrhs06MG PFPM7meNXeOTALo51L6KOGsUGfkiglbZFJvS46M0BEFRQseuevOTGvmfkHBliejEP3p8lf gqUVA3eP9I34YyL/foiTb/jYdaEiBPbTkXBlvi2VGGLV7MDyjDBmNnsN8MyQgA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=ecb167daf761b75e71607e3b216e162cad99dad0 commit ecb167daf761b75e71607e3b216e162cad99dad0 Author: Warner Losh AuthorDate: 2022-10-06 02:56:43 +0000 Commit: Warner Losh CommitDate: 2022-10-25 15:32:49 +0000 efi: Add linux memory reserve table defniitions There is some hardware which can't be completely reset to release the memory it is using(so far only the GICv3 on arm has fit this bill). Since that meory needs to be reserved by the OS for that hardware's later use of it, create defines for code that will parse that memory table. Otherise the system may allocate the memory for block I/O, network packets, etc which will lead to memory corruption. When booting via Linux's kexec protocol, it will add this table to the EFI systbl's cfgtbl array. While the mechanism to pass 'configuration' is standardized, these specific tables are not documented except in the Linux source. Include comments gleened from its study. Sponsored by: Netflix --- sys/sys/efi.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/sys/sys/efi.h b/sys/sys/efi.h index f5dc15ae418f..4714dd137551 100644 --- a/sys/sys/efi.h +++ b/sys/sys/efi.h @@ -44,6 +44,8 @@ {0xb122a263,0x3661,0x4f68,0x99,0x29,{0x78,0xf8,0xb0,0xd6,0x21,0x80}} #define EFI_PROPERTIES_TABLE \ {0x880aaca3,0x4adc,0x4a04,0x90,0x79,{0xb7,0x47,0x34,0x08,0x25,0xe5}} +#define LINUX_EFI_MEMRESERVE_TABLE \ + {0x888eb0c6,0x8ede,0x4ff5,0xa8,0xf0,{0x9a,0xee,0x5c,0xb9,0x77,0xc2}} enum efi_reset { EFI_RESET_COLD = 0, @@ -201,6 +203,34 @@ struct efi_systbl { extern vm_paddr_t efi_systbl_phys; +/* + * When memory is reserved for some use, Linux will add a + * LINUX_EFI_MEMSERVE_TABLE to the cfgtbl array of tables to communicate + * this. At present, Linux only uses this as part of its workaround for a GICv3 + * issue where you can't stop the controller long enough to move it's config and + * pending vectors. When the LinuxBoot environment kexec's a new kernel, the new + * kernel needs to use this old memory (and not use it for any other purpose). + * + * Linux stores the PA of this table in the cfgtbl. And all the addresses are + * the physical address of 'reserved' memory. The mr_next field creates a linked + * list of these tables, and all must be walked. If mr_count is 0, that entry + * should be ignored. There is no checksum for these tables, nor do they have + * a efi_tblhdr. + * + * This table is only documented in the Linux code in drivers/firmware/efi/efi.c. + */ +struct linux_efi_memreserve_entry { + vm_offset_t mre_base; /* PA of reserved area */ + vm_offset_t mre_size; /* Size of area */ +}; + +struct linux_efi_memreserve { + uint32_t mr_size; /* Total size of table in bytes */ + uint32_t mr_count; /* Count of entries used */ + vm_offset_t mr_next; /* Next in chain (though unused?) */ + struct linux_efi_memreserve_entry mr_entry[]; +}; + struct efirt_callinfo; /* Internal MD EFI functions */