Hello all, I added a hypercall "do_greet" that only prints "Hello world" to do a small experiment. After it prints the "hello world", I would it to exit from Xen and stop current process. For instance: the hypercall is like this: int do_greet(){ pirntk("Hello world\n"); /*then I would it exit from Xen and stop current process that called it.*/ exit_?? //exit(0) does not work. } If a process at the application level calls this hypercall through privcmd file, I would like it kill this process after the hypercall prints "Hello world". Then how to do that? In linux kernel, there is a function exit_kernel, which switch the kernel address space into the user address space. But I did not find any similar function in Xen. Any idea? thanks -- Best Regards, Baozeng Ding OSTG,NFS,ISCAS
George Dunlap
2011-Dec-01 11:30 UTC
Re: any exit function in xen that is similar to exit_kernel?
On Tue, Nov 29, 2011 at 2:22 PM, Baozeng <sploving1@gmail.com> wrote:> Hello all, > I added a hypercall "do_greet" that only prints "Hello world" to do a > small experiment. After it prints the "hello world", I would it to > exit from Xen and stop current process. For instance: > the hypercall is like this: > int do_greet(){ > pirntk("Hello world\n"); > /*then I would it exit from Xen and stop current process that called it.*/ > exit_?? //exit(0) does not work. > } > > If a process at the application level calls this hypercall through > privcmd file, I would like it kill this process after the hypercall > prints "Hello world". Then how to do that?A process is a guest kernel-level construct. Xen doesn''t know anything about processes; it only knows things about VMs. You can easily kill the guest by doing this: domain_crash(current->domain); If you want the process only to be killed, you have to have the guest kernel do it. -George
Baozeng
2011-Dec-01 12:55 UTC
Re: any exit function in xen that is similar to exit_kernel?
2011/12/1 George Dunlap <George.Dunlap@eu.citrix.com>:> On Tue, Nov 29, 2011 at 2:22 PM, Baozeng <sploving1@gmail.com> wrote: >> Hello all, >> I added a hypercall "do_greet" that only prints "Hello world" to do a >> small experiment. After it prints the "hello world", I would it to >> exit from Xen and stop current process. For instance: >> the hypercall is like this: >> int do_greet(){ >> pirntk("Hello world\n"); >> /*then I would it exit from Xen and stop current process that called it.*/ >> exit_?? //exit(0) does not work. >> } >> >> If a process at the application level calls this hypercall through >> privcmd file, I would like it kill this process after the hypercall >> prints "Hello world". Then how to do that? > > A process is a guest kernel-level construct. Xen doesn''t know > anything about processes; it only knows things about VMs. You can > easily kill the guest by doing this: > domain_crash(current->domain); > > If you want the process only to be killed, you have to have the guest > kernel do it. >Okay. I know. It need first return to the kernel address space. Then is there any function that can return the kernel address space from Xen after the hypercall? like this: int do_greet(){ pirntk("Hello world\n"); /*then I would it exit from Xen to the kernel.*/ exit_?? // after that CS and EIP should pointer to the kernel address space. } if there doesnot exiest such function, how can I know which function switches kernel into Xen to trigger such hypercall, so that I can return it by myself. Is it in the entry.S, when int $82 instruction happen, then the CS and EIP begin to switch point to Xen? thanks> -George-- Best Regards, Baozeng Ding OSTG,NFS,ISCAS
Ian Campbell
2011-Dec-05 09:53 UTC
Re: any exit function in xen that is similar to exit_kernel?
On Thu, 2011-12-01 at 12:55 +0000, Baozeng wrote:> 2011/12/1 George Dunlap <George.Dunlap@eu.citrix.com>: > > On Tue, Nov 29, 2011 at 2:22 PM, Baozeng <sploving1@gmail.com> wrote: > >> Hello all, > >> I added a hypercall "do_greet" that only prints "Hello world" to do a > >> small experiment. After it prints the "hello world", I would it to > >> exit from Xen and stop current process. For instance: > >> the hypercall is like this: > >> int do_greet(){ > >> pirntk("Hello world\n"); > >> /*then I would it exit from Xen and stop current process that called it.*/ > >> exit_?? //exit(0) does not work. > >> } > >> > >> If a process at the application level calls this hypercall through > >> privcmd file, I would like it kill this process after the hypercall > >> prints "Hello world". Then how to do that? > > > > A process is a guest kernel-level construct. Xen doesn''t know > > anything about processes; it only knows things about VMs. You can > > easily kill the guest by doing this: > > domain_crash(current->domain); > > > > If you want the process only to be killed, you have to have the guest > > kernel do it. > > > Okay. I know. It need first return to the kernel address space. Then > is there any function that can return the kernel address space from > Xen after the hypercall? like this: > int do_greet(){ > pirntk("Hello world\n"); > /*then I would it exit from Xen to the kernel.*/ > exit_?? // after that CS and EIP should pointer to the kernel > address space. > } > > if there doesnot exiest such function, how can I know which function > switches kernel into Xen to trigger such hypercall, so that I can > return it by myself. Is it in the entry.S, when int $82 instruction > happen, then the CS and EIP begin to switch point to Xen? thanksThis is a quite strange thing to want to do. Please can you explain your end goal (i.e. what problem are you trying to solve with this)? Perhaps there is a better way. Ian.