-
Notifications
You must be signed in to change notification settings - Fork 269
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
feat: add basic loongarch64 support #126
base: main
Are you sure you want to change the base?
Conversation
- Refactor the [repo](https://github.com/aoooos/arceos) code to merge - Use standard toolchain - Fix the compile command
1. Use r21 register to record percpu variable address 2. Add page table description, although la64 does not use page table for the time being. 3. Modify the kernel page table remap part in runtime. la64 does not require remapping.
This commit includes multiple changes aimed at ensuring all apps/task and fs can be supported properly. These edits affect various files within the 'axhal' module and its subdirectories, as well as specific system configuration aspects outlined in the 'loongarch64-qemu-virt.toml' file. fix bugs about percpu, use r21 register; fix bugs about timer interrupt; Simplify saving and restoring trap context;
Since loongarch64 does not seem to have the musl tool chain, here we use the gnu tool chain. 1. add pointer type definition 2. add float definition 3. add setjmp/longjmp
@hky1999 Support for la64 is now complete. Except for the two applications redis and sqlite, which were not tested, other apps have passed. If you have time, please check to see if there are any areas for improvement. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution! Are you still available? Let’s work on merging this PR.
tools/la64/la-qemu.sh
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could it run on the mainline qemu? So we can remove this script.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it can be run on the mainline qemu, but according to existing attempts qemu-system-loongarch64 v7.1 不能正确启动kernel, it is difficult to compile a complete tool chain, so most projects currently use a specific version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about qemu 8.1.3?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main problem is that these versions of qemu require appropriate uefi support. I have not yet tried to compile the latest tool chain. Maybe we can remove the dependency on uefi later, so that there will be no restrictions on the qemu version.
fn is_present(&self) -> bool { | ||
PTEFlags::from_bits_truncate(self.0 as usize).contains(PTEFlags::V) | ||
} | ||
fn is_huge(&self) -> bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reasons for not supporting huge pages?
I will fix these errors. |
rename loongArch64 to loongarch64
Remove unnecessary firmware programs and add help documentation.
@equation314 Do you have time to check and see if there are any other problems? |
Thanks! Please fix conflicts and CI. |
crates/percpu/src/imp.rs
Outdated
@@ -108,6 +110,8 @@ pub fn set_local_thread_pointer(cpu_id: usize) { | |||
core::arch::asm!("mv gp, {}", in(reg) tp) | |||
} else if #[cfg(target_arch = "aarch64")] { | |||
core::arch::asm!("msr TPIDR_EL1, {}", in(reg) tp) | |||
}else if #[cfg(target_arch = "loongarch64")] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add space
@equation314 This CI error may be due to a rust version issue. I'm not very familiar with CI, but it seems that the latest version of rust is used in CI. |
Hello, CI should fit the latest version of Rust, currently I believe it should be Some warnings like this should be fixed.
I try to build this branch tonight.
Could you offer some help or advice with it? Thanks a lot! @Godones |
The Qemu version should be: ❯ qemu-system-loongarch64 --version
QEMU emulator version 6.2.50 (v6.0.0-7567-gac069a8ffb)
Copyright (c) 2003-2022 Fabrice Bellard and the QEMU Project developers You can complie it according to |
scripts/make/qemu.mk
Outdated
@@ -24,7 +24,17 @@ qemu_args-aarch64 := \ | |||
-machine virt \ | |||
-kernel $(OUT_BIN) | |||
|
|||
LOONGARCH_BIOS = tools/la64/loongarch_bios_0310.bin | |||
qemu_args-loongarch64 := \ | |||
-bios $(LOONGARCH_BIOS) \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, I tried both SMP=2 and SMP=4 and they got stucked at different place.
Sorry I haven't try your provided QEMU emulator, I appreciate and admire your excellent work.
But @equation314 suggested that code should run on mainstream QEMU version (by the way I personally do not recommend that the system itself should rely a special BIOS version as loongaarch currently provides), maybe we should have a little discussion about it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to use mainline QEMU with the specific BIOS?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will try it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now, we can use the mainline QEMU for la64.
I discussed the issue of mainline qemu with some teachers at loongarch. They said that mainline qemu cannot currently boot the ELF format kernel. because our kernel is not as complex as Linux, we do not need the information passed by the bios, so here I chose to remove the BIOS dependency and start the kernel directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested it on qemu-8.2.0. The latest rust tool chain seems to cause several programs under apps/c/pthread to fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you provide a list of the current support status of apps?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These apps have not been tested: apps/c/iperf|redis|sqlite3. Other apps have been tested.
Rewrite boot code. Add pci address space definition Fix word errors for platforms/*.toml
@@ -0,0 +1,9 @@ | |||
/// Shutdown the whole system, including all CPUs. | |||
pub fn terminate() -> ! { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any instruction to exit QEMU? This is necessary for CI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't find relevant information on the Internet. Maybe I can ask the engineers at la.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mainline qemu does not have an exit function. Is it possible to use other means to exit qemu from the outside?
tools/la64/README.md
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doc needs to be updated.
tools/la64/la-qemu.sh
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This script is no longer in use.
f488812
to
25d75ce
Compare
I will submit other code about interrupt soon.