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

Initial implementation of ARMv8 support #35

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

Conversation

thomasdangl
Copy link
Collaborator

This PR provides preliminary support of all current features for ARMv8 on Linux.

What remains to be done:

  • Implement support for Windows on ARM
  • Create consistent naming between ARMv8 and AMD64, in particular, avoid the usage of architecture specific names such as CR3

@thomasdangl
Copy link
Collaborator Author

Please note that I also turned off include sorting in clang format in this PR.

Otherwise it will sort the libvmi includes in src/vmi/VmiInitError.h lexicographically, which breaks the include order and prevents the project from compiling...

@rageagainsthepc
Copy link
Member

Please note that I also turned off include sorting in clang format in this PR.

Otherwise it will sort the libvmi includes in src/vmi/VmiInitError.h lexicographically, which breaks the include order and prevents the project from compiling...

This has been fixed some time ago: libvmi/libvmi#995
It's not necessary to include libvmi.h at all anymore when events.h is included.

@thomasdangl
Copy link
Collaborator Author

Thanks for the information. Unfortunately, the libvmi port for ARM is based off this version
libvmi/libvmi@88d281d.

Maybe it would make sense to rebase it onto the current master branch before we continue merging this?

@thomasdangl
Copy link
Collaborator Author

Alright, I have rebased to current libvmi upstream.
So we should be able to keep the sorting in clang-tidy : )

)
set(libvmi_ENABLE_STATIC OFF)
set(libvmi_BUILD_EXAMPLES OFF)
set(ENABLE_STATIC OFF CACHE INTERNAL "")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer the scoped notation instead of internal cache vars.

{
return event.x86_regs->r8;
return (registers_t*)event.x86_regs;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is problematic since it breaks abstraction from libvmi types which was kinda the goal here. Afaik @K-Mayer and @cakeless are currently working on a PR that will expose the InterruptEvent to plugins.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the getRegisters() approach though. It would probably make sense to create an abstract IRegisters class and implement that. (yes, I know it's a lot of boiler plate, I am not happy about that either).

@@ -151,6 +151,9 @@ uint VmiHub::run(const std::unordered_map<std::string, std::vector<std::string>>
}
case VMI_OS_WINDOWS:
{
#if defined(ARM64)
throw new std::runtime_error("No support for Windows on ARM yet.");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
throw new std::runtime_error("No support for Windows on ARM yet.");
throw std::runtime_error("No support for Windows on ARM yet.");

)
set(libvmi_ENABLE_STATIC OFF)
set(libvmi_BUILD_EXAMPLES OFF)
set(ENABLE_STATIC OFF CACHE INTERNAL "")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those are configurable options and it would therefore be confusing if they were not displayed by ccmake.

@@ -164,6 +192,9 @@ set(test_files
test/vmi/LibvmiInterface_UnitTest.cpp
test/vmi/SingleStepSupervisor_UnitTest.cpp)

configure_file(src/config.h.in ${PROJECT_BINARY_DIR}/config.h)
Copy link
Member

@rageagainsthepc rageagainsthepc Sep 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already add some definitions via add_definitions(). It would make sense to consolidate these two methods.

#elif defined(ARM64)
addr_t eventPA;
if (VMI_SUCCESS !=
vmi_pagetable_lookup(vmi, event->arm_regs->ttbr1 & VMI_BIT_MASK(12, 47), event->arm_regs->pc, &eventPA))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer making the bitmask a named constant so it becomes clear what it is supposed to accomplish

@@ -9,7 +9,6 @@
#include <codecvt>
#include <fmt/core.h>
#include <functional>
#include <libvmi/events.h>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you remove this?

@rageagainsthepc
Copy link
Member

@thomasdangl At the moment it is not possible to run CI builds from forks. You need to push your branch to our upstream repo.

@rageagainsthepc
Copy link
Member

Is this PR still relevant? 🤔

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.

2 participants