Skip to content

Commit 71ee8e3

Browse files
agrafavikivity
authored andcommitted
KVM: PPC: Introduce branch patching helper
We will need to patch several instruction streams over to a different code path, so we need a way to patch a single instruction with a branch somewhere else. This patch adds a helper to facilitate this patching. Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Avi Kivity <avi@redhat.com>
1 parent 2d4f567 commit 71ee8e3

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

‎arch/powerpc/kernel/kvm.c‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,20 @@ static void kvm_patch_ins_nop(u32 *inst)
107107
kvm_patch_ins(inst, KVM_INST_NOP);
108108
}
109109

110+
static void kvm_patch_ins_b(u32 *inst, int addr)
111+
{
112+
#ifdef CONFIG_RELOCATABLE
113+
/* On relocatable kernels interrupts handlers and our code
114+
can be in different regions, so we don't patch them */
115+
116+
extern u32 __end_interrupts;
117+
if ((ulong)inst < (ulong)&__end_interrupts)
118+
return;
119+
#endif
120+
121+
kvm_patch_ins(inst, KVM_INST_B | (addr & KVM_INST_B_MASK));
122+
}
123+
110124
static u32 *kvm_alloc(int len)
111125
{
112126
u32 *p;

0 commit comments

Comments
 (0)