Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it work in modern kernels #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Spacefish
Copy link

not sure if it works :)

@volagtik
Copy link

not sure if it works :)

): it does not, for me at least. Errors are the same, just on different lines, in functions ‘fh_ftrace_thunk’ and ‘fh_install_hook’ in trap_hook.c file. It's all way above my skill, but I might get it if someone explains. Mind taking a look-see?
opemu-spacefish-errors.txt

@zhubr
Copy link

zhubr commented Feb 19, 2024

You need to add a specialized hook in the kernel and then arrange the module so as to employ it. Not sure why such hook is not readily available in regular kernels, but the patch to add it is quite straightforward, and apparently it is the only reliable way to do it nowadays. Please see attachment that works fine for me. Besides, I've found and fixed some small bugs in opcode processing but because the main repo looks like abandoned I'm not sure where to push the fixes yet. The attached patch is targeted for regular kernel 5.15.146.

unlock_opcode_emu.txt

@blogdron
Copy link

blogdron commented Mar 1, 2024

Ooops. op_emu legal??????????????????
TL;DR
1- op_emu under GPLv2 License
2- op_emu take code from xnu-amd repo
3- xnu-amd under ASPL2.0 License
4- ASPL2.0 not compatibility with GPLv2 op_emu module use linux GPL symbols.... wtf :D
https://www.gnu.org/philosophy/apsl.html

just noticed this inconsistency, lol . Or I mistake?

WTF

@zhubr
Copy link

zhubr commented Mar 1, 2024

I'm definitely not a lawyer, but after browsing through some relevant headers and license files, I'd say it looks like attaching the GPL was incorrect here. This certainly does NOT make the code itself illegal, as it is a fork of some master tree that obviously allowed forking by its license. Therefore, it might be problematic to e.g. include this module as a part of some distribution product or to upstream it. But other than that, I basically see no problem. Just apply appropriate correction to the license file and that's it.

@blogdron
Copy link

blogdron commented Mar 1, 2024

@zhubr maybe but no, 1 author have ASPL but @mirh lisense own code under GPLv2. I no can change license back to ASPL because code in this project have code from @mirh.

At the moment, code from two authors under incompatible licenses is mixed in one project. You can’t just take your previous license and return it. The code is mixed. I'm deleting my fork and all my work. If anyone needs changes, they are saved in a closed merge request. It's a pity. But okay.

@mirh
Copy link
Owner

mirh commented Mar 1, 2024

Not sure what's funnier.. That I wasn't subscribed to my own repo, or that my hunger for pedantry (that brought me into spending big time to find the credits for every single line) somehow made the code turn out unproperly copyrighted.
Anyhow, I don't really think there is any big deal (except perhaps having to remove the LICENSE file).

Even if the standard terms applied (which I don't really think is the case, even though it's not explicitly stated anywhere) you can mix whatever you want with GPL as long as you aren't shipping the actual binaries that "physically" bind together the different object code.
Hopefully @kalifans @sinetek @andyvand can clarify and WTFPLify their thing.

@blogdron
Copy link

blogdron commented Mar 1, 2024

Not sure what's funnier.. That I wasn't subscribed to my own repo

:D

@zhubr
Copy link

zhubr commented Mar 2, 2024

Not sure what's funnier.. That I wasn't subscribed to my own repo, or that my hunger for pedantry (that brought

Hi! I'll use this opportunity to say tons of thanks for publishing this module! It lets me run Android x86_64 image on an old Core2 laptop which would otherwise be impossible because of some few opcodes missing. And BTW I'd like to give back a small usermode test and some bugfixes :)

@mirh
Copy link
Owner

mirh commented Mar 3, 2024

It's not even mine actually (I probably broke it more than I fixed), it was originally from a brazilian guy. Which AFAIR was exactly like trying to do something with android (on an athlon or core 2), but then upgraded his system and lost interest.

But speaking of that.. I knew @maurossi used to ship a hacked up workaround at least in the past. Idk what has been of it?

@philmb3487
Copy link

Hello everyone. I am the original author of this code. My part of it is MIT licensed.
Any questions?

@blogdron
Copy link

blogdron commented Mar 3, 2024

@sinetek Hello. Thank you for your response. On this repo https:/sinetek/xnu-amd license is ASPL 2.0.

Any questions?

@mirh (and we all) can use GPLv2 for this repo https:/mirh/opemu-linux ?

My part of it is MIT licensed.

This files (exclude libudis86 BSD 2 Closure sub-project) https:/sinetek/xnu-amd/tree/master/osfmk/OPEMU not marked as MIT
if files

real under MIT maybe you as author can add MIT notice license in this files (or in LICENSE file )? Because if no have license notice on another file or in source files, all this files licensed under global project license -> ASPL 2.0

Sorry for my English. I hope you understand me :)

Maybe someone else will say something else about this.
The idea is simple, have unambiguous licenses for files. To develop a kernel module as MIT or/and GPLv2 .
Now without notice about MIT you code under ASPL 2.0... it okeyy but Im(and all others peoples) for example no can legal give to my friend binary module for Linux kernel :)

Maybe i just stupid i don't know :D

@mirh
Copy link
Owner

mirh commented Mar 4, 2024

On this repo https:/sinetek/xnu-amd license is ASPL 2.0.

The mac kernel is licensed with that, yes. But his modifications are MIT licensed, so we are good (and udis86 is licensed with BSD-2, so ditto).

So, the only things left is how much of Copyright © 2019 Meowthra was brought in to modify that (but we could even lowkey assume that's GPL, since it was eventually meant to fit into a kernel module), and finding what's the situaiton with AnV's work I brought in with d2610de

@philmb3487
Copy link

These licenses should all be compatible, with the notable exception of GPL, but I don't see how the GPL is relevant here?

@zhubr
Copy link

zhubr commented Mar 5, 2024

These licenses should all be compatible, with the notable exception of GPL, but I don't see how the GPL is relevant here?

It is (GPL 2.0) present in the topmost LICENSE file of this repository, causing some confusion and panic to people.

@mirh
Copy link
Owner

mirh commented Mar 5, 2024

And it's the expected license of compiled linux modules.

@zhubr
Copy link

zhubr commented Mar 5, 2024

And it's the expected license of compiled linux modules.

Well, if you intend to ship/share this module in binary form, yes. But imho this is becoming increasingly unlikely for a number of reasons anyway. Otherwise, for just publishing your module source, the license can be just anything (afaik).

@philmb3487
Copy link

And it's the expected license of compiled linux modules.

Well, if you intend to ship/share this module in binary form, yes. But imho this is becoming increasingly unlikely for a number of reasons anyway. Otherwise, for just publishing your module source, the license can be just anything (afaik).

That's nonsense. NVIDIA's drivers do not ship GPL for example

@blogdron
Copy link

blogdron commented Mar 7, 2024

Since it turned out that the files written by @sinetek are under the MIT license, as he said, then using only them in this project does not affect the code under ASPL 2.0 and therefore the current GPLv2 license that @mirh chose for his changes does not cause any problems. So everything is fine and I panicked in vain. The only thing is that there is no mention of MIT in the files listed above, and if @sinetek allows (after all, he wrote the code), then the text of the MIT license could be added to these files, this would solve all the theoretical problems. Since the license cannot be implied, it must be explicit and explicitly stated. Yes, sometimes it’s just unnecessary bureaucracy. And we're all here for the fun.

Sorry if my remark on licensing caused discomfort for someone :D

The point is that I thought that the current GPL project contained code under ASPL, but judging by the author's response, this is not the case. So there are no problems.

@philmb3487
Copy link

philmb3487 commented Mar 12, 2024 via email

@blogdron
Copy link

He can do that for his work, but I don't think he can relicense my whole project.?

No one has the right to license someone else's code except the author. Licenses can only be compatible and different code under different licenses can exist in one project licensed as a work under any license compatible with all other licenses. At the moment, some licenses are not indicated explicitly in the text, but only indirectly in words.
At the same time, the words are one thing, but the text of the project licenses is another.

As a result, everything got confused. I can use code under the MIT license in my project under the GPL license, for example, but this does not mean that I relicense the MIT code under the GPL license, it means that the project as a whole is under the GPL, but part of the code is under the MIT license, this is possible because the licenses are compatible. That's all.

The problem is that the code under ASPL is incompatible with the GPL, and the words that your changes are under MIT (this solves all problems) are just words and the text of the license for your code is not explicitly indicated, this creates confusion.

  • 1 The license, if any, must be attached to the code
  • 2 Licenses within one project must be compatible
  • 3 The author can give another project a different license if he wants
  • 4 Anyone who took someone else's code under a different license does not have the right to change the license, but can use the code under any compatible license.

I'm not a lawyer. These are just my thoughts.

Above I listed the files used in this project, if the author of these files claims that they are under MIT, and not under ASPL, then there are no problems and you just need to add the license text and the author’s copyright to these files, otherwise everything is ambiguous.

I will not speak further on this matter. I think everything is clear to everyone.

@volagtik
Copy link

@zhubr, since it doesn't seem to be illegal, could you please help me build it? I've patched the kernel to add the hook but have no idea what it is or how to arrange the module so as to employ it.
Trying to build it on a 32bit SSE2 Pentium M with patched kernel:
opemu-spacefish-errors-patched.txt

@zhubr
Copy link

zhubr commented Mar 17, 2024

@zhubr, since it doesn't seem to be illegal, could you please help me build it? I've patched the kernel to add the hook but have no idea what it is or how to arrange the module so as to employ it. Trying to build it on a 32bit SSE2 Pentium M with patched kernel

When using a patched kernel (with setup_invalid_op_handler function added) you can apply the following patch to this module:

trap_hook.txt

@volagtik
Copy link

When using a patched kernel (with setup_invalid_op_handler function added) you can apply the following patch to this module:

trap_hook.txt

Thanks, that fixed that, but now I have an error in opemu.c:254 *where = ss64 -> r8; about struct pt_regs not having members named r8 to r15.
Is it even supposed to work on 32bit arch?
opemu_c-error.txt

@zhubr
Copy link

zhubr commented Mar 19, 2024

Thanks, that fixed that, but now I have an error in opemu.c:254 *where = ss64 -> r8; about struct pt_regs not having members named r8 to r15. Is it even supposed to work on 32bit arch? opemu_c-error.txt

I haven't tried in 32-bit. Some details in the sources suggest that it was likely possible at some point. Moreover, 64-bit registers support in current version is actually incomplete and somewhat buggy. Some ifdefs might be necessary.

I'd still like to hear if @mirh is interested in PRs and patches to this repository and willing to fix GPL/ASPL confusion by either updating the top LICENSE file or inserting license headers to individual source files so as to clear any subsequent doubts. Or, if not, maybe I'll clone and try to fix it myself (but no promises).

@mirh
Copy link
Owner

mirh commented Mar 21, 2024

FWIW I can even add you to the project.. I try to even stay away from linux these days, and it's not like even back then I understood much about registers and opcodes.

As for the license, I just realized that we've had a problem here. We couldn't just wave away Meowthra's code because he literally wrote "all rights reserved" (which I guess legally isn't much different from just any generic copyright notice, but practically it rules out any other alternative good faith interpretation)

@zhubr
Copy link

zhubr commented May 5, 2024

Ok, if you are not really interested in maintaining this project anymore, I think I'll better just clone the repository. I'll then eventually try to insert the missing license headers where possible or maybe remove some files. AFAICS as compared to xnu-amd there were 4 new files introduced: fpins.*, sse41.c, trap_hook.c. Those 4 files are either unnecessary for my specific needs or have to be completely redesigned anyway.

@mirh
Copy link
Owner

mirh commented May 7, 2024

Maintaining would be doable (even though @saviosg is certainly more qualified than me)
But aside of the 4 brand new added files, there's much more that was changed in the others.
Even though I guess only fpins and trap_ho

opemu-linux/trap_hook.c

Lines 24 to 26 in 4a56f54

MODULE_DESCRIPTION("Intel Instruction set Emulation");
MODULE_AUTHOR("Meowthra");
MODULE_LICENSE("GPL");

Oh, come on. It was eventually all navel gazing for nothing.

@zhubr
Copy link

zhubr commented May 8, 2024

Oh, come on. It was eventually all navel gazing for nothing.

Ok. Thank you again for your work anyway :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants