From 1f1437747c80a1e6fb8950de219cad638d44c22b Mon Sep 17 00:00:00 2001 From: Johannes Schlatow Date: Thu, 23 Nov 2023 11:40:58 +0100 Subject: [PATCH] platform_drv: don't copy Bdf genodelabs/genode#5002 --- repos/os/src/drivers/platform/device_pd.cc | 4 ++-- repos/os/src/drivers/platform/device_pd.h | 4 ++-- repos/os/src/drivers/platform/io_mmu.h | 6 +++--- .../pc/src/drivers/platform/pc/intel/default_mappings.cc | 9 +++++---- .../pc/src/drivers/platform/pc/intel/default_mappings.h | 6 +++--- repos/pc/src/drivers/platform/pc/intel/io_mmu.cc | 2 +- repos/pc/src/drivers/platform/pc/intel/io_mmu.h | 4 ++-- .../src/drivers/platform/pc/intel/managed_root_table.cc | 4 ++-- .../src/drivers/platform/pc/intel/managed_root_table.h | 6 +++--- 9 files changed, 23 insertions(+), 22 deletions(-) diff --git a/repos/os/src/drivers/platform/device_pd.cc b/repos/os/src/drivers/platform/device_pd.cc index ce2a4ad5c9..3d7ac2efbf 100644 --- a/repos/os/src/drivers/platform/device_pd.cc +++ b/repos/os/src/drivers/platform/device_pd.cc @@ -114,7 +114,7 @@ void Device_pd::remove_range(Io_mmu::Range const & range) void Device_pd::enable_pci_device(Io_mem_dataspace_capability const io_mem_cap, - Pci::Bdf const bdf) + Pci::Bdf const & bdf) { addr_t addr = _address_space.attach(io_mem_cap, 0x1000); @@ -134,7 +134,7 @@ void Device_pd::enable_pci_device(Io_mem_dataspace_capability const io_mem_cap, } -void Device_pd::disable_pci_device(Pci::Bdf const) +void Device_pd::disable_pci_device(Pci::Bdf const &) { warning("Cannot unassign PCI device from device PD (not implemented by kernel)."); } diff --git a/repos/os/src/drivers/platform/device_pd.h b/repos/os/src/drivers/platform/device_pd.h index 067f5bc55d..3ca4e89fcd 100644 --- a/repos/os/src/drivers/platform/device_pd.h +++ b/repos/os/src/drivers/platform/device_pd.h @@ -93,8 +93,8 @@ class Driver::Device_pd : public Io_mmu::Domain void remove_range(Io_mmu::Range const &) override; void enable_pci_device(Io_mem_dataspace_capability const, - Pci::Bdf const) override; - void disable_pci_device(Pci::Bdf const) override; + Pci::Bdf const &) override; + void disable_pci_device(Pci::Bdf const &) override; }; diff --git a/repos/os/src/drivers/platform/io_mmu.h b/repos/os/src/drivers/platform/io_mmu.h index 3acfb3fa93..5ca3897b1a 100644 --- a/repos/os/src/drivers/platform/io_mmu.h +++ b/repos/os/src/drivers/platform/io_mmu.h @@ -79,8 +79,8 @@ class Driver::Io_mmu : private Io_mmu_devices::Element /* interface for (un)assigning a pci device */ virtual void enable_pci_device(Io_mem_dataspace_capability const, - Pci::Bdf const) = 0; - virtual void disable_pci_device(Pci::Bdf const) = 0; + Pci::Bdf const &) = 0; + virtual void disable_pci_device(Pci::Bdf const &) = 0; /* interface for adding/removing DMA buffers */ virtual void add_range(Range const &, @@ -138,7 +138,7 @@ class Driver::Io_mmu : private Io_mmu_devices::Element virtual void add_default_range(Range const &, addr_t) { } /* interface for activating default mappings for certain device */ - virtual void enable_default_mappings(Pci::Bdf) { } + virtual void enable_default_mappings(Pci::Bdf const &) { } /* interface for completing default mappings (enabled IOMMU) */ virtual void default_mappings_complete() { } diff --git a/repos/pc/src/drivers/platform/pc/intel/default_mappings.cc b/repos/pc/src/drivers/platform/pc/intel/default_mappings.cc index e0a3c8ca9b..8ac9bdb095 100644 --- a/repos/pc/src/drivers/platform/pc/intel/default_mappings.cc +++ b/repos/pc/src/drivers/platform/pc/intel/default_mappings.cc @@ -16,7 +16,7 @@ #include void Intel::Default_mappings::_insert_context(Managed_root_table & root, - Pci::Bdf bdf, + Pci::Bdf const & bdf, addr_t paddr, Domain_id domain_id) { @@ -60,14 +60,15 @@ void Intel::Default_mappings::insert_translation(addr_t va, addr_t pa, } -void Intel::Default_mappings::enable_device(Pci::Bdf bdf, Domain_id domain_id) +void Intel::Default_mappings::enable_device(Pci::Bdf const & bdf, + Domain_id domain_id) { _insert_context(_root_table, bdf, _default_table_phys, domain_id); } void Intel::Default_mappings::copy_stage2(Managed_root_table & dst_root, - Pci::Bdf bdf) + Pci::Bdf const & bdf) { _root_table.with_stage2_pointer(bdf, [&] (addr_t phys_addr, Domain_id domain) { _insert_context(dst_root, bdf, phys_addr, domain); }); @@ -77,7 +78,7 @@ void Intel::Default_mappings::copy_stage2(Managed_root_table & dst_root, void Intel::Default_mappings::copy_stage2(Managed_root_table & dst_root) { _root_table.for_each_stage2_pointer( - [&] (Pci::Bdf bdf, addr_t phys_addr, Domain_id domain) { + [&] (Pci::Bdf const & bdf, addr_t phys_addr, Domain_id domain) { _insert_context(dst_root, bdf, phys_addr, domain); }); } diff --git a/repos/pc/src/drivers/platform/pc/intel/default_mappings.h b/repos/pc/src/drivers/platform/pc/intel/default_mappings.h index 47721ff93c..4718617563 100644 --- a/repos/pc/src/drivers/platform/pc/intel/default_mappings.h +++ b/repos/pc/src/drivers/platform/pc/intel/default_mappings.h @@ -59,15 +59,15 @@ class Intel::Default_mappings return 0; } - void _insert_context(Managed_root_table &, Pci::Bdf, addr_t, Domain_id); + void _insert_context(Managed_root_table &, Pci::Bdf const &, addr_t, Domain_id); public: void insert_translation(addr_t, addr_t, size_t, Page_flags, uint32_t); - void enable_device(Pci::Bdf, Domain_id); + void enable_device(Pci::Bdf const &, Domain_id); - void copy_stage2(Managed_root_table &, Pci::Bdf); + void copy_stage2(Managed_root_table &, Pci::Bdf const &); void copy_stage2(Managed_root_table &); Default_mappings(Env & env, diff --git a/repos/pc/src/drivers/platform/pc/intel/io_mmu.cc b/repos/pc/src/drivers/platform/pc/intel/io_mmu.cc index bf9cbdf04d..de436015a3 100644 --- a/repos/pc/src/drivers/platform/pc/intel/io_mmu.cc +++ b/repos/pc/src/drivers/platform/pc/intel/io_mmu.cc @@ -52,7 +52,7 @@ void Intel::Io_mmu::Domain::enable_pci_device(Io_mem_dataspace_capability template -void Intel::Io_mmu::Domain
::disable_pci_device(Pci::Bdf const bdf) +void Intel::Io_mmu::Domain
::disable_pci_device(Pci::Bdf const & bdf) { _intel_iommu.root_table().remove_context(bdf, _translation_table_phys); diff --git a/repos/pc/src/drivers/platform/pc/intel/io_mmu.h b/repos/pc/src/drivers/platform/pc/intel/io_mmu.h index 6ccecb7916..54529f197e 100644 --- a/repos/pc/src/drivers/platform/pc/intel/io_mmu.h +++ b/repos/pc/src/drivers/platform/pc/intel/io_mmu.h @@ -545,10 +545,10 @@ class Intel::Io_mmu : private Attached_mmio, */ void add_default_range(Range const &, addr_t) override; void default_mappings_complete() override; - void enable_default_mappings(Pci::Bdf bdf) override { + void enable_default_mappings(Pci::Bdf const & bdf) override { _default_mappings.enable_device(bdf, _default_domain); } - void apply_default_mappings(Pci::Bdf bdf) { + void apply_default_mappings(Pci::Bdf const & bdf) { _default_mappings.copy_stage2(_managed_root_table, bdf); } /** diff --git a/repos/pc/src/drivers/platform/pc/intel/managed_root_table.cc b/repos/pc/src/drivers/platform/pc/intel/managed_root_table.cc index e35d1b6a6e..6ce9c41a40 100644 --- a/repos/pc/src/drivers/platform/pc/intel/managed_root_table.cc +++ b/repos/pc/src/drivers/platform/pc/intel/managed_root_table.cc @@ -14,8 +14,8 @@ /* local includes */ #include -void Intel::Managed_root_table::remove_context(Pci::Bdf bdf, - addr_t phys_addr) +void Intel::Managed_root_table::remove_context(Pci::Bdf const & bdf, + addr_t phys_addr) { _with_context_table(bdf.bus, [&] (Context_table & ctx) { Pci::rid_t rid = Pci::Bdf::rid(bdf); diff --git a/repos/pc/src/drivers/platform/pc/intel/managed_root_table.h b/repos/pc/src/drivers/platform/pc/intel/managed_root_table.h index a0995f88d3..ea25dd54ad 100644 --- a/repos/pc/src/drivers/platform/pc/intel/managed_root_table.h +++ b/repos/pc/src/drivers/platform/pc/intel/managed_root_table.h @@ -100,7 +100,7 @@ class Intel::Managed_root_table : public Registered_translation_table } template - void with_stage2_pointer(Pci::Bdf bdf, FN && fn) + void with_stage2_pointer(Pci::Bdf const & bdf, FN && fn) { _with_context_table(bdf.bus, [&] (Context_table & ctx) { Pci::rid_t rid = Pci::Bdf::rid(bdf); @@ -112,7 +112,7 @@ class Intel::Managed_root_table : public Registered_translation_table /* add second-stage table */ template - Domain_id insert_context(Pci::Bdf bdf, addr_t phys_addr, Domain_id domain) + Domain_id insert_context(Pci::Bdf const & bdf, addr_t phys_addr, Domain_id domain) { Domain_id cur_domain { }; @@ -129,7 +129,7 @@ class Intel::Managed_root_table : public Registered_translation_table } /* remove second-stage table for particular device */ - void remove_context(Pci::Bdf, addr_t); + void remove_context(Pci::Bdf const &, addr_t); /* remove second-stage table for all devices */ void remove_context(addr_t);