mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
xen/ioreq: Make x86's hvm_mmio_first(last)_byte() common
The IOREQ is a common feature now and these helpers will be used on Arm as is. Move them to xen/ioreq.h and replace "hvm" prefixes with "ioreq". Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com> Reviewed-by: Paul Durrant <paul@xen.org> Acked-by: Jan Beulich <jbeulich@suse.com> Reviewed-by: Julien Grall <jgrall@amazon.com> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> CC: Julien Grall <julien.grall@arm.com> [On Arm only] Tested-by: Wei Chen <Wei.Chen@arm.com>
This commit is contained in:
1 parent
4607644168
commit
c648ff9622
5 files changed
+23
-22
No files matched your search
@@ -17,6 +17,7 @@
|
||||
* this program; If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <xen/ioreq.h>
|
||||
#include <xen/types.h>
|
||||
#include <xen/sched.h>
|
||||
#include <asm/regs.h>
|
||||
@@ -34,7 +35,7 @@
|
||||
static bool_t hvm_mmio_accept(const struct hvm_io_handler *handler,
|
||||
const ioreq_t *p)
|
||||
{
|
||||
paddr_t first = hvm_mmio_first_byte(p), last;
|
||||
paddr_t first = ioreq_mmio_first_byte(p), last;
|
||||
|
||||
BUG_ON(handler->type != IOREQ_TYPE_COPY);
|
||||
|
||||
@@ -42,7 +43,7 @@ static bool_t hvm_mmio_accept(const struct hvm_io_handler *handler,
|
||||
return 0;
|
||||
|
||||
/* Make sure the handler will accept the whole access. */
|
||||
last = hvm_mmio_last_byte(p);
|
||||
last = ioreq_mmio_last_byte(p);
|
||||
if ( last != first &&
|
||||
!handler->mmio.ops->check(current, last) )
|
||||
domain_crash(current->domain);
|
||||
|
||||
@@ -524,8 +524,8 @@ static bool_t stdvga_mem_accept(const struct hvm_io_handler *handler,
|
||||
* deadlock when hvm_mmio_internal() is called from
|
||||
* hvm_copy_to/from_guest_phys() in hvm_process_io_intercept().
|
||||
*/
|
||||
if ( (hvm_mmio_first_byte(p) < VGA_MEM_BASE) ||
|
||||
(hvm_mmio_last_byte(p) >= (VGA_MEM_BASE + VGA_MEM_SIZE)) )
|
||||
if ( (ioreq_mmio_first_byte(p) < VGA_MEM_BASE) ||
|
||||
(ioreq_mmio_last_byte(p) >= (VGA_MEM_BASE + VGA_MEM_SIZE)) )
|
||||
return 0;
|
||||
|
||||
spin_lock(&s->lock);
|
||||
|
||||
+2
-2
@@ -1078,8 +1078,8 @@ struct hvm_ioreq_server *hvm_select_ioreq_server(struct domain *d,
|
||||
break;
|
||||
|
||||
case XEN_DMOP_IO_RANGE_MEMORY:
|
||||
start = hvm_mmio_first_byte(p);
|
||||
end = hvm_mmio_last_byte(p);
|
||||
start = ioreq_mmio_first_byte(p);
|
||||
end = ioreq_mmio_last_byte(p);
|
||||
|
||||
if ( rangeset_contains_range(r, start, end) )
|
||||
return s;
|
||||
|
||||
@@ -40,22 +40,6 @@ struct hvm_mmio_ops {
|
||||
hvm_mmio_write_t write;
|
||||
};
|
||||
|
||||
static inline paddr_t hvm_mmio_first_byte(const ioreq_t *p)
|
||||
{
|
||||
return unlikely(p->df) ?
|
||||
p->addr - (p->count - 1ul) * p->size :
|
||||
p->addr;
|
||||
}
|
||||
|
||||
static inline paddr_t hvm_mmio_last_byte(const ioreq_t *p)
|
||||
{
|
||||
unsigned long size = p->size;
|
||||
|
||||
return unlikely(p->df) ?
|
||||
p->addr + size - 1:
|
||||
p->addr + (p->count * size) - 1;
|
||||
}
|
||||
|
||||
typedef int (*portio_action_t)(
|
||||
int dir, unsigned int port, unsigned int bytes, uint32_t *val);
|
||||
|
||||
|
||||
@@ -23,6 +23,22 @@
|
||||
|
||||
#include <public/hvm/dm_op.h>
|
||||
|
||||
static inline paddr_t ioreq_mmio_first_byte(const ioreq_t *p)
|
||||
{
|
||||
return unlikely(p->df) ?
|
||||
p->addr - (p->count - 1ul) * p->size :
|
||||
p->addr;
|
||||
}
|
||||
|
||||
static inline paddr_t ioreq_mmio_last_byte(const ioreq_t *p)
|
||||
{
|
||||
unsigned long size = p->size;
|
||||
|
||||
return unlikely(p->df) ?
|
||||
p->addr + size - 1:
|
||||
p->addr + (p->count * size) - 1;
|
||||
}
|
||||
|
||||
static inline bool ioreq_needs_completion(const ioreq_t *ioreq)
|
||||
{
|
||||
return ioreq->state == STATE_IOREQ_READY &&
|
||||
|
||||