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

Loop: Unable to startup at all with Network support #120

Closed
alessio-proietti opened this issue Mar 28, 2021 · 7 comments
Closed

Loop: Unable to startup at all with Network support #120

alessio-proietti opened this issue Mar 28, 2021 · 7 comments

Comments

@alessio-proietti
Copy link
Contributor

alessio-proietti commented Mar 28, 2021

Hi I run (with and without sudo..):

$ qemu-system-x86_64 -cpu qemu64,apic,fsgsbase,rdtscp,xsave,fxsr
-enable-kvm -display none -smp 1 -m 1G -serial stdio
-kernel rusty-loader/target/x86_64-unknown-hermit-loader/debug/rusty-loader
-initrd hello_world/target/x86_64-unknown-hermit/debug/hello_world
-netdev tap,id=net0,ifname=tap10,script=no,downscript=no,vhost=on
-device virtio-net-pci,netdev=net0,disable-legacy=on

on an hello world app with this main.rs:

// src/main.rs

#[cfg(target_os = "hermit")]
extern crate hermit_sys;

fn main() {
println!("Hello World!");
}

with this Cargo.toml:

[package]
name = "hello_world"
version = "0.1.0"
authors = ["Alessio Proietti alessio.proietti@protonmail.com"]
edition = "2018"

{comment #} See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[target.'cfg(target_os = "hermit")'.dependencies.hermit-sys]
version = "0.1.*"
default-features = false
features = ["smoltcp"]

[profile.release]
opt-level = 3

[profile.dev]
opt-level = 1

But there's no way for it to start correctly (I created the virtual net bridge as for documentation), that's what happens:

[LOADER] Loader: [0x100000 - 0x336018]
[LOADER] Found Multiboot information at 0x9500
[LOADER] Found module: [0x338000 - 0x1872228]
[LOADER] Module length: 0x153a228
[LOADER] Found an ELF module at 0x338000
[LOADER] Map 200 pages at 0x338000 (page size 4 KByte)
[LOADER] Map 11 pages at 0x400000 (page size 2048 KByte)
[LOADER] Allocating 0x268 bytes at 0x133840, index 0
[LOADER] Allocating 0x8B8 bytes at 0x133AC0, index 640
[LOADER] Allocating 0xD0 bytes at 0x1343C0, index 2944
[LOADER] Allocating 0xE0 bytes at 0x1344C0, index 3200
[LOADER] This is a supported HermitCore Application
[LOADER] Found entry point: 0x705c0
[LOADER] File Size: 1122048 Bytes
[LOADER] Mem Size: 1206144 Bytes
[LOADER] start 0x338000, size 0x126780
[LOADER] Load HermitCore Application at 0x1a00000
[LOADER] Found TLS starts at 0x1afabb8 (size 120 Bytes)
[LOADER] BootInfo located at 0x333a90
[LOADER] Use stack address 0x3f8000
[LOADER] Jumping to HermitCore Application Entry Point at 0x4705c0
[0][INFO] Welcome to HermitCore-rs 0.3.48
[0][INFO] Kernel starts at 0x400000
[0][INFO] BSS starts at 0x512000
[0][INFO] TLS starts at 0x1afabb8 (size 120 Bytes)
[0][INFO] Found Multiboot info at 0x9500
[0][INFO] Found cmdline at 0x33704b (size 68)
[0][INFO] Total memory size: 63 MB
[0][INFO] Kernel region: [0x400000 - 0x600000]
[0][INFO] A pure Rust application is running on top of HermitCore!
[0][INFO] Heap: size 48 MB, start address 0x600000
[0][INFO] Heap is located at 0x600000 -- 0x3600000 (0 Bytes unmapped)
[0][INFO]
[0][INFO] ===================== PHYSICAL MEMORY FREE LIST ======================
[0][INFO] 0x00000003600000 - 0x00000003FE0000
[0][INFO] ======================================================================
[0][INFO]
[0][INFO]
[0][INFO] ================== KERNEL VIRTUAL MEMORY FREE LIST ===================
[0][INFO] 0x00000003600000 - 0x00800000000000
[0][INFO] ======================================================================
[0][INFO]
[0][INFO]
[0][INFO] ========================== CPU INFORMATION ===========================
[0][INFO] Model: QEMU Virtual CPU version 2.5+
[0][INFO] Frequency: 2386 MHz (from Measurement)
[0][INFO] SpeedStep Technology: Not Available
[0][INFO] Features: MMX SSE SSE2 SSE3 MCE FXSR XSAVE RDTSCP CLFLUSH HYPERVISOR
[0][INFO] Physical Address Width: 40 bits
[0][INFO] Linear Address Width: 48 bits
[0][INFO] Supports 1GiB Pages: No
[0][INFO] ======================================================================
[0][INFO]
[0][INFO] HermitCore-rs booted on 2021-03-28 at 12:48:44
[0][ERROR] General Protection (#GP) Exception: ExceptionStackFrame {
instruction_pointer: 0x437ca0,
code_segment: 0x8,
cpu_flags: 0x46,
stack_pointer: 0x3ff338,
stack_segment: 0x10,
}, error 0x0
[0][ERROR] fs = 0x1, gs = 0x1

and then it continues to loop printing

[0][ERROR] General Protection (#GP) Exception: ExceptionStackFrame {
instruction_pointer: 0x437ca0,
code_segment: 0x8,
cpu_flags: 0x2,
stack_pointer: 0x3ff080,
stack_segment: 0x10,
}, error 0x0
[0][ERROR] fs = 0x1, gs = 0x1

ad infinitum changin' only the stack pointer...

I can't make any sense out of it.

lscpu out:

Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
Address sizes: 39 bits physical, 48 bits virtual
CPU(s): 4
On-line CPU(s) list: 0-3
Thread(s) per core: 2
Core(s) per socket: 2
Socket(s): 1
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 69
Model name: Intel(R) Core(TM) i7-4500U CPU @ 1.80GHz
Stepping: 1
CPU MHz: 1194.586
CPU max MHz: 3000,0000
CPU min MHz: 800,0000
BogoMIPS: 4788.97
Virtualization: VT-x
L1d cache: 64 KiB
L1i cache: 64 KiB
L2 cache: 512 KiB
L3 cache: 4 MiB
NUMA node0 CPU(s): 0-3
Vulnerability Itlb multihit: KVM: Mitigation: VMX disabled
Vulnerability L1tf: Mitigation; PTE Inversion; VMX conditional cache flushes, SMT vulnerable
Vulnerability Mds: Mitigation; Clear CPU buffers; SMT vulnerable
Vulnerability Meltdown: Mitigation; PTI
Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl and seccomp
Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2: Mitigation; Full generic retpoline, IBPB conditional, IBRS_FW, STIBP conditional, RSB filling
Vulnerability Srbds: Mitigation; Microcode
Vulnerability Tsx async abort: Not affected
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc
arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4
_1 sse4_2 movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm cpuid_fault epb invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriori
ty ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt dtherm ida arat pln pts md_clear flush_l1d

@alessio-proietti
Copy link
Contributor Author

alessio-proietti commented Apr 8, 2021

I had to comment out

[target.'cfg(target_os = "hermit")'.dependencies.hermit-sys]
version = "0.1.*"
#default-features = false
features = ["smoltcp"]

And now it seems to run without falling into exception....
Is it meaningful ? @stlankes

If it is ok I can update the documentation beyond what I did there #119.
What is going on?

[0][INFO] Network driver successfully initalized virtqueues.
[0][INFO] Device specific initalization for Virtio network defice 1041 finished
[0][INFO] Network device with id 1041, has been initalized by driver!
[0][INFO] Virtio-net link is up after initalization.
[0][INFO] Virtio network driver initalized with Virtio network device.
[0][INFO] Install virtio interrupt handler at line 11
[INFO] Spawn network thread with id 2
[INFO] MAC address 52-54-00-12-34-56
[INFO] Configure network interface with address 10.0.5.100/24
[INFO] Configure gateway with address 10.0.5.1
[INFO] MTU: 1500 bytes
Hello World!
[0][INFO] Number of interrupts
[0][INFO] [0][7]: 3
[0][INFO] Shutting down system

@stlankes
Copy link
Contributor

Sorry, some times I don't get email about new issues.

Do you solve this issue? I can write a small tutorial to describe the setup.

@alessio-proietti
Copy link
Contributor Author

alessio-proietti commented May 19, 2021

It could be very useful having a tutorial, If I can help lmk

Anyway No, the issue is not resolved as of now. FUrthermore, Now with latest version and same build I Have another error, this:

[0][INFO] Feature set wanted by network driver are in conformance with specification.
[0][ERROR] Device features set, does not satisfy minimal features needed. Aborting!
[0][ERROR] Virtio networkd driver could not be initialized with device: 1041
[INFO] Spawn network thread with id 2
[WARN] Ethernet interface not available
thread 'main' panicked at 'called Result::unwrap() on an Err value: Error { kind: Other, message: "accept failed" }', src/main.rs:12:29
[0][INFO] Number of interrupts
[0][INFO] [0][7]: 3
[0][INFO] Shutting down system

for the code:

#[cfg(target_os = "hermit")]
extern crate hermit_sys;

use std::net::TcpListener;

fn main() {
let listener = TcpListener::bind("0.0.0.0:7878").unwrap();

for stream in listener.incoming() {
    let stream = stream.unwrap();
    println!("Connection established!");
}

}

@stlankes
Copy link
Contributor

stlankes commented Aug 8, 2021

Sorry, I oversaw it. We revise the network interface. But a tutorial is still missing. I will do it. Do you test our httpd example?

@alessio-proietti
Copy link
Contributor Author

Yes, it doesn't work for me:

thread '<unnamed>' panicked at 'called Result::unwrap()on anErr value: "Network is not initialized!"', /home/<MYUSERDIR>/.cargo/registry/src/github.com-1ecc6299db9ec823/hermit-sys-0.1.23/src/net/mod.rs:177:14

@stlankes
Copy link
Contributor

You are using Qemu and initialized a Tap device?

@alessio-proietti
Copy link
Contributor Author

yes

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

No branches or pull requests

2 participants