24 #include <asm/intrinsics.h>
25 #include <asm/kprobes.h>
26 #include <asm/paravirt.h>
31 unsigned long long qp : 6;
32 unsigned long long : 31;
47 extern void paravirt_fc_i(
const void *
addr);
50 for (i = 0; i <
size; i +=
sizeof(bundle_t))
51 paravirt_fc_i(instr + i);
57 return (bundle_t *)(tag & ~3
UL);
74 return (ebundle - sbundle) * 3 + eslot - sslot + 1;
88 return (
unsigned long)(bundle + 1);
100 inst.
l = bundle->quad0.slot0;
108 inst.
l = bundle->quad0.slot1_p0 |
109 ((
unsigned long long)bundle->quad1.slot1_p1 << 18
UL);
117 inst.
l = bundle->quad1.slot2;
143 bundle->quad0.slot0 = inst.
l;
149 bundle->quad0.slot1_p0 = inst.
l;
150 bundle->quad1.slot1_p1 = inst.
l >> 18
UL;
156 bundle->quad1.slot2 = inst.
l;
186 const unsigned long *quad = (
const unsigned long *)bundle;
192 "bundle 0x%p 0x%016lx 0x%016lx\n", bundle, quad[0], quad[1]);
194 "bundle template 0x%x\n",
195 bundle->quad0.template);
197 "slot0 0x%lx slot1_p0 0x%lx slot1_p1 0x%lx slot2 0x%lx\n",
198 (
unsigned long)bundle->quad0.slot0,
199 (
unsigned long)bundle->quad0.slot1_p0,
200 (
unsigned long)bundle->quad1.slot1_p1,
201 (
unsigned long)bundle->quad1.slot2);
203 "slot0 0x%016llx slot1 0x%016llx slot2 0x%016llx\n",
204 slot0.
l, slot1.
l, slot2.
l);
209 static int __init setup_noreplace_paravirt(
char *
str)
211 noreplace_paravirt = 1;
214 __setup(
"noreplace-paravirt", setup_noreplace_paravirt);
218 fill_nop_bundle(
void *sbundle,
void *ebundle)
220 extern const char paravirt_nop_bundle[];
221 extern const unsigned long paravirt_nop_bundle_size;
223 void *bundle = sbundle;
225 BUG_ON((((
unsigned long)sbundle) %
sizeof(bundle_t)) != 0);
226 BUG_ON((((
unsigned long)ebundle) %
sizeof(bundle_t)) != 0);
228 while (bundle < ebundle) {
229 memcpy(bundle, paravirt_nop_bundle, paravirt_nop_bundle_size);
231 bundle += paravirt_nop_bundle_size;
237 __paravirt_patch_apply_bundle(
void *sbundle,
void *ebundle,
unsigned long type,
239 unsigned long nelems,
242 unsigned long used = 0;
245 BUG_ON((((
unsigned long)sbundle) %
sizeof(bundle_t)) != 0);
246 BUG_ON((((
unsigned long)ebundle) %
sizeof(bundle_t)) != 0);
249 for (i = 0; i < nelems; i++) {
251 if (p->
type == type) {
253 unsigned long room = ebundle -
sbundle;
261 "the space is too small to put "
262 "bundles. type %ld need %ld room %ld\n",
282 if (noreplace_paravirt)
287 for (p = start; p <
end; p++) {
309 fill_nop_inst(
unsigned long stag,
unsigned long etag)
311 extern const bundle_t paravirt_nop_mfi_inst_bundle[];
326 if (noreplace_paravirt)
331 for (p = start; p <
end; p++) {
340 fill_nop_inst(tag, p->
etag);
381 unsigned long tag_imm =
tag;
390 unsigned long imm60 =
391 ((
unsigned long)target - (
unsigned long)bundle) >> 4;
394 BUG_ON(((
unsigned long)target & (
sizeof(bundle_t) - 1)) != 0);
397 inst_x3_op.
i = (imm60 >> 59) & 1;
399 inst_x3_op.
imm20b = imm60 & ((1
UL << 20) - 1);
401 inst_x3_imm.
imm39 = (imm60 >> 20) & ((1
UL << 39) - 1);
403 inst_op.
l = inst_x3_op.
l;
404 inst_imm.
l = inst_x3_imm.
l;
432 unsigned long target25 = (
unsigned long)target - (
unsigned long)bundle;
435 BUG_ON(((
unsigned long)target & (
sizeof(bundle_t) - 1)) != 0);
438 if (target25 & (1
UL << 63))
443 inst_b1.
imm20b = target25 >> 4;
451 unsigned long tag,
unsigned long type,
453 unsigned int nr_entries)
456 for (i = 0; i < nr_entries; i++) {
457 if (entries[i].type == type) {
470 if (noreplace_paravirt)
475 for (p = start; p <
end; p++)
485 extern const char __start_paravirt_bundles[];
486 extern const char __stop_paravirt_bundles[];
487 extern const char __start_paravirt_insts[];
488 extern const char __stop_paravirt_insts[];
489 extern const char __start_paravirt_branches[];
490 extern const char __stop_paravirt_branches[];
493 __start_paravirt_bundles,
495 __stop_paravirt_bundles);
497 __start_paravirt_insts,
499 __stop_paravirt_insts);
501 __start_paravirt_branches,
503 __stop_paravirt_branches);