~ubuntu-branches/ubuntu/quantal/open-vm-tools/quantal-201210021442

« back to all changes in this revision

Viewing changes to lib/include/vm_basic_asm_x86.h

  • Committer: Bazaar Package Importer
  • Author(s): Serge Hallyn
  • Date: 2011-03-31 14:20:05 UTC
  • mfrom: (1.4.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20110331142005-3n9red91p7ogkweo
Tags: 2011.03.28-387002-0ubuntu1
* Merge latest upstream git tag.  This has the unlocked_ioctl change
  needed to fix dkms build failures (LP: #727342)
* Changes in debian/rules:
  - work around a bug in toolbox/Makefile, where install-exec-hook is
    not happening.  This needs to get fixed the right way.
  - don't install 'vmware-user' which seems to no longer exist
  - move /etc/xdg into open-vm-toolbox (which should be done using .install)
* debian/open-vm-tools.init: add 'modprobe [-r] vmblock'. (LP: #332323)
* debian/rules and debian/open-vm-toolbox.lintian-overrides:
  - Make vmware-user-suid-wrapper suid-root (LP: #332323)

Show diffs side-by-side

added added

removed removed

Lines of Context:
82
82
 */
83
83
#if defined(__GNUC__)
84
84
static INLINE void 
85
 
FXSAVE_ES1(uint8 *save)
86
 
{
87
 
   __asm__ __volatile__ ("fxsave %0\n" : "=m" (*save) : : "memory");
88
 
}
89
 
 
90
 
static INLINE void 
91
 
FXRSTOR_ES1(const uint8 *load)
92
 
{
93
 
   __asm__ __volatile__ ("fxrstor %0\n" : : "m" (*load) : "memory");
94
 
}
95
 
 
96
 
static INLINE void 
97
 
FXRSTOR_AMD_ES0(const uint8 *load)
 
85
FXSAVE_ES1(void *save)
 
86
{
 
87
   __asm__ __volatile__ ("fxsave %0\n" : "=m" (*(uint8 *)save) : : "memory");
 
88
}
 
89
 
 
90
static INLINE void 
 
91
FXRSTOR_ES1(const void *load)
 
92
{
 
93
   __asm__ __volatile__ ("fxrstor %0\n"
 
94
                         : : "m" (*(const uint8 *)load) : "memory");
 
95
}
 
96
 
 
97
static INLINE void 
 
98
FXRSTOR_AMD_ES0(const void *load)
98
99
{
99
100
   uint64 dummy = 0;
100
 
      
 
101
 
101
102
   __asm__ __volatile__ 
102
103
       ("fnstsw  %%ax    \n"     // Grab x87 ES bit
103
104
        "bt      $7,%%ax \n"     // Test ES bit
109
110
                                 // x87 exception pointers.
110
111
        "fxrstor %1      \n"
111
112
        :  
112
 
        : "m" (dummy), "m" (*load)
 
113
        : "m" (dummy), "m" (*(const uint8 *)load)
113
114
        : "ax", "memory");
114
115
}
115
116
#endif /* __GNUC__ */
116
117
 
117
118
/*
 
119
 * XSAVE/XRSTOR
 
120
 *     save/restore GSSE/SIMD/MMX fpu state
 
121
 *
 
122
 * The pointer passed in must be 64-byte aligned.
 
123
 * See above comment for more information.
 
124
 */
 
125
#if defined(__GNUC__) && (defined(VMM) || defined(VMKERNEL) || defined(FROBOS))
 
126
 
 
127
static INLINE void 
 
128
XSAVE_ES1(void *save, uint64 mask)
 
129
{
 
130
#if __GNUC__ < 4 || __GNUC__ == 4 && __GNUC_MINOR__ == 1
 
131
   __asm__ __volatile__ (
 
132
        ".byte 0x0f, 0xae, 0x21 \n"
 
133
        :
 
134
        : "c" ((uint8 *)save), "a" ((uint32)mask), "d" ((uint32)(mask >> 32))
 
135
        : "memory");
 
136
#else
 
137
   __asm__ __volatile__ (
 
138
        "xsave %0 \n"
 
139
        : "=m" (*(uint8 *)save)
 
140
        : "a" ((uint32)mask), "d" ((uint32)(mask >> 32))
 
141
        : "memory");
 
142
#endif
 
143
}
 
144
 
 
145
static INLINE void 
 
146
XSAVEOPT_ES1(void *save, uint64 mask)
 
147
{
 
148
   __asm__ __volatile__ (
 
149
        ".byte 0x0f, 0xae, 0x31 \n"
 
150
        :
 
151
        : "c" ((uint8 *)save), "a" ((uint32)mask), "d" ((uint32)(mask >> 32))
 
152
        : "memory");
 
153
}
 
154
 
 
155
static INLINE void 
 
156
XRSTOR_ES1(const void *load, uint64 mask)
 
157
{
 
158
#if __GNUC__ < 4 || __GNUC__ == 4 && __GNUC_MINOR__ == 1
 
159
   __asm__ __volatile__ (
 
160
        ".byte 0x0f, 0xae, 0x29 \n"
 
161
        :
 
162
        : "c" ((const uint8 *)load),
 
163
          "a" ((uint32)mask), "d" ((uint32)(mask >> 32))
 
164
        : "memory");
 
165
#else
 
166
   __asm__ __volatile__ (
 
167
        "xrstor %0 \n"
 
168
        :
 
169
        : "m" (*(const uint8 *)load),
 
170
          "a" ((uint32)mask), "d" ((uint32)(mask >> 32))
 
171
        : "memory");
 
172
#endif
 
173
}
 
174
 
 
175
static INLINE void 
 
176
XRSTOR_AMD_ES0(const void *load, uint64 mask)
 
177
{
 
178
   uint64 dummy = 0;
 
179
 
 
180
   __asm__ __volatile__ 
 
181
       ("fnstsw  %%ax    \n"     // Grab x87 ES bit
 
182
        "bt      $7,%%ax \n"     // Test ES bit
 
183
        "jnc     1f      \n"     // Jump if ES=0
 
184
        "fnclex          \n"     // ES=1. Clear it so fild doesn't trap
 
185
        "1:              \n"
 
186
        "ffree   %%st(7) \n"     // Clear tag bit - avoid poss. stack overflow
 
187
        "fildl   %0      \n"     // Dummy Load from "safe address" changes all
 
188
                                 // x87 exception pointers.
 
189
        "mov %%ebx, %%eax \n"
 
190
#if __GNUC__ < 4 || __GNUC__ == 4 && __GNUC_MINOR__ == 1
 
191
        ".byte 0x0f, 0xae, 0x29 \n"
 
192
        :
 
193
        : "m" (dummy), "c" ((const uint8 *)load),
 
194
          "b" ((uint32)mask), "d" ((uint32)(mask >> 32))
 
195
#else
 
196
        "xrstor %1 \n"
 
197
        :
 
198
        : "m" (dummy), "m" (*(const uint8 *)load),
 
199
          "b" ((uint32)mask), "d" ((uint32)(mask >> 32))
 
200
#endif
 
201
        : "eax", "memory");
 
202
}
 
203
#endif /* __GNUC__ */
 
204
 
 
205
/*
118
206
 *-----------------------------------------------------------------------------
119
207
 *
120
208
 * Div643232 --
428
516
           "shrdl %%edx, %%eax\n\t"   // result = hi(p2):hi(p1):lo(p1) >> shift
429
517
           "shrdl %1, %%edx\n"
430
518
        "3:\n\t"
431
 
           : "=A" (result), "=&r" (tmp1), "=&r" (tmp2)
 
519
           : "=A" (result), "=&r" (tmp1), "=&rm" (tmp2)
432
520
           : "0" (multiplicand), "rm" (multiplier), "c" (shift)
433
521
           : "cc");
434
522
   return result;