Skip to contentSkip to conversation

ARM: KVM: Handle loads from I/O addresses to PC

PATCH New Christoffer Dall 3 participants 3 messages May 12, 2013 – May 13, 2013 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: KVM: Handle loads from I/O addresses to PC

If a VM does something like this:

ldr pc, [r0] @ r0 is an I/O address

Then simply let that value load into the PC on kvm_handle_mmio_return overwriting the PC value set from kvm_skip_instr.

---
 arch/arm/kvm/mmio.c |    6 ------
 1 file changed, 6 deletions(-)
arch/arm/kvm/mmio.c +0 -6
index 72a12f2..b8e06b7 100644
@@ -86,12 +86,6 @@ static int decode_hsr(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
 	sign_extend = kvm_vcpu_dabt_issext(vcpu);
 	rt = kvm_vcpu_dabt_get_rd(vcpu);
 
-	if (kvm_vcpu_reg_is_pc(vcpu, rt)) {
-		/* IO memory trying to read/write pc */
-		kvm_inject_pabt(vcpu, kvm_vcpu_get_hfar(vcpu));
-		return 1;
-	}
-
 	mmio->is_write = is_write;
 	mmio->phys_addr = fault_ipa;
 	mmio->len = len;
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/1 ARM: KVM: Handle loads from I/O addresses to PC

Quoted 8 lines · Christoffer Dall

If a VM does something like this:

ldr pc, [r0] @ r0 is an I/O address

Then simply let that value load into the PC on kvm_handle_mmio_return overwriting the PC value set from kvm_skip_instr.

I've had a slightly more complete patch in my tree for a while (look at bef0ef01ae75 on the kvm-arm64/kvm-3.10-rc0 branch).

Quoted 12 lines
---
 arch/arm/kvm/mmio.c |    6 ------
 1 file changed, 6 deletions(-)
arch/arm/kvm/mmio.c +0 -0
index 72a12f2..b8e06b7 100644
@@ -86,12 +86,6 @@ static int decode_hsr(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
 	sign_extend = kvm_vcpu_dabt_issext(vcpu);
 	rt = kvm_vcpu_dabt_get_rd(vcpu);

arch/arm/kvm/mmio.c static int decode_hsr(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, · line 91

Quoted 10 lines
arch/arm/kvm/mmio.c +0 -6
 
-	if (kvm_vcpu_reg_is_pc(vcpu, rt)) {
-		/* IO memory trying to read/write pc */
-		kvm_inject_pabt(vcpu, kvm_vcpu_get_hfar(vcpu));
-		return 1;
-	}
-
 	mmio->is_write = is_write;
 	mmio->phys_addr = fault_ipa;
 	mmio->len = len;

Otherwise looks good to me.

	M.
Signature · 1 line
Jazz is not dead. It just smells funny...
#2 lore raw

PATCH 1/1 ARM: KVM: Handle loads from I/O addresses to PC

In reply to Christoffer Dall
Quoted 17 lines · Christoffer Dall

If a VM does something like this:

ldr pc, [r0] @ r0 is an I/O address

Then simply let that value load into the PC on kvm_handle_mmio_return overwriting the PC value set from kvm_skip_instr.

---
 arch/arm/kvm/mmio.c |    6 ------
 1 file changed, 6 deletions(-)
arch/arm/kvm/mmio.c +0 -0
index 72a12f2..b8e06b7 100644

arch/arm/kvm/mmio.c static int decode_hsr(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, · line 92

Quoted 7 lines
arch/arm/kvm/mmio.c +0 -4
@@ -86,12 +86,6 @@ static int decode_hsr(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
 	sign_extend = kvm_vcpu_dabt_issext(vcpu);
 	rt = kvm_vcpu_dabt_get_rd(vcpu);
 
-	if (kvm_vcpu_reg_is_pc(vcpu, rt)) {
-		/* IO memory trying to read/write pc */
-		kvm_inject_pabt(vcpu, kvm_vcpu_get_hfar(vcpu));
-		return 1;

I haven't checked Marc's patch yet but I would get rid of kvm_vcpu_reg_is_pc() as well, that's the only place where it is used.

Signature · 1 line
Catalin