qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* Cross Architecture Kernel Modules?
@ 2022-01-18 19:18 Kenneth Adam Miller
  2022-01-19 19:04 ` Alex Bennée
  0 siblings, 1 reply; 6+ messages in thread
From: Kenneth Adam Miller @ 2022-01-18 19:18 UTC (permalink / raw)
  To: QEMU Developers

[-- Attachment #1: Type: text/plain, Size: 703 bytes --]

Hello all,

I just want to pose the following problem:

There is a kernel module for a non-native architecture, say, arch 1. For
performance reasons, the rest of all of the software needs to run natively
on a different arch, arch 2. Is there any way to perhaps run multiple QEMU
instances for the different architectures in such a way to minimize the
cross architecture performance penalty? For example, I would like the
kernel module in one (non-native) QEMU instance to be made available,
literally equivalently, in the second (native) QEMU instance. Would there
be any API or way to map across the QEMU instances so that the non native
arch kernel module could be mapped to the native QEMU instance?

[-- Attachment #2: Type: text/html, Size: 739 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Cross Architecture Kernel Modules?
  2022-01-18 19:18 Cross Architecture Kernel Modules? Kenneth Adam Miller
@ 2022-01-19 19:04 ` Alex Bennée
  2022-01-19 19:42   ` Kenneth Adam Miller
  0 siblings, 1 reply; 6+ messages in thread
From: Alex Bennée @ 2022-01-19 19:04 UTC (permalink / raw)
  To: Kenneth Adam Miller; +Cc: qemu-devel


Kenneth Adam Miller <kennethadammiller@gmail.com> writes:

> Hello all,
>
> I just want to pose the following problem: 
>
> There is a kernel module for a non-native architecture, say, arch 1. For performance reasons, the rest of all of the software needs to run
> natively on a different arch, arch 2. Is there any way to perhaps run multiple QEMU instances for the different architectures in such a way
> to minimize the cross architecture performance penalty? For example, I would like the kernel module in one (non-native) QEMU instance to
> be made available, literally equivalently, in the second (native) QEMU instance. Would there be any API or way to map across the QEMU
> instances so that the non native arch kernel module could be mapped to
> the native QEMU instance?

What you are describing sounds like heterogeneous system modelling which
QEMU only supports in a very limited way (all vCPUs must be the same
base architecture). You can link QEMU's together by way of shared memory
but there is no other wiring together done in that case although some
3rd party forks take this approach.

The kernel module sounds confusing - why would you have a kernel module
that wasn't the same architecture as the kernel you are running?

-- 
Alex Bennée


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Cross Architecture Kernel Modules?
  2022-01-19 19:04 ` Alex Bennée
@ 2022-01-19 19:42   ` Kenneth Adam Miller
  2022-01-19 23:04     ` Kenneth Adam Miller
  2022-01-20 10:26     ` Peter Maydell
  0 siblings, 2 replies; 6+ messages in thread
From: Kenneth Adam Miller @ 2022-01-19 19:42 UTC (permalink / raw)
  To: Alex Bennée; +Cc: QEMU Developers

[-- Attachment #1: Type: text/plain, Size: 1563 bytes --]

The source for it isn't available in order that it be compiled to the
desired architecture.

What 3rd party forks take this approach?

On Wed, Jan 19, 2022 at 2:06 PM Alex Bennée <alex.bennee@linaro.org> wrote:

>
> Kenneth Adam Miller <kennethadammiller@gmail.com> writes:
>
> > Hello all,
> >
> > I just want to pose the following problem:
> >
> > There is a kernel module for a non-native architecture, say, arch 1. For
> performance reasons, the rest of all of the software needs to run
> > natively on a different arch, arch 2. Is there any way to perhaps run
> multiple QEMU instances for the different architectures in such a way
> > to minimize the cross architecture performance penalty? For example, I
> would like the kernel module in one (non-native) QEMU instance to
> > be made available, literally equivalently, in the second (native) QEMU
> instance. Would there be any API or way to map across the QEMU
> > instances so that the non native arch kernel module could be mapped to
> > the native QEMU instance?
>
> What you are describing sounds like heterogeneous system modelling which
> QEMU only supports in a very limited way (all vCPUs must be the same
> base architecture). You can link QEMU's together by way of shared memory
> but there is no other wiring together done in that case although some
> 3rd party forks take this approach.
>
> The kernel module sounds confusing - why would you have a kernel module
> that wasn't the same architecture as the kernel you are running?
>
> --
> Alex Bennée
>

[-- Attachment #2: Type: text/html, Size: 1999 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Cross Architecture Kernel Modules?
  2022-01-19 19:42   ` Kenneth Adam Miller
@ 2022-01-19 23:04     ` Kenneth Adam Miller
  2022-01-20 10:18       ` Alex Bennée
  2022-01-20 10:26     ` Peter Maydell
  1 sibling, 1 reply; 6+ messages in thread
From: Kenneth Adam Miller @ 2022-01-19 23:04 UTC (permalink / raw)
  To: Alex Bennée; +Cc: QEMU Developers

[-- Attachment #1: Type: text/plain, Size: 1915 bytes --]

Would it be possible somehow to save the TCG cache, as with user binaries,
but for a kernel module, before then loading that kernel module into memory
the target architecture whether in or outside of QEMU?

On Wed, Jan 19, 2022 at 2:42 PM Kenneth Adam Miller <
kennethadammiller@gmail.com> wrote:

> The source for it isn't available in order that it be compiled to the
> desired architecture.
>
> What 3rd party forks take this approach?
>
> On Wed, Jan 19, 2022 at 2:06 PM Alex Bennée <alex.bennee@linaro.org>
> wrote:
>
>>
>> Kenneth Adam Miller <kennethadammiller@gmail.com> writes:
>>
>> > Hello all,
>> >
>> > I just want to pose the following problem:
>> >
>> > There is a kernel module for a non-native architecture, say, arch 1.
>> For performance reasons, the rest of all of the software needs to run
>> > natively on a different arch, arch 2. Is there any way to perhaps run
>> multiple QEMU instances for the different architectures in such a way
>> > to minimize the cross architecture performance penalty? For example, I
>> would like the kernel module in one (non-native) QEMU instance to
>> > be made available, literally equivalently, in the second (native) QEMU
>> instance. Would there be any API or way to map across the QEMU
>> > instances so that the non native arch kernel module could be mapped to
>> > the native QEMU instance?
>>
>> What you are describing sounds like heterogeneous system modelling which
>> QEMU only supports in a very limited way (all vCPUs must be the same
>> base architecture). You can link QEMU's together by way of shared memory
>> but there is no other wiring together done in that case although some
>> 3rd party forks take this approach.
>>
>> The kernel module sounds confusing - why would you have a kernel module
>> that wasn't the same architecture as the kernel you are running?
>>
>> --
>> Alex Bennée
>>
>

[-- Attachment #2: Type: text/html, Size: 2599 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Cross Architecture Kernel Modules?
  2022-01-19 23:04     ` Kenneth Adam Miller
@ 2022-01-20 10:18       ` Alex Bennée
  0 siblings, 0 replies; 6+ messages in thread
From: Alex Bennée @ 2022-01-20 10:18 UTC (permalink / raw)
  To: Kenneth Adam Miller; +Cc: QEMU Developers


Kenneth Adam Miller <kennethadammiller@gmail.com> writes:

> Would it be possible somehow to save the TCG cache, as with user binaries, but for a kernel module, before then loading that kernel
> module into memory the target architecture whether in or outside of
> QEMU?

OK let me stop you right there - TCG generated code needs a bunch of
runtime support from QEMU itself and is not designed to be run
standalone. All the existing issues with binary kernel modules get
multiplied once you have to account for architecture differences. Even
on the same architecture you can run into problems if the modules use
kernel structures that have changed between releases. Even if the kernel
was compiled for the exact same kernel release you are trying to run it
in changes in fields, padding and layout are going to be an issue.

In short this is not the solution you are looking for. Your time would
be better spent reverse engineering the proprietary module and writing a
open source version of it than trying to get something like this to
work.

Sorry.


>
> On Wed, Jan 19, 2022 at 2:42 PM Kenneth Adam Miller <kennethadammiller@gmail.com> wrote:
>
>  The source for it isn't available in order that it be compiled to the desired architecture.
>
>  What 3rd party forks take this approach?
>
>  On Wed, Jan 19, 2022 at 2:06 PM Alex Bennée <alex.bennee@linaro.org> wrote:
>
>  Kenneth Adam Miller <kennethadammiller@gmail.com> writes:
>
>  > Hello all,
>  >
>  > I just want to pose the following problem: 
>  >
>  > There is a kernel module for a non-native architecture, say, arch 1. For performance reasons, the rest of all of the software
>  needs to run
>  > natively on a different arch, arch 2. Is there any way to perhaps run multiple QEMU instances for the different architectures in
>  such a way
>  > to minimize the cross architecture performance penalty? For example, I would like the kernel module in one (non-native) QEMU
>  instance to
>  > be made available, literally equivalently, in the second (native) QEMU instance. Would there be any API or way to map across
>  the QEMU
>  > instances so that the non native arch kernel module could be mapped to
>  > the native QEMU instance?
>
>  What you are describing sounds like heterogeneous system modelling which
>  QEMU only supports in a very limited way (all vCPUs must be the same
>  base architecture). You can link QEMU's together by way of shared memory
>  but there is no other wiring together done in that case although some
>  3rd party forks take this approach.
>
>  The kernel module sounds confusing - why would you have a kernel module
>  that wasn't the same architecture as the kernel you are running?
>
>  -- 
>  Alex Bennée


-- 
Alex Bennée


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Cross Architecture Kernel Modules?
  2022-01-19 19:42   ` Kenneth Adam Miller
  2022-01-19 23:04     ` Kenneth Adam Miller
@ 2022-01-20 10:26     ` Peter Maydell
  1 sibling, 0 replies; 6+ messages in thread
From: Peter Maydell @ 2022-01-20 10:26 UTC (permalink / raw)
  To: Kenneth Adam Miller; +Cc: Alex Bennée, QEMU Developers

On Wed, 19 Jan 2022 at 19:53, Kenneth Adam Miller
<kennethadammiller@gmail.com> wrote:
>
> The source for it isn't available in order that it be compiled to the desired architecture.

In general kernel modules need to be built not just for the right architecture
but even for the specific kernel version you're going to load them into.

In theory you could perhaps build QEMU into the native system kernel and
have it act as a shim between non-native kernel modules (this has been done
for UEFI modules before). But you would (unlike the UEFI case) run into
incompatibilities in data structure layouts in memory. In general it would
be a lot of work; it is certainly not something QEMU is anywhere near
being able to do today. I doubt it's something that either the upstream
kernel folks nor upstream QEMU would be interested in either.

The best approach would be to get the source for the kernel module.

-- PMM


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-01-20 13:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-18 19:18 Cross Architecture Kernel Modules? Kenneth Adam Miller
2022-01-19 19:04 ` Alex Bennée
2022-01-19 19:42   ` Kenneth Adam Miller
2022-01-19 23:04     ` Kenneth Adam Miller
2022-01-20 10:18       ` Alex Bennée
2022-01-20 10:26     ` Peter Maydell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).