vmm: silent several VirtIO config accesses

Ref genodelabs/genode#4698
This commit is contained in:
Stefan Kalkowski 2022-12-09 11:45:55 +01:00 committed by Christian Helmuth
parent 9de81369a7
commit f2188bd397
3 changed files with 28 additions and 1 deletions

View File

@ -64,6 +64,23 @@ class Vmm::Virtio_console : public Virtio_device<Virtio_split_queue, 2>
enum Device_id { CONSOLE = 0x3 };
struct Config_area : Reg
{
Register read(Address_range & range, Cpu&) override
{
switch (range.start) {
case 4: return 1; /* maximum ports */
default: ;
}
return 0;
}
void write(Address_range & range, Cpu&, Register v) override {}
Config_area(Virtio_console & console)
: Reg(console, "ConfigArea", Mmio_register::RW, 0x100, 12) { }
} _config_area { *this };
public:
Virtio_console(const char * const name,

View File

@ -318,6 +318,13 @@ class Vmm::Virtio_device : public Vmm::Mmio_device, public Virtio_device_base
Set _device_low { *this, _queue_sel, "QueueDeviceLow", Reg::WO, 0xa0 };
Set _device_high { *this, _queue_sel, "QueueDeviceHigh", Reg::WO, 0xa4 };
Reg _shm_id { *this, "SHMSel", Reg::WO, 0xac };
Reg _shm_len_low { *this, "SHMLenLow", Reg::RO, 0xb0, 0xffffffff };
Reg _shm_len_high { *this, "SHMLenHigh", Reg::RO, 0xb4, 0xffffffff };
Reg _shm_base_low { *this, "SHMBaseLow", Reg::RO, 0xb8, 0xffffffff };
Reg _shm_base_high { *this, "SHMBaseHigh", Reg::RO, 0xbc, 0xffffffff };
Reg _config_gen { *this, "ConfigGeneration", Reg::RW, 0xfc, 0 };
uint64_t _descriptor_area() const
{
@ -432,6 +439,7 @@ class Vmm::Virtio_device : public Vmm::Mmio_device, public Virtio_device_base
}
Genode::Mutex & mutex() { return _mutex; }
void config_has_changed() { _config_gen.set(_config_gen.get() + 1); }
};
#endif /* _VIRTIO_DEVICE_H_ */

View File

@ -130,8 +130,10 @@ class Vmm::Virtio_net : public Virtio_device<Virtio_split_queue, 2>
return mac.addr[range.start];
}
void write(Address_range & range, Cpu&, Register v) override {}
Config_area(Virtio_net & device, Nic::Mac_address & mac)
: Reg(device, "ConfigArea", Mmio_register::RO, 0x100, 8),
: Reg(device, "ConfigArea", Mmio_register::RW, 0x100, 24),
mac(mac)
{ }
} _config_area { *this, _mac };