-
Notifications
You must be signed in to change notification settings - Fork 158
aws-nitro: Separate guest kernel module loading, updates #549
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
Merged
tylerfanelli
merged 4 commits into
containers:main
from
tylerfanelli:awsnitro-init-modules
Feb 25, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
e5bad94
Makefile: Add -s flag to awsnitro init binary
tylerfanelli 0f6eaf8
init/awsnitro: Update error message
tylerfanelli 03583e6
awsnitro: Start debug output earlier in boot
tylerfanelli b622ba8
init/aws-nitro: Separate linux module loading
tylerfanelli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| #ifndef _KRUN_MOD_LOADING_H | ||
| #define _KRUN_MOD_LOADING_H | ||
|
|
||
| int mods_load(void); | ||
|
|
||
| #endif // _KRUN_MOD_LOADING_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| #include <dirent.h> | ||
| #include <errno.h> | ||
| #include <fcntl.h> | ||
| #include <stddef.h> | ||
| #include <stdio.h> | ||
| #include <string.h> | ||
| #include <sys/syscall.h> | ||
| #include <unistd.h> | ||
|
|
||
| #include "include/mod.h" | ||
|
|
||
| #define KRUN_LINUX_MODS_DIR_NAME "/krun_linux_mods" | ||
tylerfanelli marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| #define MOD_FILE_NAME_BUF_SIZE 256 | ||
|
|
||
| #define finit_module(fd, param_values, flags) \ | ||
| (int)syscall(__NR_finit_module, fd, param_values, flags) | ||
|
|
||
| /* | ||
| * Load a kernel module. | ||
| */ | ||
| static int mod_load(const char *path) | ||
| { | ||
| int fd, ret; | ||
|
|
||
| // Open and load the kernel module. | ||
| fd = open(path, O_RDONLY | O_CLOEXEC); | ||
| if (fd < 0) { | ||
| if (errno == ENOENT) | ||
| return 0; | ||
|
|
||
| fprintf(stderr, "open module %s (errno %d)\n", path, errno); | ||
| return -errno; | ||
| } | ||
|
|
||
| ret = finit_module(fd, "", 0); | ||
| if (ret < 0) { | ||
| close(fd); | ||
| fprintf(stderr, "init module %s (errno %d)\n", path, errno); | ||
| return -errno; | ||
| } | ||
|
|
||
| // Close the file descriptor and remove the module file. | ||
| ret = close(fd); | ||
| if (ret < 0) { | ||
| fprintf(stderr, "close module %s (errno %d)\n", path, errno); | ||
| return -errno; | ||
| } | ||
|
|
||
| ret = unlink(path); | ||
| if (ret < 0) { | ||
| fprintf(stderr, "unlink module %s (errno %d)\n", path, errno); | ||
| return -errno; | ||
| } | ||
|
|
||
| return 0; | ||
| } | ||
|
|
||
| /* | ||
| * Load the configured kernel modules. | ||
| */ | ||
| int mods_load(void) | ||
| { | ||
| char path[MOD_FILE_NAME_BUF_SIZE + sizeof(KRUN_LINUX_MODS_DIR_NAME) + 1]; | ||
| struct dirent *entry; | ||
| int ret; | ||
| DIR *dir; | ||
|
|
||
| ret = 0; | ||
|
|
||
| dir = opendir(KRUN_LINUX_MODS_DIR_NAME); | ||
| if (dir != NULL) { | ||
| while ((entry = readdir(dir)) != NULL) { | ||
| /* | ||
| * Ignore the "." and ".." directory entries, as they are not kernel | ||
| * modules. | ||
| */ | ||
| if (strcmp(entry->d_name, ".") == 0 || | ||
| strcmp(entry->d_name, "..") == 0) | ||
| continue; | ||
|
|
||
| // Copy the full path of the module file. | ||
| snprintf(path, sizeof(path), "%s/%s", KRUN_LINUX_MODS_DIR_NAME, | ||
| entry->d_name); | ||
| ret = mod_load(path); | ||
| if (ret < 0) | ||
| break; | ||
| } | ||
| closedir(dir); | ||
tylerfanelli marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } else if (errno != ENOENT) { | ||
| ret = -errno; | ||
| perror("unable to open kernel module configuration directory"); | ||
| } | ||
|
|
||
| return ret; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.