#include <xen/spinlock.h>
#include <xen/sched.h>
#include <xen/sort.h>
+#include <asm/cpuerrata.h>
#include <asm/current.h>
#include <asm/mmio.h>
+#include "decode.h"
+
static int handle_read(const struct mmio_handler *handler, struct vcpu *v,
mmio_info_t *info)
{
return handler;
}
-int handle_mmio(mmio_info_t *info)
+int try_handle_mmio(struct cpu_user_regs *regs,
+ const union hsr hsr,
+ paddr_t gpa)
{
struct vcpu *v = current;
const struct mmio_handler *handler = NULL;
+ const struct hsr_dabt dabt = hsr.dabt;
+ mmio_info_t info = {
+ .gpa = gpa,
+ .dabt = dabt
+ };
+
+ ASSERT(hsr.ec == HSR_EC_DATA_ABORT_LOWER_EL);
- handler = find_mmio_handler(v->domain, info->gpa);
+ handler = find_mmio_handler(v->domain, info.gpa);
if ( !handler )
return 0;
- if ( info->dabt.write )
- return handle_write(handler, v, info);
+ /* All the instructions used on emulated MMIO region should be valid */
+ if ( !dabt.valid )
+ return 0;
+
+ /*
+ * Erratum 766422: Thumb store translation fault to Hypervisor may
+ * not have correct HSR Rt value.
+ */
+ if ( check_workaround_766422() && (regs->cpsr & PSR_THUMB) &&
+ dabt.write )
+ {
+ int rc;
+
+ rc = decode_instruction(regs, &info.dabt);
+ if ( rc )
+ {
+ gprintk(XENLOG_DEBUG, "Unable to decode instruction\n");
+ return 0;
+ }
+ }
+
+ if ( info.dabt.write )
+ return handle_write(handler, v, &info);
else
- return handle_read(handler, v, info);
+ return handle_read(handler, v, &info);
}
void register_mmio_handler(struct domain *d,
#include <asm/vgic.h>
#include <asm/vtimer.h>
-#include "decode.h"
-
/* The base of the stack must always be double-word aligned, which means
* that both the kernel half of struct cpu_user_regs (which is pushed in
* entry.S) and struct cpu_info (which lives at the bottom of a Xen
return s1ptw || (fsc == FSC_FLT_TRANS && !check_workaround_834220());
}
-static bool try_handle_mmio(struct cpu_user_regs *regs,
- const union hsr hsr,
- paddr_t gpa)
-{
- const struct hsr_dabt dabt = hsr.dabt;
- mmio_info_t info = {
- .gpa = gpa,
- .dabt = dabt
- };
- int rc;
-
- ASSERT(hsr.ec == HSR_EC_DATA_ABORT_LOWER_EL);
-
- /* stage-1 page table should never live in an emulated MMIO region */
- if ( dabt.s1ptw )
- return false;
-
- /* All the instructions used on emulated MMIO region should be valid */
- if ( !dabt.valid )
- return false;
-
- /*
- * Erratum 766422: Thumb store translation fault to Hypervisor may
- * not have correct HSR Rt value.
- */
- if ( check_workaround_766422() && (regs->cpsr & PSR_THUMB) &&
- dabt.write )
- {
- rc = decode_instruction(regs, &info.dabt);
- if ( rc )
- {
- gprintk(XENLOG_DEBUG, "Unable to decode instruction\n");
- return false;
- }
- }
-
- return !!handle_mmio(&info);
-}
-
/*
* When using ACPI, most of the MMIO regions will be mapped on-demand
* in stage-2 page tables for the hardware domain because Xen is not
struct mmio_handler *handlers;
};
-extern int handle_mmio(mmio_info_t *info);
+int try_handle_mmio(struct cpu_user_regs *regs,
+ const union hsr hsr,
+ paddr_t gpa);
void register_mmio_handler(struct domain *d,
const struct mmio_handler_ops *ops,
paddr_t addr, paddr_t size, void *priv);