1 /******************************************************************************
2  * arch/x86/pv/misc-hypercalls.c
3  *
4  * Misc hypercall handlers
5  *
6  * Modifications to Linux original are copyright (c) 2002-2004, K A Fraser
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; If not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 #include <xen/hypercall.h>
23 
24 #include <asm/debugreg.h>
25 
do_set_debugreg(int reg,unsigned long value)26 long do_set_debugreg(int reg, unsigned long value)
27 {
28     return set_debugreg(current, reg, value);
29 }
30 
do_get_debugreg(int reg)31 unsigned long do_get_debugreg(int reg)
32 {
33     struct vcpu *curr = current;
34 
35     switch ( reg )
36     {
37     case 0 ... 3:
38     case 6:
39         return curr->arch.debugreg[reg];
40     case 7:
41         return (curr->arch.debugreg[7] |
42                 curr->arch.debugreg[5]);
43     case 4 ... 5:
44         return ((curr->arch.pv_vcpu.ctrlreg[4] & X86_CR4_DE) ?
45                 curr->arch.debugreg[reg + 2] : 0);
46     }
47 
48     return -EINVAL;
49 }
50 
do_fpu_taskswitch(int set)51 long do_fpu_taskswitch(int set)
52 {
53     struct vcpu *v = current;
54 
55     if ( set )
56     {
57         v->arch.pv_vcpu.ctrlreg[0] |= X86_CR0_TS;
58         stts();
59     }
60     else
61     {
62         v->arch.pv_vcpu.ctrlreg[0] &= ~X86_CR0_TS;
63         if ( v->fpu_dirtied )
64             clts();
65     }
66 
67     return 0;
68 }
69 
70 /*
71  * Local variables:
72  * mode: C
73  * c-file-style: "BSD"
74  * c-basic-offset: 4
75  * tab-width: 4
76  * indent-tabs-mode: nil
77  * End:
78  */
79