Skip to contentSkip to conversation

Introduting Xen PV block driver to OVMF

RFC Laszlo Ersek 3 participants 3 messages May 20, 2014 – Jun 4, 2014 2 messages not in the archive

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive

Hello Anthony,

Quoted 11 lines · Anthony PERARD

Hi all,

I've been working on writing a driver to use a Xen PV disk directly from OVMF. So far, I have a working prototype, a guest can boot from a PV device. The code can be found on a git repo:
git://xenbits.xen.org/people/aperard/ovmf.git pv-disk
(http://xenbits.xen.org/gitweb/?p=people/aperard/ovmf.git;a=summary)

(I don't want to send yet the patchs to the mailing list since there is lots of dead code and probably hard to read because of the absence of coding style)

I probably won't find the time to review the series (it is huge), but I have a few suggestions if you allow me to say:

- I used to co-maintain the RHEL-5 Xen hypervisor, the RHEL-5 Xen dom0 and domU kernels, and the RHEL-6 domU kernel. My educated plea is that Xen developers write (or reference) a concise natural language specification, not unlike the virtio specification (probably smaller, if possible), for the subset of the Xen infrastructure that is exercised in the patchset.

- Adhering to the edk2 coding style is very much recommended, but first, please remove all dead code, unused definitions and declarations from the headers etc. The series will be very hard to review even without wading through dead code.

Quoted 7 lines

I would like your comment on the current design choice.

What I have:
- Ovmf/XenbusDxe:
This driver is the first to start, based on the presence of a PCI device, which will initialize plenty of stuff needed to access a PV device and discover every PV devices.

So it is a UEFI bus (or hybrid) driver, producing child handles (with instances of the xenbus protocol), isn't it?

Quoted 4 lines

It initializes the Grant Table and Xenstore.
It provide XenbusProtocol to PV drivers.
There are some hypercall, in assembly which will target GCC for now.

Quoted 8 lines

It consumes PciIoProtocol.
It provides XenbusProtocol.

- Ovmf/XenPvBlkDxe:
This is a block driver that use XenbusProtocol and provide BlockIO. Everything that the driver need go through the XenbusProtocol, which is Xenstore read/write, event channel initialization, Grant table access.

This layering seems sane to me.

Quoted 17 lines

- OvmfPkg/Include/IndustryStandard/Xen:
This contains all the public includes from Xen Project. There are few modification to use function provided by Ovmf instead of POSIX one.

What are all this?
- Xenstore: it's a key/value database.
- Xenbus: It's a king a bus that is bluild on top of Xenstore, this is used to discover PV devices.
- Event Channel: It provide event notification between the two sides of a PV devices, the frontend and backend. This normaly is an interrupt.
- Grant Tables: To grant access to part of a guest memory to another guest.

Quoted 3 lines

Do I need to apply the coding style to the public includes that come from Xen (which are store in Include/IndustryStandard)? I mean changing all uint32_t to UINT32, change every struct name, ...

I think that's recommended. It's the perfect incentive for you to cut stuff to the bare minimum, and to document the rest. (You'll feel an urge to explain whatever you keep and rename.)

Quoted 5 lines

I will however comply to the coding style in Ovmf/XenbusDxe and XenPvBlkDxe.

I'm not sure what I should do with the assembly code, is writing it for GCC enough or should I use another format (.S + .asm)?

AFAIK current practice is to provide all 32-bit and 64-bit assembly as both .S and .asm, and let the build system choose (based on the build host platform).

Of course the above is just my opinion; I won't complain if you disagree. The "hard" requirements will (should :)) come from Jordan.

Thanks!
Laszlo

#2 lore raw
In reply to a message not in the archive
Quoted 7 lines · Anthony PERARD

Hi all,

I've been working on writing a driver to use a Xen PV disk directly from OVMF. So far, I have a working prototype, a guest can boot from a PV device. The code can be found on a git repo:
git://xenbits.xen.org/people/aperard/ovmf.git pv-disk
(http://xenbits.xen.org/gitweb/?p=people/aperard/ovmf.git;a=summary)

Would this be contributed under the MIT license?

Generally, for simplicity we try to just use BSD licensed code in the tree. But, it does seem that there are exceptions:
* AppPkg/Applications/Python/Python-2.7.2/LICENSE
* FatBinPkg/License.txt

Quoted 41 lines

(I don't want to send yet the patchs to the mailing list since there is lots of dead code and probably hard to read because of the absence of coding style)

I would like your comment on the current design choice.

What I have:
- Ovmf/XenbusDxe:
This driver is the first to start, based on the presence of a PCI device, which will initialize plenty of stuff needed to access a PV device and discover every PV devices.
It initializes the Grant Table and Xenstore.
It provide XenbusProtocol to PV drivers.
There are some hypercall, in assembly which will target GCC for now.

It consumes PciIoProtocol.
It provides XenbusProtocol.

- Ovmf/XenPvBlkDxe:
This is a block driver that use XenbusProtocol and provide BlockIO. Everything that the driver need go through the XenbusProtocol, which is Xenstore read/write, event channel initialization, Grant table access.

- OvmfPkg/Include/IndustryStandard/Xen:
This contains all the public includes from Xen Project. There are few modification to use function provided by Ovmf instead of POSIX one.

What are all this?
- Xenstore: it's a key/value database.
- Xenbus: It's a king a bus that is bluild on top of Xenstore, this is used to discover PV devices.
- Event Channel: It provide event notification between the two sides of a PV devices, the frontend and backend. This normaly is an interrupt.
- Grant Tables: To grant access to part of a guest memory to another guest.

Quoted 5 lines

Do I need to apply the coding style to the public includes that come from Xen (which are store in Include/IndustryStandard)? I mean changing all uint32_t to UINT32, change every struct name, ...
I will however comply to the coding style in Ovmf/XenbusDxe and XenPvBlkDxe.

If the code will be shared by another project, then keeping the original code style can be considered to help with future merging. You might want to consider separating the EDK II specific code into separate files which can use the EDK II code style wherever possible.

An example of a file that does not use the EDK II code style:
OvmfPkg/Include/IndustryStandard/LinuxBzimage.h

Quoted 2 lines

I'm not sure what I should do with the assembly code, is writing it for GCC enough or should I use another format (.S + .asm)?

Currently we need both .S and .asm. Hopefully this will motivate you to keep the assembly code as small as possible. :)

-Jordan

Quoted 16 lines

Regards,

--
Anthony PERARD

------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE Instantly run your Selenium tests across 300+ browser/OS combos. Get unparalleled scalability from the best Selenium testing platform available Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-devel

#4 lore raw
In reply to a message not in the archive
Quoted 11 lines · Jordan Justen
Quoted 7 lines · Anthony PERARD

Hi all,

I've been working on writing a driver to use a Xen PV disk directly from OVMF. So far, I have a working prototype, a guest can boot from a PV device. The code can be found on a git repo:
git://xenbits.xen.org/people/aperard/ovmf.git pv-disk
(http://xenbits.xen.org/gitweb/?p=people/aperard/ovmf.git;a=summary)

Would this be contributed under the MIT license?

I think most of the code source I am using is under BSD license. It comes from FreeBSD and MiniOS (xen.git/extras/mini-os, which is likely to be compatible with BSD).

Quoted 52 lines

Generally, for simplicity we try to just use BSD licensed code in the tree. But, it does seem that there are exceptions:
* AppPkg/Applications/Python/Python-2.7.2/LICENSE
* FatBinPkg/License.txt

Quoted 41 lines

(I don't want to send yet the patchs to the mailing list since there is lots of dead code and probably hard to read because of the absence of coding style)

I would like your comment on the current design choice.

What I have:
- Ovmf/XenbusDxe:
This driver is the first to start, based on the presence of a PCI device, which will initialize plenty of stuff needed to access a PV device and discover every PV devices.
It initializes the Grant Table and Xenstore.
It provide XenbusProtocol to PV drivers.
There are some hypercall, in assembly which will target GCC for now.

It consumes PciIoProtocol.
It provides XenbusProtocol.

- Ovmf/XenPvBlkDxe:
This is a block driver that use XenbusProtocol and provide BlockIO. Everything that the driver need go through the XenbusProtocol, which is Xenstore read/write, event channel initialization, Grant table access.

- OvmfPkg/Include/IndustryStandard/Xen:
This contains all the public includes from Xen Project. There are few modification to use function provided by Ovmf instead of POSIX one.

What are all this?
- Xenstore: it's a key/value database.
- Xenbus: It's a king a bus that is bluild on top of Xenstore, this is used to discover PV devices.
- Event Channel: It provide event notification between the two sides of a PV devices, the frontend and backend. This normaly is an interrupt.
- Grant Tables: To grant access to part of a guest memory to another guest.

Quoted 5 lines

Do I need to apply the coding style to the public includes that come from Xen (which are store in Include/IndustryStandard)? I mean changing all uint32_t to UINT32, change every struct name, ...
I will however comply to the coding style in Ovmf/XenbusDxe and XenPvBlkDxe.

Quoted 7 lines

If the code will be shared by another project, then keeping the original code style can be considered to help with future merging. You might want to consider separating the EDK II specific code into separate files which can use the EDK II code style wherever possible.

An example of a file that does not use the EDK II code style:
OvmfPkg/Include/IndustryStandard/LinuxBzimage.h

That's good to know. I will keep the original coding style for the includes then, they will live under OvmfPkg/Include/IndustryStandard/Xen. That will definitely help future merge to gain new features.

Quoted 5 lines
Quoted 2 lines

I'm not sure what I should do with the assembly code, is writing it for GCC enough or should I use another format (.S + .asm)?

Currently we need both .S and .asm. Hopefully this will motivate you to keep the assembly code as small as possible. :)

OK, I will provide .S and .asm when assembly is required.

Thanks for your feedback.

Signature · 1 line
Anthony PERARD