Re: sharing RTC device between 2 linux VMs

Adam Lackorzynski <[email protected]> Tue, 3 Sep 2024 00:06:59 +0200
Newsgroups gmane.comp.micro-kernel.l4.devel
Message-ID <[email protected]>
Hi Mohamed,

On Sun Sep 01, 2024 at 14:26:55 +0300, Mohamed Dawod wrote:
> Thank you for the information. but I couldn't find anything about the RTC
> package, how to use and configure it in the ned script ?

Please find attached an example how to start a VM on amd64 using the RTC
service, including ned script and io config.
The entry in the modules.list file is as follows:

entry[arch=amd64] VM-rtc
moe vm-rtc.cfg
module l4re
module ned
module cons
module io
module rtc.io
module rtc
module uvmm
module dtb/virt-pc.dtb
module[fname=linux,nostrip] https://l4re.org/download/Linux-kernel/x86-64/bzImage-6.6.8
module https://l4re.org/download/ramdisks/ramdisk-amd64.rd


I hope it is useful.


Adam

> On Thu, Aug 29, 2024 at 8:54 PM Adam Lackorzynski <[email protected]> wrote:
> > Hi Mohamed,
> > indeed, accessing the same device by two or more clients is not good.
> > There is an rtc package for exactly this: giving multiple clients/VMs
> > access to the rtc.
> >
> > Adam
> > On Mon Aug 26, 2024 at 13:48:39 +0300, Mohamed Dawod wrote:
> > > Hi,
> > > I was trying to pass the RTC device from the host machine (qemu-arm46) to
> > > the guest machine linux VM on top of L4. and it was done successfully.
> > > Now I'm trying to share the same device between 2 linux VMs on top of L4.
> > >  by duplicating the virtual device that describes the same physical
> > device
> > > and also duplicating the virtual bus and passing one for each new vm.
> > >
> > > The issue if that one of the VMs is terminated because of the disability
> > of
> > > binding the same IRQ as described in the screenshot below :
> > > [image: image.png]
> > >
> > > Please find attached all ned scripts I'm using for this experiment.
> > >
> > > Thank you,
> > > Regards
> > >
> > > --
> > > Mohamed Dawod
> > > *Software Engineer, *Avelabs Egypt
> > > *Cell Phone : (+20) 1117311726*
> 
> >
> > > --
> >
> 
> -- 
> 
> 
> *Driving Innovation! Visit our website www.avelabs.com 
> <http://www.avelabs.com/>*, to read Avelabs Confidentiality Notice, follow 
> this link: http://www.avelabs.com/email/disclaimer.html 
> <http://www.avelabs.com/email/disclaimer.html>

_______________________________________________
l4-hackers mailing list -- [email protected]
To unsubscribe send an email to [email protected]
vm-rtc.cfg (text/plain, 1.4 KB)
-- vim:set ft=lua:

local L4 = require("L4");

local l = L4.default_loader;

-- start console server
local cons = l:new_channel();
l:start({ caps = { cons = cons:svr(); },
          log = L4.Env.log
        },
        "rom/cons -a");
l.log_fab = cons:svr();

-- start io server
local rtc_vbus = l:new_channel();

l:start({
          caps = {
            rtc_vbus = rtc_vbus:svr(),
            icu      = L4.Env.icu,
            iommu    = L4.Env.iommu,
            sigma0   = L4.Env.sigma0,
          },
          log      = { "IO", "y" },
          l4re_dbg = L4.Dbg.Warn,
        },
        "rom/io rom/rtc.io");

local rtc_caps = {
  vbus = rtc_vbus;
  rtc  = l:new_channel():svr();
};
l:startv({caps = rtc_caps, log = {"rtc", "c"}}, "rom/rtc");


local flags = L4.Mem_alloc_flags.Continuous
              | L4.Mem_alloc_flags.Pinned
              | L4.Mem_alloc_flags.Super_pages;
local align = 28;

l:startv({
           caps = {
             ram = L4.Env.user_factory:create(L4.Proto.Dataspace,
                                              256 * 1024 * 1024,
                                              flags, align):m("rw"),
             rtc  = rtc_caps.rtc,
           },
           log = { "vm", "Blue" },
         },
         "rom/uvmm", "-v",
            "-krom/linux",
            "-rrom/ramdisk-" .. L4.Info.arch() .. ".rd",
            "-drom/virt-pc.dtb",
            "-cconsole=ttyS0 ramdisk_size=10000 root=/dev/ram0 rw");
rtc.io (text/plain, 280 B)
-- vi:ft=lua

local hw = Io.system_bus()

Io.hw_add_devices(function()
  RTC = Io.Hw.Device(function()
    Property.hid = "PNP0B00";
    Resource.iop1 = Io.Res.io(0x70, 0x71);
  end)
end)

Io.add_vbusses
{
  rtc_vbus = Io.Vi.System_bus(function()
    rtc = wrap(hw.RTC);
  end)
}