Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 215833
b: refs/heads/master
c: 7508e16
h: refs/heads/master
i:
  215831: 4dc05a4
v: v3
  • Loading branch information
Alexander Graf authored and Avi Kivity committed Oct 24, 2010
1 parent 130327e commit 36f3ab6
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: cb24c50826e0722bffb0674f088954cd4980818b
refs/heads/master: 7508e16c9f2a20f7721d7bc47c33a7b34c873a2c
2 changes: 2 additions & 0 deletions trunk/arch/powerpc/include/asm/kvm_para.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ struct kvm_vcpu_arch_shared {

#define KVM_FEATURE_MAGIC_PAGE 1

#define KVM_MAGIC_FEAT_SR (1 << 0)

#ifdef __KERNEL__

#ifdef CONFIG_KVM_GUEST
Expand Down
21 changes: 15 additions & 6 deletions trunk/arch/powerpc/kernel/kvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,12 +266,20 @@ static void kvm_patch_ins_wrteei(u32 *inst)

static void kvm_map_magic_page(void *data)
{
kvm_hypercall2(KVM_HC_PPC_MAP_MAGIC_PAGE,
KVM_MAGIC_PAGE, /* Physical Address */
KVM_MAGIC_PAGE); /* Effective Address */
u32 *features = data;

ulong in[8];
ulong out[8];

in[0] = KVM_MAGIC_PAGE;
in[1] = KVM_MAGIC_PAGE;

kvm_hypercall(in, out, HC_VENDOR_KVM | KVM_HC_PPC_MAP_MAGIC_PAGE);

*features = out[0];
}

static void kvm_check_ins(u32 *inst)
static void kvm_check_ins(u32 *inst, u32 features)
{
u32 _inst = *inst;
u32 inst_no_rt = _inst & ~KVM_MASK_RT;
Expand Down Expand Up @@ -367,9 +375,10 @@ static void kvm_use_magic_page(void)
u32 *p;
u32 *start, *end;
u32 tmp;
u32 features;

/* Tell the host to map the magic page to -4096 on all CPUs */
on_each_cpu(kvm_map_magic_page, NULL, 1);
on_each_cpu(kvm_map_magic_page, &features, 1);

/* Quick self-test to see if the mapping works */
if (__get_user(tmp, (u32*)KVM_MAGIC_PAGE)) {
Expand All @@ -382,7 +391,7 @@ static void kvm_use_magic_page(void)
end = (void*)_etext;

for (p = start; p < end; p++)
kvm_check_ins(p);
kvm_check_ins(p, features);

printk(KERN_INFO "KVM: Live patching for a fast VM %s\n",
kvm_patching_worked ? "worked" : "failed");
Expand Down
5 changes: 4 additions & 1 deletion trunk/arch/powerpc/kvm/powerpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ int kvmppc_kvm_pv(struct kvm_vcpu *vcpu)
vcpu->arch.magic_page_pa = param1;
vcpu->arch.magic_page_ea = param2;

r2 = 0;

r = HC_EV_SUCCESS;
break;
}
Expand All @@ -76,13 +78,14 @@ int kvmppc_kvm_pv(struct kvm_vcpu *vcpu)
#endif

/* Second return value is in r4 */
kvmppc_set_gpr(vcpu, 4, r2);
break;
default:
r = HC_EV_UNIMPLEMENTED;
break;
}

kvmppc_set_gpr(vcpu, 4, r2);

return r;
}

Expand Down

0 comments on commit 36f3ab6

Please sign in to comment.