kvm: add support for memory transaction attributes
Let kvm_arch_post_run convert fields in the kvm_run struct to MemTxAttrs. These are then passed to address_space_rw. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
f8a9f720dd
commit
4c66375252
@ -18,6 +18,7 @@
|
|||||||
#include "config-host.h"
|
#include "config-host.h"
|
||||||
#include "qemu/queue.h"
|
#include "qemu/queue.h"
|
||||||
#include "qom/cpu.h"
|
#include "qom/cpu.h"
|
||||||
|
#include "exec/memattrs.h"
|
||||||
|
|
||||||
#ifdef CONFIG_KVM
|
#ifdef CONFIG_KVM
|
||||||
#include <linux/kvm.h>
|
#include <linux/kvm.h>
|
||||||
@ -254,7 +255,7 @@ int kvm_create_device(KVMState *s, uint64_t type, bool test);
|
|||||||
extern const KVMCapabilityInfo kvm_arch_required_capabilities[];
|
extern const KVMCapabilityInfo kvm_arch_required_capabilities[];
|
||||||
|
|
||||||
void kvm_arch_pre_run(CPUState *cpu, struct kvm_run *run);
|
void kvm_arch_pre_run(CPUState *cpu, struct kvm_run *run);
|
||||||
void kvm_arch_post_run(CPUState *cpu, struct kvm_run *run);
|
MemTxAttrs kvm_arch_post_run(CPUState *cpu, struct kvm_run *run);
|
||||||
|
|
||||||
int kvm_arch_handle_exit(CPUState *cpu, struct kvm_run *run);
|
int kvm_arch_handle_exit(CPUState *cpu, struct kvm_run *run);
|
||||||
|
|
||||||
|
21
kvm-all.c
21
kvm-all.c
@ -1669,14 +1669,14 @@ void kvm_set_sigmask_len(KVMState *s, unsigned int sigmask_len)
|
|||||||
s->sigmask_len = sigmask_len;
|
s->sigmask_len = sigmask_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void kvm_handle_io(uint16_t port, void *data, int direction, int size,
|
static void kvm_handle_io(uint16_t port, MemTxAttrs attrs, void *data, int direction,
|
||||||
uint32_t count)
|
int size, uint32_t count)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
uint8_t *ptr = data;
|
uint8_t *ptr = data;
|
||||||
|
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
address_space_rw(&address_space_io, port, MEMTXATTRS_UNSPECIFIED,
|
address_space_rw(&address_space_io, port, attrs,
|
||||||
ptr, size,
|
ptr, size,
|
||||||
direction == KVM_EXIT_IO_OUT);
|
direction == KVM_EXIT_IO_OUT);
|
||||||
ptr += size;
|
ptr += size;
|
||||||
@ -1796,6 +1796,8 @@ int kvm_cpu_exec(CPUState *cpu)
|
|||||||
}
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
MemTxAttrs attrs;
|
||||||
|
|
||||||
if (cpu->kvm_vcpu_dirty) {
|
if (cpu->kvm_vcpu_dirty) {
|
||||||
kvm_arch_put_registers(cpu, KVM_PUT_RUNTIME_STATE);
|
kvm_arch_put_registers(cpu, KVM_PUT_RUNTIME_STATE);
|
||||||
cpu->kvm_vcpu_dirty = false;
|
cpu->kvm_vcpu_dirty = false;
|
||||||
@ -1816,7 +1818,7 @@ int kvm_cpu_exec(CPUState *cpu)
|
|||||||
run_ret = kvm_vcpu_ioctl(cpu, KVM_RUN, 0);
|
run_ret = kvm_vcpu_ioctl(cpu, KVM_RUN, 0);
|
||||||
|
|
||||||
qemu_mutex_lock_iothread();
|
qemu_mutex_lock_iothread();
|
||||||
kvm_arch_post_run(cpu, run);
|
attrs = kvm_arch_post_run(cpu, run);
|
||||||
|
|
||||||
if (run_ret < 0) {
|
if (run_ret < 0) {
|
||||||
if (run_ret == -EINTR || run_ret == -EAGAIN) {
|
if (run_ret == -EINTR || run_ret == -EAGAIN) {
|
||||||
@ -1834,7 +1836,7 @@ int kvm_cpu_exec(CPUState *cpu)
|
|||||||
switch (run->exit_reason) {
|
switch (run->exit_reason) {
|
||||||
case KVM_EXIT_IO:
|
case KVM_EXIT_IO:
|
||||||
DPRINTF("handle_io\n");
|
DPRINTF("handle_io\n");
|
||||||
kvm_handle_io(run->io.port,
|
kvm_handle_io(run->io.port, attrs,
|
||||||
(uint8_t *)run + run->io.data_offset,
|
(uint8_t *)run + run->io.data_offset,
|
||||||
run->io.direction,
|
run->io.direction,
|
||||||
run->io.size,
|
run->io.size,
|
||||||
@ -1843,10 +1845,11 @@ int kvm_cpu_exec(CPUState *cpu)
|
|||||||
break;
|
break;
|
||||||
case KVM_EXIT_MMIO:
|
case KVM_EXIT_MMIO:
|
||||||
DPRINTF("handle_mmio\n");
|
DPRINTF("handle_mmio\n");
|
||||||
cpu_physical_memory_rw(run->mmio.phys_addr,
|
address_space_rw(&address_space_memory,
|
||||||
run->mmio.data,
|
run->mmio.phys_addr, attrs,
|
||||||
run->mmio.len,
|
run->mmio.data,
|
||||||
run->mmio.is_write);
|
run->mmio.len,
|
||||||
|
run->mmio.is_write);
|
||||||
ret = 0;
|
ret = 0;
|
||||||
break;
|
break;
|
||||||
case KVM_EXIT_IRQ_WINDOW_OPEN:
|
case KVM_EXIT_IRQ_WINDOW_OPEN:
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include "cpu.h"
|
#include "cpu.h"
|
||||||
#include "internals.h"
|
#include "internals.h"
|
||||||
#include "hw/arm/arm.h"
|
#include "hw/arm/arm.h"
|
||||||
|
#include "exec/memattrs.h"
|
||||||
|
|
||||||
const KVMCapabilityInfo kvm_arch_required_capabilities[] = {
|
const KVMCapabilityInfo kvm_arch_required_capabilities[] = {
|
||||||
KVM_CAP_LAST_INFO
|
KVM_CAP_LAST_INFO
|
||||||
@ -506,8 +507,9 @@ void kvm_arch_pre_run(CPUState *cs, struct kvm_run *run)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void kvm_arch_post_run(CPUState *cs, struct kvm_run *run)
|
MemTxAttrs kvm_arch_post_run(CPUState *cs, struct kvm_run *run)
|
||||||
{
|
{
|
||||||
|
return MEMTXATTRS_UNSPECIFIED;
|
||||||
}
|
}
|
||||||
|
|
||||||
int kvm_arch_handle_exit(CPUState *cs, struct kvm_run *run)
|
int kvm_arch_handle_exit(CPUState *cs, struct kvm_run *run)
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
#include "hw/pci/pci.h"
|
#include "hw/pci/pci.h"
|
||||||
#include "migration/migration.h"
|
#include "migration/migration.h"
|
||||||
#include "qapi/qmp/qerror.h"
|
#include "qapi/qmp/qerror.h"
|
||||||
|
#include "exec/memattrs.h"
|
||||||
|
|
||||||
//#define DEBUG_KVM
|
//#define DEBUG_KVM
|
||||||
|
|
||||||
@ -2246,7 +2247,7 @@ void kvm_arch_pre_run(CPUState *cpu, struct kvm_run *run)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void kvm_arch_post_run(CPUState *cpu, struct kvm_run *run)
|
MemTxAttrs kvm_arch_post_run(CPUState *cpu, struct kvm_run *run)
|
||||||
{
|
{
|
||||||
X86CPU *x86_cpu = X86_CPU(cpu);
|
X86CPU *x86_cpu = X86_CPU(cpu);
|
||||||
CPUX86State *env = &x86_cpu->env;
|
CPUX86State *env = &x86_cpu->env;
|
||||||
@ -2258,6 +2259,7 @@ void kvm_arch_post_run(CPUState *cpu, struct kvm_run *run)
|
|||||||
}
|
}
|
||||||
cpu_set_apic_tpr(x86_cpu->apic_state, run->cr8);
|
cpu_set_apic_tpr(x86_cpu->apic_state, run->cr8);
|
||||||
cpu_set_apic_base(x86_cpu->apic_state, run->apic_base);
|
cpu_set_apic_base(x86_cpu->apic_state, run->apic_base);
|
||||||
|
return MEMTXATTRS_UNSPECIFIED;
|
||||||
}
|
}
|
||||||
|
|
||||||
int kvm_arch_process_async_events(CPUState *cs)
|
int kvm_arch_process_async_events(CPUState *cs)
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include "cpu.h"
|
#include "cpu.h"
|
||||||
#include "sysemu/cpus.h"
|
#include "sysemu/cpus.h"
|
||||||
#include "kvm_mips.h"
|
#include "kvm_mips.h"
|
||||||
|
#include "exec/memattrs.h"
|
||||||
|
|
||||||
#define DEBUG_KVM 0
|
#define DEBUG_KVM 0
|
||||||
|
|
||||||
@ -110,9 +111,10 @@ void kvm_arch_pre_run(CPUState *cs, struct kvm_run *run)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void kvm_arch_post_run(CPUState *cs, struct kvm_run *run)
|
MemTxAttrs kvm_arch_post_run(CPUState *cs, struct kvm_run *run)
|
||||||
{
|
{
|
||||||
DPRINTF("%s\n", __func__);
|
DPRINTF("%s\n", __func__);
|
||||||
|
return MEMTXATTRS_UNSPECIFIED;
|
||||||
}
|
}
|
||||||
|
|
||||||
int kvm_arch_process_async_events(CPUState *cs)
|
int kvm_arch_process_async_events(CPUState *cs)
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
#include "sysemu/watchdog.h"
|
#include "sysemu/watchdog.h"
|
||||||
#include "trace.h"
|
#include "trace.h"
|
||||||
#include "exec/gdbstub.h"
|
#include "exec/gdbstub.h"
|
||||||
|
#include "exec/memattrs.h"
|
||||||
|
|
||||||
//#define DEBUG_KVM
|
//#define DEBUG_KVM
|
||||||
|
|
||||||
@ -1270,8 +1271,9 @@ void kvm_arch_pre_run(CPUState *cs, struct kvm_run *run)
|
|||||||
* anyways, so we will get a chance to deliver the rest. */
|
* anyways, so we will get a chance to deliver the rest. */
|
||||||
}
|
}
|
||||||
|
|
||||||
void kvm_arch_post_run(CPUState *cpu, struct kvm_run *run)
|
MemTxAttrs kvm_arch_post_run(CPUState *cs, struct kvm_run *run)
|
||||||
{
|
{
|
||||||
|
return MEMTXATTRS_UNSPECIFIED;
|
||||||
}
|
}
|
||||||
|
|
||||||
int kvm_arch_process_async_events(CPUState *cs)
|
int kvm_arch_process_async_events(CPUState *cs)
|
||||||
|
@ -45,6 +45,7 @@
|
|||||||
#include "hw/s390x/s390-pci-bus.h"
|
#include "hw/s390x/s390-pci-bus.h"
|
||||||
#include "hw/s390x/ipl.h"
|
#include "hw/s390x/ipl.h"
|
||||||
#include "hw/s390x/ebcdic.h"
|
#include "hw/s390x/ebcdic.h"
|
||||||
|
#include "exec/memattrs.h"
|
||||||
|
|
||||||
/* #define DEBUG_KVM */
|
/* #define DEBUG_KVM */
|
||||||
|
|
||||||
@ -769,8 +770,9 @@ void kvm_arch_pre_run(CPUState *cpu, struct kvm_run *run)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void kvm_arch_post_run(CPUState *cpu, struct kvm_run *run)
|
MemTxAttrs kvm_arch_post_run(CPUState *cs, struct kvm_run *run)
|
||||||
{
|
{
|
||||||
|
return MEMTXATTRS_UNSPECIFIED;
|
||||||
}
|
}
|
||||||
|
|
||||||
int kvm_arch_process_async_events(CPUState *cs)
|
int kvm_arch_process_async_events(CPUState *cs)
|
||||||
|
Loading…
Reference in New Issue
Block a user