Skip to content

Commit ec13f4e

Browse files
yakuizhaojren1
authored andcommitted
HV:Remove the "immediate" constraint for inline assembly in bits operation
The input operand for inline assembly is passed from the caller. And they are not the immediate type. Instead the register should be used. This also helps to reduce the compile error if the optimizatin is enabled. Signed-off-by: Zhao Yakui<yakui.zhao@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
1 parent cb41210 commit ec13f4e

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

hypervisor/include/lib/bits.h

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ static inline void atomic_set_char(unsigned char *p, unsigned char v)
3838
{
3939
__asm __volatile(BUS_LOCK "orb %b1,%0"
4040
: "+m" (*p)
41-
: "iq" (v)
41+
: "q" (v)
4242
: "cc", "memory");
4343
}
4444

@@ -49,7 +49,7 @@ static inline void atomic_clear_char(unsigned char *p, unsigned char v)
4949
{
5050
__asm __volatile(BUS_LOCK "andb %b1,%0"
5151
: "+m" (*p)
52-
: "iq" (~v)
52+
: "q" (~v)
5353
: "cc", "memory");
5454
}
5555

@@ -60,7 +60,7 @@ static inline void atomic_add_char(unsigned char *p, unsigned char v)
6060
{
6161
__asm __volatile(BUS_LOCK "addb %b1,%0"
6262
: "+m" (*p)
63-
: "iq" (v)
63+
: "q" (v)
6464
: "cc", "memory");
6565
}
6666

@@ -71,7 +71,7 @@ static inline void atomic_subtract_char(unsigned char *p, unsigned char v)
7171
{
7272
__asm __volatile(BUS_LOCK "subb %b1,%0"
7373
: "+m" (*p)
74-
: "iq" (v)
74+
: "q" (v)
7575
: "cc", "memory");
7676
}
7777

@@ -82,7 +82,7 @@ static inline void atomic_set_short(unsigned short *p, unsigned short v)
8282
{
8383
__asm __volatile(BUS_LOCK "orw %w1,%0"
8484
: "+m" (*p)
85-
: "ir" (v)
85+
: "r" (v)
8686
: "cc", "memory");
8787
}
8888

@@ -93,7 +93,7 @@ static inline void atomic_clear_short(unsigned short *p, unsigned short v)
9393
{
9494
__asm __volatile(BUS_LOCK "andw %w1,%0"
9595
: "+m" (*p)
96-
: "ir" (~v)
96+
: "r" (~v)
9797
: "cc", "memory");
9898
}
9999

@@ -104,7 +104,7 @@ static inline void atomic_add_short(unsigned short *p, unsigned short v)
104104
{
105105
__asm __volatile(BUS_LOCK "addw %w1,%0"
106106
: "+m" (*p)
107-
: "ir" (v)
107+
: "r" (v)
108108
: "cc", "memory");
109109
}
110110

@@ -115,7 +115,7 @@ static inline void atomic_subtract_short(unsigned short *p, unsigned short v)
115115
{
116116
__asm __volatile(BUS_LOCK "subw %w1,%0"
117117
: "+m" (*p)
118-
: "ir" (v)
118+
: "r" (v)
119119
: "cc", "memory");
120120
}
121121

@@ -126,7 +126,7 @@ static inline void atomic_set_int(unsigned int *p, unsigned int v)
126126
{
127127
__asm __volatile(BUS_LOCK "orl %1,%0"
128128
: "+m" (*p)
129-
: "ir" (v)
129+
: "r" (v)
130130
: "cc", "memory");
131131
}
132132

@@ -137,7 +137,7 @@ static inline void atomic_clear_int(unsigned int *p, unsigned int v)
137137
{
138138
__asm __volatile(BUS_LOCK "andl %1,%0"
139139
: "+m" (*p)
140-
: "ir" (~v)
140+
: "r" (~v)
141141
: "cc", "memory");
142142
}
143143

@@ -148,7 +148,7 @@ static inline void atomic_add_int(unsigned int *p, unsigned int v)
148148
{
149149
__asm __volatile(BUS_LOCK "addl %1,%0"
150150
: "+m" (*p)
151-
: "ir" (v)
151+
: "r" (v)
152152
: "cc", "memory");
153153
}
154154

@@ -159,7 +159,7 @@ static inline void atomic_subtract_int(unsigned int *p, unsigned int v)
159159
{
160160
__asm __volatile(BUS_LOCK "subl %1,%0"
161161
: "+m" (*p)
162-
: "ir" (v)
162+
: "r" (v)
163163
: "cc", "memory");
164164
}
165165

@@ -189,7 +189,7 @@ static inline void atomic_set_long(unsigned long *p, unsigned long v)
189189
{
190190
__asm __volatile(BUS_LOCK "orq %1,%0"
191191
: "+m" (*p)
192-
: "ir" (v)
192+
: "r" (v)
193193
: "cc", "memory");
194194
}
195195

@@ -200,7 +200,7 @@ static inline void atomic_clear_long(unsigned long *p, unsigned long v)
200200
{
201201
__asm __volatile(BUS_LOCK "andq %1,%0"
202202
: "+m" (*p)
203-
: "ir" (~v)
203+
: "r" (~v)
204204
: "cc", "memory");
205205
}
206206

@@ -211,7 +211,7 @@ static inline void atomic_add_long(unsigned long *p, unsigned long v)
211211
{
212212
__asm __volatile(BUS_LOCK "addq %1,%0"
213213
: "+m" (*p)
214-
: "ir" (v)
214+
: "r" (v)
215215
: "cc", "memory");
216216
}
217217

@@ -222,7 +222,7 @@ static inline void atomic_subtract_long(unsigned long *p, unsigned long v)
222222
{
223223
__asm __volatile(BUS_LOCK "subq %1,%0"
224224
: "+m" (*p)
225-
: "ir" (v)
225+
: "r" (v)
226226
: "cc", "memory");
227227
}
228228

@@ -439,7 +439,7 @@ bitmap_set(int mask, unsigned long *bits)
439439
/* (*bits) |= (1UL<<mask); */
440440
__asm __volatile(BUS_LOCK "orq %1,%0"
441441
: "+m" (*bits)
442-
: "ir" (1UL<<mask)
442+
: "r" (1UL<<mask)
443443
: "cc", "memory");
444444
}
445445

@@ -449,7 +449,7 @@ bitmap_clr(int mask, unsigned long *bits)
449449
/* (*bits) &= ~(1UL<<mask); */
450450
__asm __volatile(BUS_LOCK "andq %1,%0"
451451
: "+m" (*bits)
452-
: "ir" (~(1UL<<mask))
452+
: "r" (~(1UL<<mask))
453453
: "cc", "memory");
454454
}
455455

@@ -463,7 +463,7 @@ bitmap_isset(int mask, unsigned long *bits)
463463

464464
__asm __volatile("btq %2,%1\n\tsbbl %0, %0"
465465
: "=r" (ret), "=m" (*bits)
466-
: "ir" ((long)(mask) & 0x3f)
466+
: "r" ((long)(mask) & 0x3f)
467467
: "cc", "memory");
468468
return (!!ret);
469469
}
@@ -475,7 +475,7 @@ bitmap_test_and_set(int mask, unsigned long *bits)
475475

476476
__asm __volatile(BUS_LOCK "btsq %2,%1\n\tsbbl %0,%0"
477477
: "=r" (ret), "=m" (*bits)
478-
: "ir" ((long)(mask & 0x3f))
478+
: "r" ((long)(mask & 0x3f))
479479
: "cc", "memory");
480480
return (!!ret);
481481
}
@@ -492,7 +492,7 @@ bitmap_test_and_clear(int mask, unsigned long *bits)
492492

493493
__asm __volatile(BUS_LOCK "btrq %2,%1\n\tsbbl %0,%0"
494494
: "=r" (ret), "=m" (*bits)
495-
: "ir" ((long)(mask) & 0x3f)
495+
: "r" ((long)(mask) & 0x3f)
496496
: "cc", "memory");
497497
return (!!ret);
498498
}
@@ -507,7 +507,7 @@ bitmap_setof(int mask, unsigned long *bits)
507507

508508
__asm __volatile(BUS_LOCK "xchgq %1,%0"
509509
: "+m" (*bits)
510-
: "ir" ((1UL<<mask))
510+
: "r" ((1UL<<mask))
511511
: "cc", "memory");
512512

513513
}

0 commit comments

Comments
 (0)