Skip to contentSkip to conversation

linux openvpn development job

Openvpn-devel Siim Põder 5 participants 16 messages Apr 24, 2009 – Apr 29, 2009

lore
Share & tools
lore
#0 lore raw

Hi

We are running a couple of openvpn servers with relatively high load (Opterons 2xDC, e1000, recent kerneles) and it seems as if most of the CPU time is not used on cryptography, but in softirq (send/recv for udp and read/write on tun?). This has lead us to suspect that most of the time is spent pumping data between userspace and kernelspace.

Now, we are still investigating this, but I thought I'd ask around too:. Does anyone have a take on this, could a considerable (upwards of 10%) increase in openvpn capacity be accomplished by optimizing udp/tun interfaces of the kernel (a mechanism like ring buffers?) or are we on a wrong track? Furthermore (if it is possible) would anyone care to develop such a solution? You'd get compensated for your trouble, naturally.

Thanks for your attention,
Siim

#1 lore raw
Quoted 9 lines · Siim Põder

Hi

We are running a couple of openvpn servers with relatively high load (Opterons 2xDC, e1000, recent kerneles) and it seems as if most of the CPU time is not used on cryptography, but in softirq (send/recv for udp
and read/write on tun?). This has lead us to suspect that most of the time is spent pumping data between userspace and kernelspace.

Quoted 7 lines

Now, we are still investigating this, but I thought I'd ask around too:.
Does anyone have a take on this, could a considerable (upwards of 10%) increase in openvpn capacity be accomplished by optimizing udp/tun interfaces of the kernel (a mechanism like ring buffers?) or are we on a
wrong track?

Please pardon me for thinking out loud here...

The problem is that moving data between userspace and kernelspace is expensive. (IIRC you can't just use the CPU to filter the bus between nics, you need to deliver data to/receive data from RAM because that's where the userland app works with it.) OpenVPN runs in userspace so all the VPN data has to pass out of the kernel into userspace and back again. To attack the problem directly you need to move all functionality into the kernel, which raises a number of problems. Such an OpenVPN would not port between OS platforms very well. Someone would have to convince both
the kernel and OpenVPN developers to maintain the
code. And so forth.

The question then becomes how much optimization can be made between kernel and userspace beyond what's already been done, again bearing in mind the both the kernel and OpenVPN developers must be on-board with the result. Of course you could maintain the resulting code, but you'd need to recognize that, typically, at least 70% of software labor costs are in maintenance.

Everybody wants faster userspace/kernelspace transfers but everybody also wants a standard OS API. The Linux kernel developers provide feedback on ideas. I don't know about the OpenVPN developers but I've not seem much traffic here in the weeks I've been subscribed.

I've seen embedded devices use upwards of 50% of the CPU on the kernel/userspace transition. Using hardware acceleration reduces performance because it passes more data across the kernel/user boundary.

IMO your money is better spent getting redundant hardware and load balancing. (E.g. you could run OpenVPN on OpenBSD/carp and have a loadbalanced hot-failover
cluster. Or use some other clustering solution.)
At least that's how I'd go without a good plan, and buy-in from the OpenVPN developers.
After the initial investment the cluster solution will scale linearly with dollars spent, and you get increased reliability and fault-tolerance for free.

Karl <[email protected]...>
Free Software: "You don't pay back, you pay forward."
-- Robert A. Heinlein

#2 lore raw
Quoted 1 line · Karl O. Pinc

On 04/24/2009 07:40:02 AM, Siim Põder wrote:

[snip]

Quoted 1 line

Please pardon me for thinking out loud here...

I'll follow in this path, thinking out loud ...

Quoted 4 lines

The problem is that moving data between userspace and kernelspace is expensive. (IIRC you can't just use the CPU to filter the bus between nics, you need to deliver data to/receive data from RAM because that's where the userland app works

Quoted 8 lines

with it.) OpenVPN runs in userspace so all the VPN data has to pass out of the kernel into userspace and back again. To attack the problem directly you need to move all functionality into the kernel, which raises a number of problems. Such an OpenVPN would not port between OS platforms very well. Someone would have to convince both
the kernel and OpenVPN developers to maintain the
code. And so forth.

This actually made me think a little bit. For the Windows platform, OpenVPN ship a TUN/TAP driver as a part of the installation, due to missing native tun/tap drivers.

What if OpenVPN on selected platforms also provided it's own kernel driver which would do practically the same as the upstream tun.ko modules - except it provides a direct API which OpenVPN can utilize, to avoid the kernel-userspace-kernel ping-pong.

But I also do realise that, a poorly written API can introduce some really nasty security breaches as well. And I also realise that it will be more code to maintain. Such an implementation should probably try to make use of the kernel based encryption API as well, as that might be also much more efficient in this setting.

Just my 2cents.

David Sommerseth

#3 lore raw
Quoted 19 lines · David Sommerseth
Quoted 1 line · Karl O. Pinc

On 04/24/2009 07:40:02 AM, Siim Põder wrote:

[snip]

Quoted 1 line

Please pardon me for thinking out loud here...

I'll follow in this path, thinking out loud ...

Quoted 8 lines

The problem is that moving data between userspace and kernelspace is expensive. (IIRC you can't just use the CPU to filter the bus between nics, you need to deliver data to/receive data from RAM because that's where the userland app works with it.) OpenVPN runs in userspace so all the VPN data has to pass out of the kernel into userspace and back again. To attack the problem directly you need to move all functionality into the kernel, which raises a number of problems.

Quoted 6 lines

What if OpenVPN on selected platforms also provided it's own kernel driver
which would do practically the same as the upstream tun.ko modules - except it provides a direct API which OpenVPN can utilize, to avoid the
kernel-userspace-kernel ping-pong.

That actually sounds approachable, from a thinking out loud perspective. I don't really know the important details so can't judge.

In order to reduce latency and work the kernel need only examine the IP headers. The rest of the datagrams can stay on the card. Once the routing decision is made the bus can deliver the datagram directly to the appropriate nic's buffer. This could be on the same card if you've multiport nic cards or could be assisted by dma or some such. This keeps down latency and offloads the CPU.

As long as you're putting parts of OpenVPN in the kernel it would be nice to leave as much of the tun module alone as possible and have a separate OpenVPN kernel module. You'd split out the part of OpenVPN that does the data channel and put that in the kernel module, it would talk to the kernel tun interface etc. Everything else, all the control channel auth stuff and the like, does not have to be in the kernel because it's not high performance/high volume.

As Siim pointed out you do need to move the whole datagram into RAM if you're going to operate on it. But if there's encryption hardware support in the kernel additional operations involving system RAM may not be required.. You may be able to go directly between the nic and the hardware encryption engine and avoid RAM. I've really no idea.

(I do know that one reason why I saw such bad kernel/userspace performance in an embedded device is due to sucky nic hardware. It may require good hardware to offload the CPU.)

I don't know how this would play with the OpenSSL API. Ideally OpenSSL has provisions for being used inside kernelspace so that it can directly access any hardware
engines. Moving all the crypto calls from the OpenSSL
API to the kernel API sounds prohibitive although you never know until you look. Worst case
you'd not be able to use hardware acceleration if you used a kernel module version of OpenVPN based on OpenSSL.

And of course, as you say, there's all sorts of opportunity for insecurity when you introduce code into the kernel. But the data channel code that goes in the kernel module should already be hardened.

Regards the political considerations, if successful such an approach could be attractive enough that the OpenVPN developers couldn't ignore it. Greatly improved performance could create enough interest to support a fork, especially if the necessary changes were minimal and could be ported into future OpenVPN versions. I don't want to be seen in any way as agitating for such a fork, and I certainly don't want to cast
any aspersions on the management of the OpenVPN project. My point here is only to explore the prospects of the long-term maintenance of an OpenVPN kernel module.

In the long-term the other aspect of such an approach that needs addressing is the API between the kernel module and the rest of OpenVPN. Ideally the kernel module would eventually be made part of the official kernel. I don't know the policy of the kernel maintainers but I would think that an OpenVPN kernel module would be more attractive if it were usable by something besides the OpenVPN application. The big attraction of getting
a kernel module sanctioned by the kernel devs is that there's no headaces with respect to kernel version incompatibilities. The in-kernel API is not static so changes to any of the nic drivers could affect system stability.

The above is an awful lot of thinking out loud, especially because I don't really have any involvement or familiarity with any internals.
Or any of the politics involved for that matter. My intention here is to explore the entire problem space; and when people become involved politics ensues. It's always a bad idea to
speak on political matters when you are not
on familiar ground, and that is what I've
done here. I hope I have not stepped into sensitive matters and apologize in advance
for any offense.

Karl <[email protected]...>
Free Software: "You don't pay back, you pay forward."
-- Robert A. Heinlein

#4 lore raw

Karl O. Pinc wrote on 25/04/2009 7:42 PM:

Quoted 124 lines · David Sommerseth
Quoted 24 lines
Quoted 2 lines · Karl O. Pinc

On 04/24/2009 07:40:02 AM, Siim Põder wrote:

[snip]

Quoted 2 lines

Please pardon me for thinking out loud here...

I'll follow in this path, thinking out loud ...

Quoted 9 lines

The problem is that moving data between userspace and kernelspace is expensive. (IIRC you can't just use the CPU to filter the bus between nics, you need to deliver data to/receive data from RAM because that's where the userland app works with it.) OpenVPN runs in userspace so all the VPN data has to pass out of the kernel into userspace and back again. To attack the problem directly you need to move all functionality into the kernel, which raises a number of problems.

Quoted 7 lines

What if OpenVPN on selected platforms also provided it's own kernel driver
which would do practically the same as the upstream tun.ko modules - except it provides a direct API which OpenVPN can utilize, to avoid the
kernel-userspace-kernel ping-pong.

That actually sounds approachable, from a thinking out loud perspective. I don't really know the important details so can't judge.

In order to reduce latency and work the kernel need only examine the IP headers. The rest of the datagrams can stay on the card. Once the routing decision is made the bus can deliver the datagram directly to the appropriate nic's buffer. This could be on the same card if you've multiport nic cards or could be assisted by dma or some such. This keeps down latency and offloads the CPU.

As long as you're putting parts of OpenVPN in the kernel it would be nice to leave as much of the tun module alone as possible and have a separate OpenVPN kernel module. You'd split out the part of OpenVPN that does the data channel and put that in the kernel module, it would talk to the kernel tun interface etc. Everything else, all the control channel auth stuff and the like, does not have to be in the kernel because it's not high performance/high volume.

As Siim pointed out you do need to move the whole datagram into RAM if you're going to operate on it. But if there's encryption hardware support in the kernel additional operations involving system RAM may not be required.. You may be able to go directly between the nic and the hardware encryption engine and avoid RAM. I've really no idea.

(I do know that one reason why I saw such bad kernel/userspace performance in an embedded device is due to sucky nic hardware. It may require good hardware to offload the CPU.)

I don't know how this would play with the OpenSSL API. Ideally OpenSSL has provisions for being used inside kernelspace so that it can directly access any hardware
engines. Moving all the crypto calls from the OpenSSL
API to the kernel API sounds prohibitive although you never know until you look. Worst case
you'd not be able to use hardware acceleration if you used a kernel module version of OpenVPN based on OpenSSL.

And of course, as you say, there's all sorts of opportunity for insecurity when you introduce code into the kernel. But the data channel code that goes in the kernel module should already be hardened.

Regards the political considerations, if successful such an approach could be attractive enough that the OpenVPN developers couldn't ignore it. Greatly improved performance could create enough interest to support a fork, especially if the necessary changes were minimal and could be ported into future OpenVPN versions. I don't want to be seen in any way as agitating for such a fork, and I certainly don't want to cast
any aspersions on the management of the OpenVPN project. My point here is only to explore the prospects of the long-term maintenance of an OpenVPN kernel module.

In the long-term the other aspect of such an approach that needs addressing is the API between the kernel module and the rest of OpenVPN. Ideally the kernel module would eventually be made part of the official kernel. I don't know the policy of the kernel maintainers but I would think that an OpenVPN kernel module would be more attractive if it were usable by something besides the OpenVPN application. The big attraction of getting
a kernel module sanctioned by the kernel devs is that there's no headaces with respect to kernel version incompatibilities. The in-kernel API is not static so changes to any of the nic drivers could affect system stability.

The above is an awful lot of thinking out loud, especially because I don't really have any involvement or familiarity with any internals.
Or any of the politics involved for that matter. My intention here is to explore the entire problem space; and when people become involved politics ensues. It's always a bad idea to
speak on political matters when you are not
on familiar ground, and that is what I've
done here. I hope I have not stepped into sensitive matters and apologize in advance
for any offense.

Quoted 3 lines

Karl <[email protected]...>
Free Software: "You don't pay back, you pay forward."

Although not directly the same issue, we had/have performance issues and folks contributed some thoughts here :

http://sourceforge.net/mailarchive/forum.php?thread_name=492DBF02.1070305%40ednet.ns.ca&forum_name=openvpn-devel

begin:vcard
fn:James MacLean (Portable Apps Sent)
n:MacLean;James B.
email;internet:[email protected]...
note:Portable Apps Sent
x-mozilla-html:TRUE
version:2.1
end:vcard

#5 lore raw
In reply to David Sommerseth
Quoted 4 lines · David Sommerseth

What if OpenVPN on selected platforms also provided it's own kernel driver which would do practically the same as the upstream tun.ko modules - except it provides a direct API which OpenVPN can utilize, to avoid the kernel-userspace-kernel ping-pong.

It seems that OpenVPN is quite far away from the theoretical performance where kernel-userspace-kernel copying becomes an issue. Right now encryption is quite expensive, except on a few platforms with dedicated AES instructions.

/Benny

#6 lore raw
Quoted 7 lines · Benny Amorsen

It seems that OpenVPN is quite far away from the theoretical performance
where kernel-userspace-kernel copying becomes an issue. Right now encryption is quite expensive, except on a few platforms with dedicated
AES instructions.

Dedicated encryption hardware is cheap. (<$100) And it seems that using it can also involve a kernel/userspace transition.

I've a box with an AMD Geode LX. This chip supports AES-128 bit encryption. The same box also has a Hi/fn 7955 chip on a separate PCI card, which supports AES-256 as well as other algorithms.

When I switch from AES-128 to AES-256, or other, cheaper, choices supported by the Hifn but not the Geode, I see a large performance hit. Assuming my tests are right; I've not put a lot of effort into it.

I suspect the problem is again kernel/userspace. The CPU is available to userspace, but the Hifn is not. (There are other possibilities. Perhaps OpenSSL does not play well with multiple hardware accelerators, or maybe my tests are just plain bad.)

So, I believe it's easy and cheap to add hardware to a OpenVPN box and create a situation where
the kernel/userspace transition cost does matter.

Karl <[email protected]...>
Free Software: "You don't pay back, you pay forward."
-- Robert A. Heinlein

#7 lore raw

Hi

Quoted 3 lines · Karl O. Pinc

So, I believe it's easy and cheap to add hardware
to a OpenVPN box and create a situation where
the kernel/userspace transition cost does matter.

It's easy and cheap if you add a second box or third. But if you are approaching tens of openvpn boxes (at various locations) and you want to maintain rendundancy, it is not especially cheap nor is it especially easy. Maintaining the system gets a bit trickier and simply relying on ssh and grep doesn't cut it any more.

Regarding the idea of moving openvpn to kernel, I think there are MUCH easier ways to improve the situation. As a large part of time is spent in moving data between kernel/user, that interface could be improved.

There are two interfaces, udp sockets and tun devices. For both of them, experimental proposed rx/tx ring implementations exist:

http://lwn.net/Articles/276856/ vringfd() is a genering buffer ring interface, developed for lguest and seems to be implemented for tun device. Not sure how much it would improve the situation, but I'm guessing quite a bit.

http://wiki.ipxwarzone.com/index.php5?title=Linux_packet_mmap
packet_ring_tx (and rx, IIRC) interface written by Johann Baudy. Quoting that wiki "I've reached 107Mo/S using a small embedded target (PPC405-300Mhz) where I've never exceeded 20Mo/s with normal raw socket."

Also our own test show that using standard (ie, not neccessarily optimized for routing) Opteron servers and intel e1000, we can saturate 1G easilly (with up to 300Kpps in one direction), with about 10% of a single core working in softirq (50% if conntrack is in the picture). However, with openvpn, we can go up to ~80 Kpps without encryption and in that case, rougly half of the load goes into softirq and the other half goes into userland. Most of the drop from 300 to 80 should be wasted work.

With encryption, something along the lines of 50Kpps could be maintained (this is an estimation from another earlier test). Furthermore, roughly half of the CPU time goes into user and the other half into kernelland.

Thinking out loud - if the machine can route much higher packet rates without breaking a sweat and encryption takes about half of the load, then optimizing the user/kernel interaction could improve performance up to 50%. Even if the ring buffers turn out to be less effective than I optimistically presume, 10% performance increase wouldn't be too shabby either.

It doesn't seem too hard to implement at the first glance and if someone wants to try it a compensation could be arranged for that effort.

Siim

#8 lore raw
Quoted 7 lines · Siim Põder

Hi

Quoted 3 lines · Karl O. Pinc

So, I believe it's easy and cheap to add hardware
to a OpenVPN box and create a situation where
the kernel/userspace transition cost does matter.

Quoted 6 lines

It's easy and cheap if you add a second box or third. But if you are approaching tens of openvpn boxes (at various locations) and you want to
maintain rendundancy, it is not especially cheap nor is it especially easy. Maintaining the system gets a bit trickier and simply relying on ssh and grep doesn't cut it any more.

I believe you, but you lost me when it comes to the explanation. What do ssh and grep have to do with adding a hardware encryption card? (I think maybe you're thinking I'm still talking about additional boxes. Recap: My point was that hardware encryption seems to involve kernel/userspace transitions too.)

Quoted 9 lines

Also our own test show that using standard (ie, not neccessarily optimized for routing) Opteron servers and intel e1000, we can saturate
1G easilly (with up to 300Kpps in one direction), with about 10% of a single core working in softirq (50% if conntrack is in the picture). However, with openvpn, we can go up to ~80 Kpps without encryption and in that case, rougly half of the load goes into softirq and the other half goes into userland. Most of the drop from 300 to 80 should be wasted work.

Out of curiosity, did you test the scheduler per
the link supplied by James MacLean?
http://sourceforge.net/mailarchive/forum.php?thread_name=492DBF02.1070305%40ednet.ns.ca&forum_name=openvpn-devel

Karl <[email protected]...>
Free Software: "You don't pay back, you pay forward."
-- Robert A. Heinlein

#9 lore raw

Hi

Quoted 7 lines · Karl O. Pinc
Quoted 1 line · Siim Põder

Karl O. Pinc wrote:

I believe you, but you lost me when it comes to the explanation. What do ssh and grep have to do with adding a hardware encryption card? (I think maybe you're thinking I'm still talking about additional boxes. Recap: My point was that hardware encryption seems to involve kernel/userspace transitions too.)

Yes, I was still talking about additional boxes. HW encryption (as i see it) will not help at all, because by the current design, all packets need to come to userland and go back to kernelland. Most likely to talk to the HW encryption device, another round-trip to kernel space would be needed?

Quoted 3 lines

Out of curiosity, did you test the scheduler per the link supplied by James MacLean?
http://sourceforge.net/mailarchive/forum.php?thread_name=492DBF02.1070305%40ednet.ns.ca&forum_name=openvpn-devel

We use openvpn in p2p setup so this would not be applicable.

Siim

#10 lore raw
Quoted 8 lines · Siim Põder

Yes, I was still talking about additional boxes. HW encryption (as i see
it) will not help at all, because by the current design, all packets need to come to userland and go back to kernelland. Most likely to talk
to the HW encryption device, another round-trip to kernel space would be
needed?

That's what I'm guessing happens in my rudimentary testing.

Karl <[email protected]...>
Free Software: "You don't pay back, you pay forward."
-- Robert A. Heinlein

#11 lore raw
In reply to Siim Põder
Quoted 11 lines · Siim Põder

Hi

Quoted 7 lines · Karl O. Pinc
Quoted 1 line · Siim Põder

Karl O. Pinc wrote:

I believe you, but you lost me when it comes to the explanation. What do ssh and grep have to do with adding a hardware encryption card? (I think maybe you're thinking I'm still talking about additional boxes. Recap: My point was that hardware encryption seems to involve kernel/userspace transitions too.)

Quoted 5 lines

Yes, I was still talking about additional boxes. HW encryption (as i see it) will not help at all, because by the current design, all packets need to come to userland and go back to kernelland. Most likely to talk to the HW encryption device, another round-trip to kernel space would be needed?

It's very important to separate between HW encryption boxes (so called HSM's) and HW encryption accelerators. The HSM variant, which I have the impression you are talking about does encryption as well, but are also suitable for more high security encryption key management as well, with automatic key rotation, key access control, etc, etc.

The HW encryption accelerator is very often a PCI card (might be they exists in ISA as well). These cards can basically only do encryption/decryption and that's it.

An HSM is very often connected to a network, and uses the TCP/IP stack as the primary interface, thus giving a much more overhead in the packets being sent to the device. The advantage of an HSM is that it does safe and efficient encryption and decryption of bigger payloads.

The HW accelerator will not have that extreme processing power as an HSM, but as they are working on the same internal bus as the rest of the hardware and closer to the encryption/decryption needing software, it can transfer smaller packages much more quickly and process smaller packages quicker than an HSM. I believe many of the accelerators also supports DMA, which practically gives it instant access to the user memory region where the payload is stored, without giving the CPU too much extra work.

So for the HW accelerator in an OpenVPN setting, it will be kernel/user copy when a package is received on the input NIC and data is moved to user memory. The HW accelerator will process the user memory data and return it here, without involving the CPU too much. The CPU will move the processed data from user memory to the output NIC.

With an HSM, the data will be needed to be copied from input NIC to user memory, the application will establish a connection to HSM, copy user memory to kernel space and push the data to the NIC where the HSM is located. Further a similar thing happens when the HSM has processed the data.

So in this regard, I do not see any advantage of having an HSM processing VPN data, as the overhead will be the biggest disadvantage. But it will be suitable on bigger bulk jobs or jobs requiring strict key management. And for HW accelerator, it will be much more efficient, as it can work more independently in user memory (outside kernel space) and the driver will just signal the main process when data is ready.

This is at least how I've understood things works ... I'm not claiming I'm right. It might be I've even misunderstood some bigger parts here as well :)

kind regards,

David Sommerseth

Quoted 18 lines
Quoted 3 lines

Out of curiosity, did you test the scheduler per the link supplied by James MacLean?
http://sourceforge.net/mailarchive/forum.php?thread_name=492DBF02.1070305%40ednet.ns.ca&forum_name=openvpn-devel

We use openvpn in p2p setup so this would not be applicable.

Siim

------------------------------------------------------------------------------
Register Now & Save for Velocity, the Web Performance & Operations Conference from O'Reilly Media. Velocity features a full day of expert-led, hands-on workshops and two days of sessions from industry leaders in dedicated Performance & Operations tracks. Use code vel09scf and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
_______________________________________________
Openvpn-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

#12 lore raw

Hi

Quoted 7 lines · David Sommerseth

The HW accelerator will not have that extreme processing power as an HSM, but as they are working on the same internal bus as the rest of the hardware and closer to the encryption/decryption needing software, it can transfer smaller packages much more quickly and process smaller packages quicker than an HSM. I believe many of the accelerators also supports DMA, which practically gives it instant access to the user memory region where the payload is stored, without giving the CPU too much extra work.

Are you sure crypto accelerators allow DMA from user memory? I don't know for sure either, but I would suspect that they would work like any other device: copy to kernel, DMA to device, DMA back to kernel, copy to user.

Siim

#13 lore raw
Quoted 4 lines · Siim Põder

Are you sure crypto accelerators allow DMA from user memory? I don't know for sure either, but I would suspect that they would work like any other device: copy to kernel, DMA to device, DMA back to kernel, copy to user.

Devices don't care if memory belongs to user or kernel. Unless the kernel restricts the device with an IOMMU; but that is still unusual when it comes to PC's.

/Benny

#14 lore raw
Quoted 4 lines · Benny Amorsen
Quoted 2 lines · Siim Põder

Are you sure crypto accelerators allow DMA from user memory? I don't know for sure either, but I would suspect that they would work like

Quoted 8 lines

any

Quoted 1 line

other device: copy to kernel, DMA to device, DMA back to kernel,

copy to

Quoted 1 line

user.

Devices don't care if memory belongs to user or kernel. Unless the kernel restricts the device with an IOMMU; but that is still unusual when it comes to PC's.

Doesn't the kernel care whether userspace has direct access to hardware? Seems to me that the kernel does more than abstract hardware, it also protects hardware by managing concurrency and so forth and protects the entire system by keeping users from doing things with hardware that interfere with other processes. (E.g. bypassing the VM and doing DMA direct into somebody else's address space.) Direct userspace access to hardware violates these principals. Why would HW crypto accelerators be different and not require kernel mediation?

Karl <[email protected]...>
Free Software: "You don't pay back, you pay forward."
-- Robert A. Heinlein

#15 lore raw
Quoted 2 lines · Karl O. Pinc

Doesn't the kernel care whether userspace has direct access to hardware?

If userspace has the right privileges, then no. The X server is an example of this.

Quoted 7 lines

Seems to me that the kernel does more than abstract hardware, it also protects hardware by managing concurrency and so forth and protects the entire system by keeping users from doing things with hardware that interfere with other processes. (E.g. bypassing the VM and doing DMA direct into somebody else's address space.) Direct userspace access to hardware violates these principals. Why would HW crypto accelerators be different and not require kernel mediation?

Kernel mediation doesn't require DMA to go through kernel space. That's what zero copy is all about.

/Benny