cp_prefetch(9)
π cp_prefetch(9) β the Kernel API Manual glow-up β¨
okay so bestie, welcome to cp_prefetch(9) from the Kernel API Manual (section 9, kernel land, we love a low-level moment) πΈ
β¨ NAME β¨
cp_prefetch β translates a guest physical address channel program into a real-device runnable channel program π
π¦ SYNOPSIS π¦
int cp_prefetch (struct channel_program *cp );
π ARGUMENTS π
cpβ thechannel_programwe're doing the operation on π«Ά
π DESCRIPTION π
So basically this function translates the guest-physical-address channel program and stores the result into the ccwchain list. Iconic, honestly.
β οΈ Real talk though:cpmust have been initialized by a previous call withcp_init. If it wasn't? Undefined behavior occurs. Not a vibe. Not a slay. Please init your structs, bestie π
For each chain that composes the channel program:
- On entry,
ch_lenholds the count of CCWs to be translated π₯ - On exit,
ch_lenis adjusted to the count of successfully translated CCWs. This is the whole point β it letscp_freefind, inch_len, the count of CCWs to free in a chain π (a little bookkeeping moment, but we respect it)
The S/390 CCW Translation APIS (prefixed by cp_, iykyk) were introduced as helpers to do ccw chain translation inside the kernel. Basically: they accept a channel program issued by a virtual machine, and translate that channel program into a real-device runnable channel program π
These APIs will copy the ccws into kernel-space buffers, and update the guest physical addresses with their corresponding host physical addresses. Then channel I/O device drivers could issue the translated channel program to real devices to perform an I/O operation β
These interfaces are designed to support translation only for channel programs that are generated and formatted by a guest. Which is literally what makes it possible for things like VFIO to leverage the interfaces to passthrough a channel I/O mediated device in QEMU π§
And last but not least: we support direct ccw chaining by translating them to idal ccws π
π₯ RETURN π₯
0 on success, and a negative error value on failure β¨
πΈ SEE ALSO πΈ
Kernel file ./drivers/s390/cio/vfio_ccw_cp.c, plus these besties:
that's the whole page, bestie β go translate some channel programs π β¨
π«Ά cute lil sign-off: this one lives under ./drivers/s390/cio, dated October 2026, and yes ma'am, cp_prefetch(9) again because we always close the loop π
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms