Hello,
I am a computer science student and my assignment is porting an OS
(pintos, http://www.stanford.edu/class/cs140/) as an unpriviledged Domain.
I''m trying to invoke hypercalls as described in
http://www-user.tu-chemnitz.de/~mien/materialien/sys/04-Hypercalls.pdf
or http://www.o3one.org/xen.html#posp1 by using int 0x82:
------------------------------------------------------------------------
.section __xen_guest
.ascii "GUEST_OS=Mini-OS"
.ascii ",XEN_VER=xen-3.0"
.ascii ",HYPERCALL_PAGE=0x2"
.ascii ",LOADER=generic"
.ascii ",PT_MODE_WRITABLE"
.byte 0
.text
.globl _start
_start:
cld
movl $18, %eax # __Hypervisor_console_io
movl $0, %ebx # CONSOLEIO_write
movl $hello_message_len, %ecx # buffer length
movl $hello_message, %edx # buffer virtual address
int $0x82
movl $6, %eax # __Hypervisor_sched_op_compat
movl $2, %ebx # SCHEDOP_shutdown
movl $0, %ecx # SHUTDOWN_poweroff
int $0x82
hang: jmp hang # shouldn''t get here
hello_message: .ascii "This is the hello world program.\n"
hello_message_len = . - hello_message
------------------------------------------------------------------------
I compile this with:
as -o helloworld.o -a=helloworld.l helloworld.s
ld -Ttext 0x100000 -o helloworld.elf helloworld.o
Unfortunately, i don''t get any output (or better: i don''t know
where the
output goes to). If I check the logs, the domain seems to shut down
normally:
...
[2006-08-13 16:50:53 xend.XendDomainInfo] INFO (XendDomainInfo:818)
Domain has shutdown: name=HelloWorld id=24 reason=poweroff.
...
I have also studied the mini-os in the xen source distribution
(extras/mini-os) and I realized, that hypercalls are calls in specific
entries of a hypercall_page. What is this page and where is it initialized?
Thanks,
Antoine
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
On 13/8/06 4:00 pm, "antoinet" <xen@schoggi.org> wrote:> I compile this with: > > as -o helloworld.o -a=helloworld.l helloworld.s > ld -Ttext 0x100000 -o helloworld.elf helloworld.o > > Unfortunately, i don''t get any output (or better: i don''t know where the > output goes to). If I check the logs, the domain seems to shut down > normally: > > ... > [2006-08-13 16:50:53 xend.XendDomainInfo] INFO (XendDomainInfo:818) > Domain has shutdown: name=HelloWorld id=24 reason=poweroff.Console output doesn''t get logged, but you can connect to the console automatically when the domain is created by adding option -c to the end of your ''xm create'' command line.> I have also studied the mini-os in the xen source distribution > (extras/mini-os) and I realized, that hypercalls are calls in specific > entries of a hypercall_page. What is this page and where is it initialized?It''s now the preferred way of executing hypercalls. Rather than the old way of: mov $hypercall_number,%eax int $0x82 You now do: call hypercall_page + hypercall_number*32 Where ''hypercall_page'' is the virtual address of your hypercall page. In your case your header specifies that the page should be set up at pseudophysical page frame 2, so this will be at virtual address 0x12000. So e.g., ''call 0x12000 + __HYPERVISOR_sched_op*32''. In fact some version of ld don''t relocate absolute targets properly. So you''re better writing the above as ''call _start + 0x2000 + __HYPERVISOR_sched_op*32''. Of course you really want to hide these details behind a C or asm macro. -- Keir _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
On 13/8/06 6:54 pm, "antoinet" <xen@schoggi.org> wrote:>> >> Console output doesn''t get logged, but you can connect to the console >> automatically when the domain is created by adding option -c to the end of >> your ''xm create'' command line. >> >> > > I also tried the -c switch, but i still can''t get any output... Do you > have any idea why it is so? > btw: i also tried to do the HYPERCALL_console_io the new way, i.e. by > calling in the hypercall_page, without success.D''oh, yes of course. The console_io hypercall is intended only for domain0. It sends output to whatever console Xen has open (usually just a serial line after domain0 has booted). Other domains are allowed to use the hypercall only if Xen is built with verbose=y option. But still that''s not useful unless you have a serial line connected or if you tell Xen to keep the vga console after domain0 boots (console=vga[keep]). The usual domU console method is to pick up a console shared page from start_info structure and write console data to a ring buffer embedded in that shared page. See Linux''s driver for an example, or mini-os''s. Possibly Xen should be able to provide a serial-like interface on top of the console shared page, which would make initial OS porting a little easier. It would be something of a layer violation in the system (Xen talking up to dom0) but we do that already for HVM guests so there''s a precedent (albeit one we''d like to get rid of). -- Keir _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
>> I compile this with: >> >> as -o helloworld.o -a=helloworld.l helloworld.s >> ld -Ttext 0x100000 -o helloworld.elf helloworld.o >> >> Unfortunately, i don''t get any output (or better: i don''t know where the >> output goes to). If I check the logs, the domain seems to shut down >> normally: >> >> ... >> [2006-08-13 16:50:53 xend.XendDomainInfo] INFO (XendDomainInfo:818) >> Domain has shutdown: name=HelloWorld id=24 reason=poweroff. >> > > Console output doesn''t get logged, but you can connect to the console > automatically when the domain is created by adding option -c to the end of > your ''xm create'' command line. > >I also tried the -c switch, but i still can''t get any output... Do you have any idea why it is so? btw: i also tried to do the HYPERCALL_console_io the new way, i.e. by calling in the hypercall_page, without success. Thanks, Antoine _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Hollis Blanchard
2006-Aug-14 16:55 UTC
Re: [Xen-devel] console hypercalls (was "How to invoke hypercalls")
On Sun, 2006-08-13 at 18:51 +0100, Keir Fraser wrote:> > The usual domU console method is to pick up a console shared page from > start_info structure and write console data to a ring buffer embedded in > that shared page. See Linux''s driver for an example, or mini-os''s. > > Possibly Xen should be able to provide a serial-like interface on top of the > console shared page, which would make initial OS porting a little easier. It > would be something of a layer violation in the system (Xen talking up to > dom0) but we do that already for HVM guests so there''s a precedent (albeit > one we''d like to get rid of).This would be useful for PowerPC as well. The IBM Power Hypervisor (i.e. the thing shipping on IBM''s "System p" servers) defines the guest console API as read/write hypercalls. It would be nice to emulate those hypercalls so that legacy guests can run on Xen unmodified. However, since the Xen hypervisor currently has no knowledge whatsoever of the format of the console page, we can''t. -- Hollis Blanchard IBM Linux Technology Center _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel