Load program for AP

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
coldfire
Posts: 12
Joined: Tue Apr 11, 2017 3:19 am

Load program for AP

Post by coldfire »

Hello!

I am trying to load in memory some test program (smth like hello world) that will be running on AP.
For this did next:
1. turn off SMP in linux kernel
2. wrote code in userspace that map address from low memory (0x8000) and trying to load there test program ( currently just one arbitrary byte, for this i am using next: https://github.com/izard/RTBench/tree/m ... tal/phymem ).

When I wrote something to 0x8000, I am getting corruption:

Code: Select all

29879.549297]  mac_hid i2c_piix4 vboxguest parport_pc ppdev lp parport autofs4 hid_generic usbhid hid psmouse ahci libahci fjes video e1000 pata_acpi [last unloaded: resmem]
[29879.549347] CPU: 0 PID: 16682 Comm: kworker/0:1 Tainted: G           OE   4.4.0-72-generic #93-Ubuntu
[29879.549351] Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006
[29879.549360] Workqueue: events check_corruption
[29879.549366]  0000000000000286 00000000fc8f8723 ffff880008027d20 ffffffff813f82b3
[29879.549374]  ffff880008027d68 ffffffff81caffd0 ffff880008027d58 ffffffff81081302
[29879.549381]  0000000000000000 ffff880000010000 ffffffff821031f0 0000000000000001
[29879.549389] Call Trace:
[29879.549400]  [<ffffffff813f82b3>] dump_stack+0x63/0x90
[29879.549409]  [<ffffffff81081302>] warn_slowpath_common+0x82/0xc0
[29879.549415]  [<ffffffff8108139c>] warn_slowpath_fmt+0x5c/0x80
[29879.549423]  [<ffffffff8106541f>] check_for_bios_corruption.part.1+0xaf/0x100
[29879.549430]  [<ffffffff81065488>] check_corruption+0x18/0x50
[29879.549438]  [<ffffffff8109a555>] process_one_work+0x165/0x480
[29879.549445]  [<ffffffff8109a8bb>] worker_thread+0x4b/0x4c0
[29879.549451]  [<ffffffff8109a870>] ? process_one_work+0x480/0x480
[29879.549457]  [<ffffffff8109a870>] ? process_one_work+0x480/0x480
[29879.549463]  [<ffffffff810a0be8>] kthread+0xd8/0xf0
[29879.549469]  [<ffffffff810a0b10>] ? kthread_create_on_node+0x1e0/0x1e0
[29879.549479]  [<ffffffff8183ca0f>] ret_from_fork+0x3f/0x70
[29879.549484]  [<ffffffff810a0b10>] ? kthread_create_on_node+0x1e0/0x1e0
[29879.549489] ---[ end trace fa273c1ab0b0e6b7 ]---
[85440.016782] Corrupted low memory at ffff880000008000 (8000 phys) = 00000001

Code: Select all

test@test-VirtualBox:~/Projects/RTBench/tools/src/baremetal/phymem$ sudo ./phymem.x -p 0x8000 -l 0x1
Physical address : 0x8000
length : 0x1
adjust span size to 4K
Memory locations : 

8000: 0000000000
Unmap memory..
test@test-VirtualBox:~/Projects/RTBench/tools/src/baremetal/phymem$ sudo ./phymem.x -p 0x8000 -l 0x1 -w -d 0x1
Physical address : 0x8000
length : 0x1
Memory Write operation
Data : 0x1
adjust span size to 4K
Writing 0x1 to location 0x8000

Unmap memory..
test@test-VirtualBox:~/Projects/RTBench/tools/src/baremetal/phymem$ 
test@test-VirtualBox:~/Projects/RTBench/tools/src/baremetal/phymem$ 
test@test-VirtualBox:~/Projects/RTBench/tools/src/baremetal/phymem$ sudo ./phymem.x -p 0x8000 -l 0x1
Physical address : 0x8000
length : 0x1
adjust span size to 4K
Memory locations : 

8000: 0x00000001
Unmap memory..
test@test-VirtualBox:~/Projects/RTBench/tools/src/baremetal/phymem$ sudo ./phymem.x -p 0x8000 -l 0x1
Physical address : 0x8000
length : 0x1
adjust span size to 4K
Memory locations : 

8000: 0000000000
Unmap memory..
Can U give me some advice?

And another one problem.
When I am trying to set memmap=0x80M$0x18000000 in Linux kernel command line than kernel does not load. Anyone get same problem?

With best,
coldfire
Octocontrabass
Member
Member
Posts: 5587
Joined: Mon Mar 25, 2013 7:01 pm

Re: Load program for AP

Post by Octocontrabass »

If you want to program on bare metal, why aren't you programming on bare metal? Fighting Linux for resources doesn't sound like fun to me.

The error is coming from the low memory corruption check because you're using iopl() to steal memory from the kernel. The error will go away if you use the correct memory allocation API.
coldfire
Posts: 12
Joined: Tue Apr 11, 2017 3:19 am

Re: Load program for AP

Post by coldfire »

Octocontrabass wrote:If you want to program on bare metal, why aren't you programming on bare metal? Fighting Linux for resources doesn't sound like fun to me.
I do not programming on bare metal because of currently want to run simultaneously 2 OS ( Linux and my some bare metal like).
Octocontrabass wrote: The error is coming from the low memory corruption check because you're using iopl() to steal memory from the kernel. The error will go away if you use the correct memory allocation API.
Thanks for answer.
I decided just to turn off this check.

There is just one remained open question about memmap in Linux cmdline.
User avatar
JAAman
Member
Member
Posts: 879
Joined: Wed Oct 27, 2004 11:00 pm
Location: WA

Re: Load program for AP

Post by JAAman »

coldfire wrote: I do not programming on bare metal because of currently want to run simultaneously 2 OS ( Linux and my some bare metal like).
you cannot do this
there is much more to an OS then just control of the CPU, 2 OSes cannot co-exist (the way you are doing it, you will just be running a linux application on a dedicated CPU -- that is not 2 OSes, that is linux and a linux application -- if what you run on the other CPU is anything other than a linux application, your computer will crash, and it might be physically damaged, and possibly start a fire)
User avatar
IanSeyler
Member
Member
Posts: 326
Joined: Mon Jul 28, 2008 9:46 am
Location: Ontario, Canada
Contact:

Re: Load program for AP

Post by IanSeyler »

Did someone say BareMetal? :wink:

coldfire, you may be interested in trying BareMetal OS if you want to experiment with running code on different APs. In the next version I'll be removing the SMP work queue so workloads can be assigned directly to specific APs.

-Ian
BareMetal OS - http://www.returninfinity.com/
Mono-tasking 64-bit OS for x86-64 based computers, written entirely in Assembly
coldfire
Posts: 12
Joined: Tue Apr 11, 2017 3:19 am

Re: Load program for AP

Post by coldfire »

Thanks for answers.

I will look at ReturnInfinity/BareMetal-OS!
Post Reply