KVM: arm/arm64: Export mmio_read/write_bus
authorChristoffer Dall <christoffer.dall@linaro.org>
Sun, 24 Apr 2016 19:41:36 +0000 (21:41 +0200)
committerChristoffer Dall <christoffer.dall@linaro.org>
Fri, 20 May 2016 13:39:42 +0000 (15:39 +0200)
Rename mmio_{read,write}_bus to kvm_mmio_{read,write}_bus and export
them out of mmio.c.
This will be needed later for the new VGIC implementation.

Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Acked-by: Marc Zyngier <marc.zyngier@arm.com>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
arch/arm/include/asm/kvm_mmio.h
arch/arm/kvm/mmio.c
arch/arm64/include/asm/kvm_mmio.h

index d8e90c8cb5fa0ab4c0486cb6d9fd53d576456291..f3a7de71f515016bf9ab0b2525bfe622794975a7 100644 (file)
@@ -28,6 +28,9 @@ struct kvm_decode {
        bool sign_extend;
 };
 
+void kvm_mmio_write_buf(void *buf, unsigned int len, unsigned long data);
+unsigned long kvm_mmio_read_buf(const void *buf, unsigned int len);
+
 int kvm_handle_mmio_return(struct kvm_vcpu *vcpu, struct kvm_run *run);
 int io_mem_abort(struct kvm_vcpu *vcpu, struct kvm_run *run,
                 phys_addr_t fault_ipa);
index 0158e9e3276d06563b6353f30369cbc0766b5f61..10f80a6c797a2b6b67363b6f163ef5b85b28465e 100644 (file)
@@ -23,7 +23,7 @@
 
 #include "trace.h"
 
-static void mmio_write_buf(char *buf, unsigned int len, unsigned long data)
+void kvm_mmio_write_buf(void *buf, unsigned int len, unsigned long data)
 {
        void *datap = NULL;
        union {
@@ -55,7 +55,7 @@ static void mmio_write_buf(char *buf, unsigned int len, unsigned long data)
        memcpy(buf, datap, len);
 }
 
-static unsigned long mmio_read_buf(char *buf, unsigned int len)
+unsigned long kvm_mmio_read_buf(const void *buf, unsigned int len)
 {
        unsigned long data = 0;
        union {
@@ -66,7 +66,7 @@ static unsigned long mmio_read_buf(char *buf, unsigned int len)
 
        switch (len) {
        case 1:
-               data = buf[0];
+               data = *(u8 *)buf;
                break;
        case 2:
                memcpy(&tmp.hword, buf, len);
@@ -103,7 +103,7 @@ int kvm_handle_mmio_return(struct kvm_vcpu *vcpu, struct kvm_run *run)
                if (len > sizeof(unsigned long))
                        return -EINVAL;
 
-               data = mmio_read_buf(run->mmio.data, len);
+               data = kvm_mmio_read_buf(run->mmio.data, len);
 
                if (vcpu->arch.mmio_decode.sign_extend &&
                    len < sizeof(unsigned long)) {
@@ -189,7 +189,7 @@ int io_mem_abort(struct kvm_vcpu *vcpu, struct kvm_run *run,
                                               len);
 
                trace_kvm_mmio(KVM_TRACE_MMIO_WRITE, len, fault_ipa, data);
-               mmio_write_buf(data_buf, len, data);
+               kvm_mmio_write_buf(data_buf, len, data);
 
                ret = kvm_io_bus_write(vcpu, KVM_MMIO_BUS, fault_ipa, len,
                                       data_buf);
index fe612a9625766b5fff3698e2d1014d7376744e4f..75ea4207975760f92a1b8d091a7e04b8c7dd0e7a 100644 (file)
@@ -30,6 +30,9 @@ struct kvm_decode {
        bool sign_extend;
 };
 
+void kvm_mmio_write_buf(void *buf, unsigned int len, unsigned long data);
+unsigned long kvm_mmio_read_buf(const void *buf, unsigned int len);
+
 int kvm_handle_mmio_return(struct kvm_vcpu *vcpu, struct kvm_run *run);
 int io_mem_abort(struct kvm_vcpu *vcpu, struct kvm_run *run,
                 phys_addr_t fault_ipa);