fix(linux): the driver-core, platform-device, I2C, userptr and shmem imports xe, nouveau and amdgpu leave open report once and answer as Linux does for a missing facility, and I2C buffer transfers and adapter checks run as Linux's, where each stopped the machine at a trap

This commit is contained in:
Tyler Smith committed 2026-11-16 16:32:13 -05:00
1 parent f6d98dbc84
commit c4192e55bb
8 files changed
+272 -173

No files matched your search

+4 -22
View File
@@ -69,34 +69,16 @@ fn selected(kconfig: &str, set: impl Fn(&str) -> bool) -> Result<Vec<String>, St
/// lacks, or defines only as a trap, by service. Building fails when the
/// imports change, so each supplied service leaves this list with its change.
const OPEN: super::image::Open = &[
// As nouveau's list has them: TTM allocates from its own pool and Stela
// never swaps it out.
(
"shmem and page cache",
&[
"folio_clear_dirty_for_io",
"mm_get_unmapped_area",
"shmem_read_folio_gfp",
"shmem_read_mapping_page_gfp",
"shmem_truncate_range",
"shmem_writeout",
],
),
(
"reopening a file without a VFS path",
&["stela_linux_reopen_unowned_path"],
),
// Only SMU 14's USB-C controller link makes a device link.
("device links", &["device_link_add", "device_link_del"]),
// Only SMU 14's USB-C controller link makes a device link, and
// device_link_add refuses it, so none is deleted.
("device links", &["device_link_del"]),
// Only the partitions of a partitioned accelerator (amdxcp) are
// platform devices.
(
"platform devices",
&[
"platform_device_register_full",
"platform_device_unregister",
],
),
("platform devices", &["platform_device_register_full"]),
// Only the NUMA placement of an accelerator's memory partitions asks.
("the firmware's memory map", &["page_is_ram"]),
// As nouveau's list has them, through hwmon.c and backlight.c.
-35
View File
@@ -20,52 +20,17 @@ const COMPOSITES: [&str; 1] = ["nouveau"];
/// lacks, or defines only as a trap, by service. Building fails when the
/// imports change, so each supplied service leaves this list with its change.
const OPEN: super::image::Open = &[
// Traps nothing nouveau runs reaches. Shmem-backed pages: TTM allocates
// from its own pool and Stela never swaps it out.
(
"shmem and page cache",
&[
"folio_clear_dirty_for_io",
"mm_get_unmapped_area",
"shmem_read_folio_gfp",
"shmem_read_mapping_page_gfp",
"shmem_truncate_range",
"shmem_writeout",
],
),
// Nothing tears a pseudo filesystem's superblock down.
(
"reopening a file without a VFS path",
&["stela_linux_reopen_unowned_path"],
),
(
"HDMI audio",
&["device_link_add", "platform_device_unregister"],
),
// Searches of a class's devices and of a device's children, which
// hwmon.c and backlight.c hold for I2C sensors and panel drivers.
(
"the driver core's device lists",
&["class_find_device", "device_find_child"],
),
// The MIPI DSI and auxiliary buses of the DRM archive: no driver of the
// image registers on either, and only a DSI host's removal walks a
// device's children.
(
"Linux drivers on a bus, bus searches and child walks",
&[
"bus_find_device",
"device_for_each_child",
"driver_register",
"driver_unregister",
],
),
// MMU_NOTIFIER gives every mm notifiers, which dropping an mm destroys;
// nothing subscribes one, which is what takes these locks.
(
"an address space's first notifier",
&["mm_drop_all_locks", "mm_take_all_locks"],
),
];
/// The unit of nouveau's own `module_init`.
+1 -65
View File
@@ -99,71 +99,7 @@ const DESCRIPTIONS: [&str; 6] = [
/// lacks, or defines only as a trap, by service. Building fails when the
/// imports change, so each supplied service leaves this list with its change.
const OPEN: super::image::Open = &[
// Traps: no driver of the image registers on the auxiliary or MIPI DSI
// bus, and only a DSI host's removal walks a device's children.
(
"Linux drivers on a bus, bus searches and child walks",
&[
"bus_find_device",
"device_for_each_child",
"driver_register",
"driver_unregister",
],
),
// Made only when an audio driver binds the display's component.
("HDMI audio's power dependency", &["device_link_add"]),
// Trap: no bus lists a window, so no driver gets as far as assigning a
// resized BAR (pci_resize_resource itself answers that the host bridge
// keeps the firmware's assignment).
(
"PCI: a BAR's resize",
&["pci_assign_unassigned_bus_resources"],
),
// Traps behind a refusal: a discrete GPU's management controller gets
// no register map, so its platform device and I2C client never exist.
(
"management controller: after its register map",
&[
"bus_register_notifier",
"bus_unregister_notifier",
"fwnode_create_software_node",
"fwnode_remove_software_node",
"i2c_bus_type",
"i2c_transfer_buffer_flags",
"i2c_verify_adapter",
"platform_device_add",
"platform_device_alloc",
"platform_device_put",
"platform_device_unregister",
],
),
// Traps behind two refusals: no range of a client's memory faults in,
// and xe refuses a user fence from a caller without an address space
// (every Stela task), so no worker adopts one.
(
"userptr and user fences: a client's address space",
&[
"find_vma_intersection",
"kthread_unuse_mm",
"kthread_use_mm",
"mm_drop_all_locks",
"mm_take_all_locks",
"mmput",
],
),
// As for nouveau: TTM allocates from its own pool and Stela never swaps
// it out, and nothing tears a pseudo filesystem's superblock down.
(
"shmem and page cache",
&[
"folio_clear_dirty_for_io",
"mm_get_unmapped_area",
"shmem_read_folio_gfp",
"shmem_read_mapping_page_gfp",
"shmem_truncate_range",
"shmem_writeout",
],
),
// Nothing tears a pseudo filesystem's superblock down.
(
"reopening a file without a VFS path",
&["stela_linux_reopen_unowned_path"],
+52 -10
View File
@@ -22,6 +22,7 @@
#include <linux/slab.h>
#include <stela/device.h>
#include <stela/catalogue.h>
#include <stela/linux.h>
#include <unsupported.h>
static void device_release(struct kobject *kobj)
@@ -195,9 +196,12 @@ int device_match_of_node(struct device *dev, const void *np)
/* A bus is its type: Stela's owners match and bind the devices of the buses
* they own, so registering one records nothing. A Linux driver on a bus, a
* search of a bus's devices and a walk of a device's children need the
* driver core's lists, which do not exist; nothing in the image registers
* such a driver, and only the removal of a MIPI DSI host walks children,
* which no display driver here registers. */
* driver core's lists, which do not exist. Each is said once and answers as
* Linux does when it finds nothing to act on: a driver is refused (only MIPI
* DSI and DP AUX bus drivers register one, and the image holds none), a
* search finds no device, and a walk visits no child, so the children of a
* MIPI DSI host that goes away (a DSI panel's encoder torn down) stay
* registered and keep their host's device, as their references hold it. */
int bus_register(const struct bus_type *bus)
{
return bus && bus->name ? 0 : -EINVAL;
@@ -208,11 +212,38 @@ void bus_unregister(const struct bus_type *bus)
(void)bus;
}
STELA_UNSUPPORTED(int, driver_register, struct device_driver *)
STELA_UNSUPPORTED(void, driver_unregister, struct device_driver *)
STELA_UNSUPPORTED(struct device *, bus_find_device, const struct bus_type *, struct device *,
const void *, device_match_t)
STELA_UNSUPPORTED(int, device_for_each_child, struct device *, void *, device_iter_t)
int driver_register(struct device_driver *driver)
{
(void)driver;
stela_linux_unsupported("a Linux driver on a bus: it is refused");
return -EOPNOTSUPP;
}
/* Only a driver driver_register took is unregistered, and it takes none. */
void driver_unregister(struct device_driver *driver)
{
(void)driver;
}
struct device *bus_find_device(const struct bus_type *bus, struct device *start,
const void *data, device_match_t match)
{
(void)bus;
(void)start;
(void)data;
(void)match;
stela_linux_unsupported("a search of a bus's devices: it finds none");
return NULL;
}
int device_for_each_child(struct device *parent, void *data, device_iter_t fn)
{
(void)parent;
(void)data;
(void)fn;
stela_linux_unsupported("a walk of a device's children: they stay registered");
return 0;
}
/* A class is its name: a device of one is created and attached like any
* other, and its attribute groups are files nothing reads. Registering a
@@ -320,8 +351,19 @@ void component_del(struct device *dev, const struct component_ops *ops)
(void)ops;
}
/* Runtime power dependencies, which only a bound audio component makes. */
STELA_UNSUPPORTED(struct device_link *, device_link_add, struct device *, struct device *, u32)
/* Runtime power dependencies, which a bound HDMI audio component and an
* SR-IOV physical function's virtual functions make. Without the driver
* core's lists none is kept: the link is refused, said once, and its maker
* goes on as Linux's does when a link fails (audio's bind fails with
* -ENOMEM, a virtual function stays unlinked). */
struct device_link *device_link_add(struct device *consumer, struct device *supplier, u32 flags)
{
(void)consumer;
(void)supplier;
(void)flags;
stela_linux_unsupported("a runtime power dependency between devices: it is refused");
return NULL;
}
/* A link to delete is one device_link_add gave, and it gives none. */
STELA_UNSUPPORTED(void, device_link_del, struct device_link *)
@@ -19,6 +19,12 @@
static int next_adapter;
/* The bus clients are on, which only names it: no I2C driver matches here. */
const struct bus_type i2c_bus_type = {.name = "i2c"};
/* What an adapter's device is, so i2c_verify_adapter tells it from others. */
const struct device_type i2c_adapter_type = {0};
static void lock_bus(struct i2c_adapter *adapter, unsigned int flags)
{
(void)flags;
@@ -73,6 +79,7 @@ int i2c_add_adapter(struct i2c_adapter *adapter)
init_completion(&adapter->dev_released);
adapter->nr = next_adapter++;
device_initialize(&adapter->dev);
adapter->dev.type = &i2c_adapter_type;
adapter->dev.release = adapter_released;
return dev_set_name(&adapter->dev, "i2c-%d", adapter->nr);
}
@@ -139,6 +146,26 @@ int i2c_transfer(struct i2c_adapter *adapter, struct i2c_msg *msgs, int num)
return ret;
}
/* One message to or from a client: the bytes moved, or the error. */
int i2c_transfer_buffer_flags(const struct i2c_client *client, char *buf, int count, u16 flags)
{
struct i2c_msg msg = {
.addr = client->addr,
.flags = flags | (client->flags & I2C_M_TEN),
.len = (u16)count,
.buf = (u8 *)buf,
};
int ret = i2c_transfer(client->adapter, &msg, 1);
return ret == 1 ? count : ret;
}
/* The adapter a device is, or NULL for a device of another type. */
struct i2c_adapter *i2c_verify_adapter(struct device *dev)
{
return dev->type == &i2c_adapter_type ? to_i2c_adapter(dev) : NULL;
}
static void client_released(struct device *dev)
{
kfree(to_i2c_client(dev));
+7 -1
View File
@@ -476,7 +476,13 @@ int pci_resize_resource(struct pci_dev *dev, int resno, int size, int exclude_ba
return -ENOTSUPP;
}
STELA_UNSUPPORTED(void, pci_assign_unassigned_bus_resources, struct pci_bus *)
/* What a BAR's resize released, assigned again. pci_resize_resource refuses
* every resize, so each BAR keeps the firmware's assignment and nothing is
* unassigned: there is nothing to do. */
void pci_assign_unassigned_bus_resources(struct pci_bus *bus)
{
(void)bus;
}
const struct bus_type pci_bus_type = {.name = "pci"};
@@ -17,25 +17,87 @@
#include <stela/linux.h>
#include <unsupported.h>
/* Pages behind shmem files and shmem-backed GEM objects, which swap and
* nouveau's TTM objects never need: TTM allocates pages from its own pool and
* Stela never reclaims them. */
STELA_UNSUPPORTED(struct folio *, shmem_read_folio_gfp, struct address_space *, pgoff_t, gfp_t)
STELA_UNSUPPORTED(struct page *, shmem_read_mapping_page_gfp, struct address_space *, pgoff_t,
gfp_t)
STELA_UNSUPPORTED(void, shmem_truncate_range, struct inode *, loff_t, uoff_t)
/* Pages behind shmem files: shmem-backed GEM objects and TTM's backup of
* buffers it swaps out. TTM allocates pages from its own pool and Stela never
* reclaims them, so nothing needs them; a page asked for anyway is refused,
* said once, with the error Linux gives when shmem has no page to give, which
* each caller returns (a GEM object's pages fail, a buffer stays unswapped).
* No shmem page is ever read in, so a truncation finds none and a writeout or
* a dirty bit has no page to act on. */
struct folio *shmem_read_folio_gfp(struct address_space *mapping, pgoff_t index, gfp_t gfp)
{
(void)mapping;
(void)index;
(void)gfp;
stela_linux_unsupported("pages of a shmem file: they are refused");
return ERR_PTR(-ENOMEM);
}
struct page *shmem_read_mapping_page_gfp(struct address_space *mapping, pgoff_t index, gfp_t gfp)
{
(void)mapping;
(void)index;
(void)gfp;
stela_linux_unsupported("pages of a shmem file: they are refused");
return ERR_PTR(-ENOMEM);
}
void shmem_truncate_range(struct inode *inode, loff_t start, uoff_t end)
{
(void)inode;
(void)start;
(void)end;
}
struct swap_iocb;
STELA_UNSUPPORTED(int, shmem_writeout, struct folio *, struct swap_iocb **, struct list_head *)
STELA_UNSUPPORTED(bool, folio_clear_dirty_for_io, struct folio *)
/* Transparent huge mappings of shmem-backed objects. */
STELA_UNSUPPORTED(unsigned long, mm_get_unmapped_area, struct file *, unsigned long,
unsigned long, unsigned long, unsigned long)
int shmem_writeout(struct folio *folio, struct swap_iocb **plug, struct list_head *folio_list)
{
(void)folio;
(void)plug;
(void)folio_list;
stela_linux_unsupported("writing a shmem page out: it is refused");
return -EOPNOTSUPP;
}
bool folio_clear_dirty_for_io(struct folio *folio)
{
(void)folio;
stela_linux_unsupported("writing a shmem page out: it is refused");
return false;
}
/* An address for a client's mapping of a shmem-backed object, which only a
* client with a Linux address space asks for; Stela's clients map through
* their owner. It is refused, said once, as Linux refuses an address it
* cannot place. */
unsigned long mm_get_unmapped_area(struct file *file, unsigned long address, unsigned long length,
unsigned long offset, unsigned long flags)
{
(void)file;
(void)address;
(void)length;
(void)offset;
(void)flags;
stela_linux_unsupported("a client address for a shmem-backed mapping: it is refused");
return (unsigned long)-ENOMEM;
}
/* The locks of every mapping of an address space, which subscribing its
* first notifier takes. Only a driver mirroring a client's memory (userptr)
* subscribes one, and that also needs the client's pages faulted in through
* Linux page tables, which Stela's clients do not have. */
STELA_UNSUPPORTED(int, mm_take_all_locks, struct mm_struct *)
STELA_UNSUPPORTED(void, mm_drop_all_locks, struct mm_struct *)
* Linux page tables, which Stela's clients do not have. The subscription is
* refused, said once, with the error Linux gives when the locks cannot all
* be taken, and none is then held to drop. */
int mm_take_all_locks(struct mm_struct *mm)
{
(void)mm;
stela_linux_unsupported("a client's own memory as a device buffer (userptr)");
return -EINTR;
}
void mm_drop_all_locks(struct mm_struct *mm)
{
(void)mm;
}
/* A client's own memory as a device's buffer (userptr) and a value written
* into a client from a worker (a user fence). Both need the client as a
* Linux address space with VMAs and page tables. Stela's clients are not:
@@ -43,26 +105,51 @@ STELA_UNSUPPORTED(void, mm_drop_all_locks, struct mm_struct *)
* neither. A fault of a range is refused and said once. A user fence is
* refused by xe where it is asked for, with one warning: no Stela task has an
* address space, and xe refuses a caller without one (third_party/patches/
* linux, "refuse a user fence"). The rest is reached only after a range
* faulted or a worker adopted an address space, so by nothing. */
* linux, "refuse a user fence"). What follows needs an address space a
* caller had, so nothing reaches it; were it reached, a search finds no
* mapping (the caller fails the range with -EFAULT), a worker runs without
* the address space, so its copy goes through the owner's copy services as
* any copy to a client does, and a reference put leaves nothing to free,
* each said once. */
int hmm_range_fault(struct hmm_range *range)
{
(void)range;
stela_linux_unsupported("a client's own memory as a device buffer (userptr)");
return -EOPNOTSUPP;
}
STELA_UNSUPPORTED(struct vm_area_struct *, find_vma_intersection, struct mm_struct *,
unsigned long, unsigned long)
STELA_UNSUPPORTED(void, kthread_use_mm, struct mm_struct *)
STELA_UNSUPPORTED(void, kthread_unuse_mm, struct mm_struct *)
STELA_UNSUPPORTED(void, mmput, struct mm_struct *)
struct vm_area_struct *find_vma_intersection(struct mm_struct *mm, unsigned long start,
unsigned long end)
{
(void)mm;
(void)start;
(void)end;
stela_linux_unsupported("a client's own memory as a device buffer (userptr)");
return NULL;
}
void kthread_use_mm(struct mm_struct *mm)
{
(void)mm;
stela_linux_unsupported("a worker in a client's address space");
}
void kthread_unuse_mm(struct mm_struct *mm)
{
(void)mm;
}
void mmput(struct mm_struct *mm)
{
(void)mm;
stela_linux_unsupported("a worker in a client's address space");
}
/* Register maps, which only a discrete Intel GPU's management controller
* (an I2C controller behind the GPU's own registers) asks for. Stela has no
* platform bus for that controller's driver, so the map is refused and said
* once and the GPU's probe ends with that error; what follows a map (the
* controller as a platform device with a software node, its adapter seen
* through the I2C bus's notifier, transfers to the controller) is not
* reached. */
* once and xe goes on without the controller (third_party/patches/linux,
* "management controller"). What follows a map is refused as well, each
* said once, with the errors Linux gives: the I2C bus's notifier, the
* controller's software node and its platform device. */
struct regmap *__devm_regmap_init(struct device *dev, const struct regmap_bus *bus,
void *bus_context, const struct regmap_config *config,
struct lock_class_key *lock_key, const char *lock_name)
@@ -76,18 +163,57 @@ struct regmap *__devm_regmap_init(struct device *dev, const struct regmap_bus *b
stela_linux_unsupported("register maps: a GPU's management controller");
return ERR_PTR(-EOPNOTSUPP);
}
STELA_UNSUPPORTED(int, bus_register_notifier, const struct bus_type *, struct notifier_block *)
STELA_UNSUPPORTED(int, bus_unregister_notifier, const struct bus_type *,
struct notifier_block *)
STELA_UNSUPPORTED(struct fwnode_handle *, fwnode_create_software_node,
const struct property_entry *, const struct fwnode_handle *)
STELA_UNSUPPORTED(void, fwnode_remove_software_node, struct fwnode_handle *)
STELA_UNSUPPORTED(struct platform_device *, platform_device_alloc, const char *, int)
STELA_UNSUPPORTED(int, platform_device_add, struct platform_device *)
STELA_UNSUPPORTED(void, platform_device_put, struct platform_device *)
STELA_UNSUPPORTED_OBJECT(const struct bus_type, i2c_bus_type);
STELA_UNSUPPORTED(struct i2c_adapter *, i2c_verify_adapter, struct device *)
STELA_UNSUPPORTED(int, i2c_transfer_buffer_flags, const struct i2c_client *, char *, int, u16)
int bus_register_notifier(const struct bus_type *bus, struct notifier_block *notifier)
{
(void)bus;
(void)notifier;
stela_linux_unsupported("a bus notifier: it is refused");
return -EOPNOTSUPP;
}
/* No notifier is registered, so none is found, as Linux answers. */
int bus_unregister_notifier(const struct bus_type *bus, struct notifier_block *notifier)
{
(void)bus;
(void)notifier;
return -ENOENT;
}
struct fwnode_handle *fwnode_create_software_node(const struct property_entry *properties,
const struct fwnode_handle *parent)
{
(void)properties;
(void)parent;
stela_linux_unsupported("a software firmware node: it is refused");
return ERR_PTR(-EOPNOTSUPP);
}
/* Only a node fwnode_create_software_node made is removed, and it makes none. */
void fwnode_remove_software_node(struct fwnode_handle *node)
{
(void)node;
}
struct platform_device *platform_device_alloc(const char *name, int id)
{
(void)name;
(void)id;
stela_linux_unsupported("a platform device: it is refused");
return NULL;
}
int platform_device_add(struct platform_device *device)
{
(void)device;
stela_linux_unsupported("a platform device: it is refused");
return -EOPNOTSUPP;
}
/* Only a device platform_device_alloc gave is put, and it gives none. */
void platform_device_put(struct platform_device *device)
{
(void)device;
}
/* debugfs's seq_file operations, which no file opens: Stela has no debugfs. */
STELA_UNSUPPORTED(int, single_open, struct file *, int (*)(struct seq_file *, void *), void *)
STELA_UNSUPPORTED(int, single_release, struct inode *, struct file *)
@@ -97,7 +223,12 @@ STELA_UNSUPPORTED(loff_t, seq_lseek, struct file *, loff_t, int)
* the partitions of a partitioned accelerator reach DRM as such. */
STELA_UNSUPPORTED(struct platform_device *, platform_device_register_full,
const struct platform_device_info *)
STELA_UNSUPPORTED(void, platform_device_unregister, struct platform_device *)
/* Only a device platform_device_register_full or platform_device_add gave is
* unregistered, and neither gives one. */
void platform_device_unregister(struct platform_device *device)
{
(void)device;
}
/* Whether a frame is RAM is the answer of the firmware's memory map in
* iomem_resource, which holds no map here: Stela's owners hand Linux its
* pages. Only the NUMA placement of an accelerator's memory partitions asks. */
+11 -1
View File
@@ -55,8 +55,18 @@ void stela_linux_i2c_test(void)
struct i2c_client *client = i2c_new_client_device(&adapter, &info);
assert(!IS_ERR(client) && client->addr == 0x48 && !client->dev.driver);
assert(!strcmp(client->name, "sensor") && client->adapter == &adapter);
/* A client is known by its device type; an adapter's device is none. */
/* A client and an adapter are each known by their device type. */
assert(i2c_verify_client(&client->dev) == client && !i2c_verify_client(&adapter.dev));
assert(i2c_verify_adapter(&adapter.dev) == &adapter && !i2c_verify_adapter(&client->dev));
/* One message to the client: its bytes moved, or the transfer's error. */
char bytes[3] = {0};
transfers = 0;
results[0] = 1;
assert(i2c_master_send(client, bytes, 3) == 3 && transfers == 1);
transfers = 0;
results[0] = -EIO;
assert(i2c_master_recv(client, bytes, 3) == -EIO && transfers == 1);
transfers = 0;
i2c_unregister_device(client);
i2c_unregister_device(ERR_PTR(-ENODEV));
info.addr = 0x80;