diff --git a/drivers/gpu/drm/asahi/Kconfig b/drivers/gpu/drm/asahi/Kconfig index 0e41582573a3e2..ec2a588054e229 100644 --- a/drivers/gpu/drm/asahi/Kconfig +++ b/drivers/gpu/drm/asahi/Kconfig @@ -36,11 +36,20 @@ config DRM_ASAHI_DEBUG_ALLOCATOR Say N unless you are debugging firmware structures or porting to a new firmware version. +config DRM_ASAHI_UAT_ADOPTION + bool + help + The firmware UAT handoff adoption shared by the G15 backend and the + T8122 runtime (g15/uat.rs, g15/regs.rs). + config DRM_ASAHI_M3_T8122 bool "M3 MacBook Air GPU runtime (T8122, 14.8.3 firmware)" depends on DRM_ASAHI - # The runtime adopts the firmware's UAT through the G15 backend's handoff helpers. - depends on DRM_ASAHI_G15 + # The runtime adopts the firmware's UAT as the G15 backend does, without + # needing that backend: M3 Pro/Max keep their own setting. + # Its PMP votes call apple-pmp directly (m3_device.rs). + depends on APPLE_PMP=y || (APPLE_PMP=m && DRM_ASAHI=m) + select DRM_ASAHI_UAT_ADOPTION select APPLE_T8122_GPU_PMP_LINK select CRYPTO_LIB_SHA256 default n @@ -59,6 +68,7 @@ config DRM_ASAHI_G15 select APPLE_T6030_GPU_PMP_LINK select CRYPTO_LIB_SHA256 select RUST_FW_LOADER_ABSTRACTIONS + select DRM_ASAHI_UAT_ADOPTION default n help Enable the native G15 backend for explicitly admitted M3 Pro/Max diff --git a/drivers/gpu/drm/asahi/Makefile b/drivers/gpu/drm/asahi/Makefile index e1987914e0956e..6a5783c4c54da8 100644 --- a/drivers/gpu/drm/asahi/Makefile +++ b/drivers/gpu/drm/asahi/Makefile @@ -4,3 +4,4 @@ obj-$(CONFIG_DRM_ASAHI) += asahi.o asahi-y := asahi_core.o sysfs.o asahi-$(CONFIG_DRM_ASAHI_G15) += g15/glue.o +asahi-$(CONFIG_DRM_ASAHI_UAT_ADOPTION) += g15/uat_glue.o diff --git a/drivers/gpu/drm/asahi/asahi_core.rs b/drivers/gpu/drm/asahi/asahi_core.rs index a55322d50ad236..0fbe6e728773d3 100644 --- a/drivers/gpu/drm/asahi/asahi_core.rs +++ b/drivers/gpu/drm/asahi/asahi_core.rs @@ -17,6 +17,10 @@ mod gem; mod g17; #[cfg(CONFIG_DRM_ASAHI_G15)] mod g15; +// Without the G15 backend, only the UAT adoption the T8122 runtime shares with it. +#[cfg(all(CONFIG_DRM_ASAHI_UAT_ADOPTION, not(CONFIG_DRM_ASAHI_G15)))] +#[path = "g15/adopt.rs"] +mod g15; mod gpu; mod hw; mod initdata; diff --git a/drivers/gpu/drm/asahi/g15/adopt.rs b/drivers/gpu/drm/asahi/g15/adopt.rs new file mode 100644 index 00000000000000..5dd54b04aaec6b --- /dev/null +++ b/drivers/gpu/drm/asahi/g15/adopt.rs @@ -0,0 +1,32 @@ +// SPDX-License-Identifier: GPL-2.0-only OR MIT + +//! Without the G15 backend (`CONFIG_DRM_ASAHI_G15=n`), the parts of it the T8122 runtime uses to +//! adopt the firmware's UAT: the handoff window ([`uat`]), its mappings ([`regs`]) and the +//! hardware constants they name ([`hw`]). Nothing here probes a device. + +// Only the adoption is used; the rest of these files serves the G15 backend. +#![allow(dead_code)] + +// hw.rs's `t6031` submodule is cfg-gated on G15; were it built here, a #[path]-loaded file +// would look for it at g15/t6031.rs, not g15/hw/t6031.rs. +#[path = "hw.rs"] +pub(crate) mod hw; +#[path = "regs.rs"] +pub(crate) mod regs; +#[path = "uat.rs"] +pub(crate) mod uat; + +use kernel::prelude::*; + +extern "C" { + fn asahi_g15_memory_mode(start: u64, size: u64) -> u32; +} + +/// WB for complete reserved RAM, WC for aligned non-RAM carveouts; reject everything else. +pub(crate) fn memory_mode(start: u64, size: u64) -> Result { + // SAFETY: Only queries resources and page metadata; it does not create a mapping. + match unsafe { asahi_g15_memory_mode(start, size) } { + 0 => Err(EINVAL), + mode => Ok(mode), + } +} diff --git a/drivers/gpu/drm/asahi/g15/glue.c b/drivers/gpu/drm/asahi/g15/glue.c index 5ceb20cd35d4b8..69c2a77057780d 100644 --- a/drivers/gpu/drm/asahi/g15/glue.c +++ b/drivers/gpu/drm/asahi/g15/glue.c @@ -30,9 +30,6 @@ void asahi_g15_module_get(void); void asahi_g15_reprobe(void); void asahi_g15_report_loader_gpu(void); int asahi_g15_adt_phram(u64 *start, u64 *size); -bool asahi_g15_ram_disjoint(u64 start, u64 size); -bool asahi_g15_ram_within(u64 start, u64 size); -unsigned int asahi_g15_memory_mode(u64 start, u64 size); void __iomem *asahi_g15_ioremap_wc(u64 start, size_t size); bool asahi_g15_dma_coherent(struct device *dev); int asahi_g15_pmp_prepare(struct device *dev); @@ -237,13 +234,6 @@ int asahi_g15_adt_phram(u64 *start, u64 *size) return 0; } -/* The range is disjoint from System RAM (ADT region admission). */ -bool asahi_g15_ram_disjoint(u64 start, u64 size) -{ - return region_intersects(start, size, IORESOURCE_SYSTEM_RAM, IORES_DESC_NONE) == - REGION_DISJOINT; -} - /* * Whether DMA mappings of the device skip cache maintenance. The G15 firmware * objects rely on the DMA mapping cleaning their pages to the point of @@ -254,42 +244,6 @@ bool asahi_g15_dma_coherent(struct device *dev) return dev_is_dma_coherent(dev); } -/* - * Every page must be valid, System RAM and still reserved from the allocator. - * REGION_INTERSECTS alone also accepts RAM mixed with undefined memory holes. - */ -bool asahi_g15_ram_within(u64 start, u64 size) -{ - u64 end, pa; - - if (!size || !IS_ALIGNED(start, PAGE_SIZE) || - !IS_ALIGNED(size, PAGE_SIZE) || check_add_overflow(start, size, &end)) - return false; - for (pa = start; pa < end; pa += PAGE_SIZE) { - unsigned long pfn = PHYS_PFN(pa); - - if (!pfn_valid(pfn) || !page_is_ram(pfn) || - !PageReserved(pfn_to_page(pfn))) - return false; - } - return true; -} - -/* One classification for every adopted-UAT and firmware-region CPU mapping. */ -unsigned int asahi_g15_memory_mode(u64 start, u64 size) -{ - u64 end; - - if (!size || !IS_ALIGNED(start, PAGE_SIZE) || - !IS_ALIGNED(size, PAGE_SIZE) || check_add_overflow(start, size, &end)) - return 0; - if (asahi_g15_ram_within(start, size)) - return MEMREMAP_WB; - if (asahi_g15_ram_disjoint(start, size)) - return MEMREMAP_WC; - return 0; -} - /* The inherited RTKit buffer inside firmware DATA. */ void __iomem *asahi_g15_ioremap_wc(u64 start, size_t size) { diff --git a/drivers/gpu/drm/asahi/g15/hw.rs b/drivers/gpu/drm/asahi/g15/hw.rs index c7f21a9110cee8..24ff3628eca811 100644 --- a/drivers/gpu/drm/asahi/g15/hw.rs +++ b/drivers/gpu/drm/asahi/g15/hw.rs @@ -7,6 +7,7 @@ use core::ops::Range; +#[cfg(CONFIG_DRM_ASAHI_G15)] pub(crate) mod t6031; /// Identification register values of a qualified G15S. @@ -94,6 +95,7 @@ pub(crate) struct ComputeRegs { } /// The T6030 configuration. +#[cfg(CONFIG_DRM_ASAHI_G15)] pub(crate) mod t6030 { use super::super::Config; use super::{ComputeRegs, FirmwareBuild, HwId, Layout}; diff --git a/drivers/gpu/drm/asahi/g15/regs.rs b/drivers/gpu/drm/asahi/g15/regs.rs index 05a1b390b3dffc..98e7d4c8cf78a4 100644 --- a/drivers/gpu/drm/asahi/g15/regs.rs +++ b/drivers/gpu/drm/asahi/g15/regs.rs @@ -125,7 +125,7 @@ impl Mapping { if size == 0 { return Err(EINVAL); } - let mode = super::boot::glue::memory_mode(phys, size as u64)?; + let mode = super::memory_mode(phys, size as u64)?; if mode == bindings::MEMREMAP_WC as u32 { return Self::write_combined(phys, size); } @@ -252,6 +252,7 @@ impl Regs { /// Reads the identification words and the enabled-core mask (once the GPU is powered). A /// SoC with more than 32 core slots carries the mask in two words. + #[cfg(CONFIG_DRM_ASAHI_G15)] pub(crate) fn identity(&self, cfg: &super::Config) -> Result { let version = self.sgx.io().try_read32(SGX_ID)?; let counts = self.sgx.io().try_read32(SGX_ID + 0x10)?; diff --git a/drivers/gpu/drm/asahi/g15/uat.rs b/drivers/gpu/drm/asahi/g15/uat.rs index 3855bd0beb9cb6..7ab3a1919eaecc 100644 --- a/drivers/gpu/drm/asahi/g15/uat.rs +++ b/drivers/gpu/drm/asahi/g15/uat.rs @@ -36,12 +36,14 @@ use kernel::{ bindings, device, io::Io, prelude::*, - sync::Arc, time::{delay::fsleep, Delta, Instant, Monotonic}, }; +#[cfg(CONFIG_DRM_ASAHI_G15)] +use kernel::sync::Arc; use super::hw; use super::regs::{mb, rmb, wmb, Mapping}; +#[cfg(CONFIG_DRM_ASAHI_G15)] use crate::driver::AsahiDrmDevice as AsahiDevice; use crate::{mmu, pgtable}; @@ -67,6 +69,7 @@ const fn indices(va: u64) -> [usize; 3] { } /// Creates the adopted UAT over the ADT regions (step 2 above). +#[cfg(CONFIG_DRM_ASAHI_G15)] pub(crate) fn adopt( dev: &AsahiDevice, cfg: &'static super::Config, @@ -199,6 +202,7 @@ pub(crate) struct Window { impl Window { /// Maps the UAT handoff regions ([`Mapping::region`]). + #[cfg(CONFIG_DRM_ASAHI_G15)] pub(crate) fn new(adt: &super::adt::GpuAdt) -> Result { Self::from_regions(adt.handoff.start, adt.ttbs.start, adt.tables.start, adt.shared_l2.start) } diff --git a/drivers/gpu/drm/asahi/g15/uat_glue.c b/drivers/gpu/drm/asahi/g15/uat_glue.c new file mode 100644 index 00000000000000..134ff4bb28ab6b --- /dev/null +++ b/drivers/gpu/drm/asahi/g15/uat_glue.c @@ -0,0 +1,59 @@ +// SPDX-License-Identifier: GPL-2.0-only OR MIT +/* + * C helpers of the UAT adoption (g15/uat.rs, g15/regs.rs), built for the G15 + * backend and for the T8122 runtime, which adopts the firmware's UAT the same + * way (CONFIG_DRM_ASAHI_UAT_ADOPTION). + */ +#include +#include +#include +#include +#include +#include + +bool asahi_g15_ram_disjoint(u64 start, u64 size); +bool asahi_g15_ram_within(u64 start, u64 size); +unsigned int asahi_g15_memory_mode(u64 start, u64 size); + +/* The range is disjoint from System RAM (ADT region admission). */ +bool asahi_g15_ram_disjoint(u64 start, u64 size) +{ + return region_intersects(start, size, IORESOURCE_SYSTEM_RAM, IORES_DESC_NONE) == + REGION_DISJOINT; +} + +/* + * Every page must be valid, System RAM and still reserved from the allocator. + * REGION_INTERSECTS alone also accepts RAM mixed with undefined memory holes. + */ +bool asahi_g15_ram_within(u64 start, u64 size) +{ + u64 end, pa; + + if (!size || !IS_ALIGNED(start, PAGE_SIZE) || + !IS_ALIGNED(size, PAGE_SIZE) || check_add_overflow(start, size, &end)) + return false; + for (pa = start; pa < end; pa += PAGE_SIZE) { + unsigned long pfn = PHYS_PFN(pa); + + if (!pfn_valid(pfn) || !page_is_ram(pfn) || + !PageReserved(pfn_to_page(pfn))) + return false; + } + return true; +} + +/* One classification for every adopted-UAT and firmware-region CPU mapping. */ +unsigned int asahi_g15_memory_mode(u64 start, u64 size) +{ + u64 end; + + if (!size || !IS_ALIGNED(start, PAGE_SIZE) || + !IS_ALIGNED(size, PAGE_SIZE) || check_add_overflow(start, size, &end)) + return 0; + if (asahi_g15_ram_within(start, size)) + return MEMREMAP_WB; + if (asahi_g15_ram_disjoint(start, size)) + return MEMREMAP_WC; + return 0; +} diff --git a/drivers/gpu/drm/asahi/mmu.rs b/drivers/gpu/drm/asahi/mmu.rs index dc828a460202d5..7717f01d8ee5d0 100644 --- a/drivers/gpu/drm/asahi/mmu.rs +++ b/drivers/gpu/drm/asahi/mmu.rs @@ -1477,7 +1477,7 @@ unsafe impl Send for UatShared {} #[pin_data] struct UatInner { firmware: UatFirmware, - #[cfg(CONFIG_DRM_ASAHI_G15)] + #[cfg(CONFIG_DRM_ASAHI_UAT_ADOPTION)] clean_poc: bool, #[pin] shared: Mutex, @@ -1665,7 +1665,7 @@ impl Vm { UatPageTable::new(geometry.ias, geometry.oas)? }; - #[cfg(CONFIG_DRM_ASAHI_G15)] + #[cfg(CONFIG_DRM_ASAHI_UAT_ADOPTION)] let page_table = { let mut page_table = page_table; if uat_inner.clean_poc { @@ -1753,7 +1753,7 @@ impl Vm { /// Attach a status and job lifetime tracking before sharing a newly created user VM with /// queues, without the G17 canonical context views, shared-object footprints and idle /// residency reclaim of [`Self::with_status`]. Used by G15, whose user objects stay pinned. - #[cfg(CONFIG_DRM_ASAHI_G15)] + #[cfg(CONFIG_DRM_ASAHI_UAT_ADOPTION)] pub(crate) fn with_tracked_status(mut self) -> Result { self.status = Some(Arc::pin_init(crate::g17::status::VmStatus::new(), GFP_KERNEL)?); self.lifetime = Some(lifetime::VmLifetime::new()?); @@ -1761,7 +1761,7 @@ impl Vm { } /// The identifier this VM was created with (G15 keeps per-VM state keyed by it). - #[cfg(CONFIG_DRM_ASAHI_G15)] + #[cfg(CONFIG_DRM_ASAHI_UAT_ADOPTION)] pub(crate) fn id(&self) -> u64 { self.id } @@ -1773,7 +1773,7 @@ impl Vm { /// and invalidated to the point of coherency first (never only invalidated: CPU-written lines /// may be dirty), so the copy sees what the GPU or a write-combined CPU view stored. The /// mappings cannot change during the copy (GPUVM exec lock). - #[cfg(CONFIG_DRM_ASAHI_G15)] + #[cfg(CONFIG_DRM_ASAHI_UAT_ADOPTION)] pub(crate) fn read_user(&self, va: u64, buf: &mut [u8]) -> Result { let mut inner = lock_vm(&self.gpuvm, None, false)?; let mut done = 0usize; @@ -2420,7 +2420,7 @@ impl Drop for VmInner { /// Physical regions of a UAT whose handoff the generation has already established itself /// ([`Uat::new_adopted`]). None of them needs to be in the kernel linear map. -#[cfg(CONFIG_DRM_ASAHI_G15)] +#[cfg(CONFIG_DRM_ASAHI_UAT_ADOPTION)] pub(crate) struct AdoptedRegions { /// The handoff region (PPL magic, lock and flush requests). pub(crate) handoff: Range, @@ -2431,7 +2431,7 @@ pub(crate) struct AdoptedRegions { } impl Uat { - #[cfg(CONFIG_DRM_ASAHI_G15)] + #[cfg(CONFIG_DRM_ASAHI_UAT_ADOPTION)] /// Map a region given by its physical range, write-combined. fn map_physical(range: &Range, min_size: usize) -> Result { let size: usize = (range.end.checked_sub(range.start).ok_or(EINVAL)?).try_into()?; @@ -2466,7 +2466,7 @@ impl Uat { }) } - #[cfg(CONFIG_DRM_ASAHI_G15)] + #[cfg(CONFIG_DRM_ASAHI_UAT_ADOPTION)] /// Creates a `Uat` for a handoff that the caller establishes itself (G15). /// /// This only maps the handoff and the TTBAT (write-combined); neither is written here. The @@ -2548,13 +2548,13 @@ impl Uat { }) } - #[cfg(CONFIG_DRM_ASAHI_G15)] + #[cfg(CONFIG_DRM_ASAHI_UAT_ADOPTION)] /// Root of the kernel lower `Vm`, for TTBAT context 0 of an adopted handoff. pub(crate) fn kernel_lower_root(&self) -> PhysicalAddr { self.kernel_lower_vm.ttb() } - #[cfg(CONFIG_DRM_ASAHI_G15)] + #[cfg(CONFIG_DRM_ASAHI_UAT_ADOPTION)] /// Root whose driver-window entry names the second-level table of [`Self::kernel_vm`]'s /// driver window. With [`Self::new_adopted`] this is the shadow root that no context names. pub(crate) fn kernel_window_root(&self) -> PhysicalAddr { @@ -2900,7 +2900,7 @@ impl Uat { Arc::pin_init( try_pin_init!(UatInner { firmware, - #[cfg(CONFIG_DRM_ASAHI_G15)] + #[cfg(CONFIG_DRM_ASAHI_UAT_ADOPTION)] clean_poc: false, handoff_flush <- pin_init::pin_init_array_from_fn(|i| { new_mutex!(HandoffFlush(&handoff.flush[i]), "handoff_flush") diff --git a/drivers/gpu/drm/asahi/pgtable.rs b/drivers/gpu/drm/asahi/pgtable.rs index 1655c1183438bf..b88353a2f73441 100644 --- a/drivers/gpu/drm/asahi/pgtable.rs +++ b/drivers/gpu/drm/asahi/pgtable.rs @@ -95,7 +95,7 @@ pub(crate) fn clean_poc(ptr: *const u8, len: usize) { /// Cleans and invalidates the CPU data cache lines covering `len` bytes at `ptr` to the point of /// coherency, so that later CPU reads observe what a non-snooping agent wrote. Lines the CPU wrote /// are written back first. [`poc_barrier`] completes the maintenance. -#[cfg(CONFIG_DRM_ASAHI_G15)] +#[cfg(CONFIG_DRM_ASAHI_UAT_ADOPTION)] pub(crate) fn clean_invalidate_poc(ptr: *const u8, len: usize) { if len == 0 { return; @@ -305,7 +305,7 @@ pub(crate) struct UatPageTable { oas_mask: u64, /// Clean new tables and changed entries to the point of coherency, for a UAT walker that does /// not snoop the CPU caches ([`Self::enable_clean_poc`]). - #[cfg(CONFIG_DRM_ASAHI_G15)] + #[cfg(CONFIG_DRM_ASAHI_UAT_ADOPTION)] clean_poc: bool, } @@ -321,7 +321,7 @@ impl UatPageTable { va_range: 0..(1u64 << ias), ias_mask: (1u64 << ias) - 1, oas_mask: (1u64 << oas) - 1, - #[cfg(CONFIG_DRM_ASAHI_G15)] + #[cfg(CONFIG_DRM_ASAHI_UAT_ADOPTION)] clean_poc: false, }) } @@ -332,7 +332,7 @@ impl UatPageTable { /// From now on, a new table page is cleaned before its parent descriptor names it, a changed /// table or leaf descriptor is cleaned after the store, and every mutating walk ends with a /// `dsb osh`. Call it before anything is mapped and before any context names the root. - #[cfg(CONFIG_DRM_ASAHI_G15)] + #[cfg(CONFIG_DRM_ASAHI_UAT_ADOPTION)] pub(crate) fn enable_clean_poc(&mut self) -> Result { self.clean_poc = true; // SAFETY: The root is a RAM page owned or borrowed by this page table for its lifetime. @@ -345,14 +345,14 @@ impl UatPageTable { Ok(()) } - /// Whether changes are cleaned to the point of coherency (always false without G15 support). + /// Whether changes are cleaned to the point of coherency (always false without UAT adoption support). #[inline(always)] fn cleans_poc(&self) -> bool { - #[cfg(CONFIG_DRM_ASAHI_G15)] + #[cfg(CONFIG_DRM_ASAHI_UAT_ADOPTION)] { self.clean_poc } - #[cfg(not(CONFIG_DRM_ASAHI_G15))] + #[cfg(not(CONFIG_DRM_ASAHI_UAT_ADOPTION))] { false } @@ -396,7 +396,7 @@ impl UatPageTable { va_range, ias_mask: (1u64 << ias) - 1, oas_mask: (1u64 << oas) - 1, - #[cfg(CONFIG_DRM_ASAHI_G15)] + #[cfg(CONFIG_DRM_ASAHI_UAT_ADOPTION)] clean_poc: false, }) } diff --git a/tools/asahi/g15-zero-words-tests.py b/tools/asahi/g15-zero-words-tests.py index e659a507477b56..68b65b9a6b73a2 100644 --- a/tools/asahi/g15-zero-words-tests.py +++ b/tools/asahi/g15-zero-words-tests.py @@ -7,7 +7,9 @@ golden T6030 inputs below are from SiliconForest 9f09c85f8d3b, except the full hw.rs file refreshed at 709f0f08316a for the reviewed shared PB allocator changes and again when the initial PB posting became a module parameter (the tuning -constant PB_BLOCKS removed). Its T6030 configuration module is independently +constant PB_BLOCKS removed), and when the T6030/T6031 tables were gated on +CONFIG_DRM_ASAHI_G15 for the T8122 runtime's UAT adoption (two #[cfg] lines; +the tables are unchanged). Its T6030 configuration module is independently pinned to the original bytes. """ @@ -24,7 +26,7 @@ GOLDEN_FILES = { "board/data.rs": "7c5ff1077ca3296cbfc9e7144294162b6dea78a3774c38eeed4b0f59a14d7a5c", "board/template.rs": "286872f5474a67534f214e83e659253299f85143f3dc59035fa80894022e2549", - "hw.rs": "658c58026553c098b899aeffa0b6ae5be2b14921aef19df9e4f14789b7b890c4", + "hw.rs": "aa043d11bad177a0aa38755d14159786ee3313c4f8432f5ed56d6967882d9f01", "power/idle.rs": "4928ecf7699b3ca85ff5143eb6e996efd40d47321e29a238a02c8873bc9f102c", } GOLDEN_FUNCTIONS = { diff --git a/tools/testing/selftests/drivers/gpu/asahi-g15/run.py b/tools/testing/selftests/drivers/gpu/asahi-g15/run.py index 861290ef240986..7a3ceaf8003c26 100644 --- a/tools/testing/selftests/drivers/gpu/asahi-g15/run.py +++ b/tools/testing/selftests/drivers/gpu/asahi-g15/run.py @@ -259,13 +259,15 @@ def main(): with tempfile.TemporaryDirectory(prefix="asahi-g15-host-") as temp: temp = Path(temp) glue = (G15 / "glue.c").read_text() + # The UAT adoption's helpers, shared with the T8122 runtime. + uat_glue = (G15 / "uat_glue.c").read_text() functions = [] for signature in ["bool asahi_g15_ram_disjoint", "bool asahi_g15_ram_within", "unsigned int asahi_g15_memory_mode"]: marker = signature + "(u64 start, u64 size)\n{" - start = glue.index(marker) - end = glue.index("\n}", start) + 2 - functions.append(glue[start:end]) + start = uat_glue.index(marker) + end = uat_glue.index("\n}", start) + 2 + functions.append(uat_glue[start:end]) c_source = temp / "memory.c" c_source.write_text(MEMORY_PREFIX + "\n".join(functions) + MEMORY_CASES) subprocess.run([os.environ.get("HOSTCC", "cc"), "-std=gnu11", "-Wall", "-Wextra",