target-arm queue
The following changes since commit d5001cf787ad0514839a81d0f2e771e01e076e21:
xilinx: Delete hw/include/xilinx.h (2014-02-26 14:54:45 +1000)
are available in the git repository at:
git://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20140226
for you to fetch changes up to c04018e93390e31b40044f3db92c173fb0ccb3d2:
dma/pl330: implement dmaadnh instruction (2014-02-26 17:20:09 +0000)
----------------------------------------------------------------
target-arm queue:
* fixes for various Coverity-spotted bugs
* support new KVM device control API for VGIC
* support KVM VGIC save/restore/migration
* more AArch64 system mode foundations
* support ARMv8 CRC instructions for A32/T32
* PL330 minor fixes and cleanup
----------------------------------------------------------------
Christoffer Dall (6):
hw/intc/arm_gic: Fix GIC_SET_LEVEL
linux-headers: Update from v3.14-rc3
kvm: Introduce kvm_arch_irqchip_create
kvm: Common device control API functions
arm: vgic device control api support
hw: arm_gic_kvm: Add KVM VGIC save/restore logic
Peter Crosthwaite (7):
dma/pl330: Delete overly verbose debug printf dma/pl330: Fix misleading type dma/pl330: printf format type sweep. dma/pl330: Rename parent_obj dma/pl330: Add event debugging printfs dma/pl330: Fix buffer depth dma/pl330: implement dmaadnh instruction
Peter Maydell (30):
hw/misc/arm_sysctl: Fix bad boundary check on mb clock accesses hw/net/stellaris_enet: Avoid unintended sign extension hw/timer/arm_timer: Avoid array overrun for bad addresses
target-arm: Fix incorrect arithmetic constructing short-form PAR for ATS ops hw/intc/exynos4210_combiner: Don't overrun output_irq array in init hw/arm/musicpal: Remove nonexistent CDTP2, CDTP3 registers
target-arm: Load correct access bits from ARMv5 level 2 page table descriptors
target-arm: Fix raw read and write functions on AArch64 registers
target-arm: A64: Make cache ID registers visible to AArch64
target-arm: Implement AArch64 CurrentEL sysreg
target-arm: Implement AArch64 MIDR_EL1
target-arm: Implement AArch64 cache invalidate/clean ops
target-arm: Implement AArch64 TLB invalidate ops
target-arm: Implement AArch64 dummy MDSCR_EL1
target-arm: Implement AArch64 memory attribute registers
target-arm: Implement AArch64 SCTLR_EL1
target-arm: Implement AArch64 TCR_EL1
target-arm: Implement AArch64 VBAR_EL1
target-arm: Implement AArch64 TTBR*
target-arm: Implement AArch64 MPIDR
target-arm: Implement AArch64 generic timers
target-arm: Implement AArch64 ID and feature registers
target-arm: Implement AArch64 dummy breakpoint and watchpoint registers
target-arm: Implement AArch64 OSLAR_EL1 sysreg as WI
target-arm: Get MMU index information correct for A64 code
target-arm: A64: Implement WFI
target-arm: Store AIF bits in env->pstate for AArch32
target-arm: A64: Implement MSR (immediate) instructions
target-arm: Implement AArch64 view of CPACR
target-arm: Add utility function for checking AA32/64 state of an EL
Will Newton (2):
include/qemu/crc32c.h: Rename include guards to match filename
target-arm: Add support for AArch32 ARMv8 CRC32 instructions
configure | 2 +- cpu-exec.c | 4 +- hw/arm/musicpal.c | 6 +- hw/arm/pxa2xx.c | 6 +- hw/dma/pl330.c | 55 ++-- hw/intc/arm_gic_kvm.c | 446 ++++++++++++++++++++++++++++++- hw/intc/exynos4210_combiner.c | 2 +- hw/intc/gic_internal.h | 2 +- hw/misc/arm_sysctl.c | 4 +- hw/net/stellaris_enet.c | 3 +- hw/timer/arm_timer.c | 2 + include/hw/intc/arm_gic_common.h | 1 + include/qemu/crc32c.h | 4 +- include/sysemu/kvm.h | 34 +++ kvm-all.c | 50 +++- linux-headers/asm-arm/kvm.h | 28 ++ linux-headers/asm-arm64/kvm.h | 30 ++- linux-headers/asm-powerpc/kvm.h | 3 + linux-headers/asm-x86/hyperv.h | 16 +- linux-headers/linux/kvm.h | 1 + stubs/Makefile.objs | 1 + stubs/kvm.c | 7 + target-arm/cpu-qom.h | 10 + target-arm/cpu.c | 13 +- target-arm/cpu.h | 80 ++++-- target-arm/cpu64.c | 1 + target-arm/helper.c | 562 +++++++++++++++++++++++++++++++-------- target-arm/helper.h | 5 + target-arm/kvm.c | 55 +++- target-arm/kvm_arm.h | 17 +- target-arm/op_helper.c | 25 ++ target-arm/translate-a64.c | 39 ++- target-arm/translate.c | 56 ++++ trace-events | 1 + 34 files changed, 1379 insertions(+), 192 deletions(-) create mode 100644 stubs/kvm.c
[Qemu-devel] [PULL 11/45] kvm: Common device control API functions
From: Christoffer Dall <[email protected]>
Introduces two simple functions:
int kvm_device_ioctl(int fd, int type, ...);
int kvm_create_device(KVMState *s, uint64_t type, bool test);These functions wrap the basic ioctl-based interactions with KVM in a way similar to other KVM ioctl wrappers.
Message-id: [email protected]
--- include/sysemu/kvm.h | 22 ++++++++++++++++++++++ kvm-all.c | 39 +++++++++++++++++++++++++++++++++++++++ trace-events | 1 + 3 files changed, 62 insertions(+)
include/sysemu/kvm.h +22 -0
@@ -194,6 +194,28 @@ int kvm_vm_ioctl(KVMState *s, int type, ...);int kvm_vcpu_ioctl (CPUState *cpu,int type, ...); +/** +* kvm_device_ioctl - call an ioctl on a kvm device +* @fd: The KVM device file descriptor as returned from KVM_CREATE_DEVICE +* @type: The device-ctrl ioctl number +* +* Returns: -errno on error, nonnegative on success +*/ +int kvm_device_ioctl (int fd,int type, ...); + +/** +* kvm_create_device - create a KVM device for the device control API +* @KVMState: The KVMState pointer +* @type: The KVM device type (see Documentation/virtual/kvm/devices in the +* kernel source) +* @test: If true, only test if device can be created, but don't actually +* create the device. +* +* Returns: -errno on error, nonnegative on success: @test ? 0 : device fd; +*/ +int kvm_create_device (KVMState *s,uint64_t type,bool test); + +/* Arch specific hooks */ extern const KVMCapabilityInfo kvm_arch_required_capabilities[];
kvm-all.c +39 -0
@@ -1784,6 +1784,24 @@ int kvm_vcpu_ioctl(CPUState *cpu, int type, ...)return ret; } +int kvm_device_ioctl (int fd,int type, ...) +{ +int ret; +void *arg; +va_list ap; + +va_start (ap, type); + arg = va_arg(ap, void *); +va_end (ap); + +trace_kvm_device_ioctl (fd, type, arg); + ret =ioctl (fd, type, arg); +if (ret ==-1 ) { + ret = -errno; + } +return ret; +} +int kvm_has_sync_mmu (void ) {return kvm_check_extension (kvm_state,KVM_CAP_SYNC_MMU );
@@ -2065,3 +2083,24 @@ int kvm_on_sigbus(int code, void *addr) {return kvm_arch_on_sigbus (code, addr); } + +int kvm_create_device (KVMState *s,uint64_t type,bool test) +{ +int ret; +struct kvm_create_device create_dev; + + create_dev.type = type; + create_dev.fd =-1 ; + create_dev.flags = test ?KVM_CREATE_DEVICE_TEST :0 ; + +if (!kvm_check_extension (s,KVM_CAP_DEVICE_CTRL )) { +return -ENOTSUP ; + } + + ret =kvm_vm_ioctl (s,KVM_CREATE_DEVICE , &create_dev); +if (ret) { +return ret; + } + +return test ?0 : create_dev.fd; +}
trace-events +1 -0
@@ -1170,6 +1170,7 @@ kvm_ioctl(int type, void *arg) "type 0x%x, arg %p" kvm_vm_ioctl(int type, void *arg) "type 0x%x, arg %p" kvm_vcpu_ioctl(int cpu_index, int type, void *arg) "cpu_index %d, type 0x%x, arg %p" kvm_run_exit(int cpu_index, uint32_t reason) "cpu_index %d, reason %d" +kvm_device_ioctl(int fd, int type, void *arg) "dev fd %d, type 0x%x, arg %p" # memory.c memory_region_ops_read(void *mr, uint64_t addr, uint64_t value, unsigned size) "mr %p addr %#"PRIx64" value %#"PRIx64" size %u"
Signature · 1 line
1.9.0
[Qemu-devel] [PULL 10/45] kvm: Introduce kvm_arch_irqchip_create
In reply to Peter MaydellFrom: Christoffer Dall <[email protected]>
Introduce kvm_arch_irqchip_create an arch-specific hook in preparation for architecture-specific use of the device control API to create IRQ chips.
Following patches will implement the ARM irqchip create method to prefer the device control API over the older KVM_CREATE_IRQCHIP API.
Message-id: [email protected]
--- include/sysemu/kvm.h | 12 ++++++++++++ kvm-all.c | 11 +++++++++-- stubs/Makefile.objs | 1 + stubs/kvm.c | 7 +++++++ 4 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 stubs/kvm.c
include/sysemu/kvm.h +12 -0
@@ -319,4 +319,16 @@ int kvm_irqchip_remove_irqfd_notifier(KVMState *s, EventNotifier *n, int virq);void kvm_pc_gsi_handler (void *opaque,int n,int level);void kvm_pc_setup_irq_routing (bool pci_enabled);void kvm_init_irq_routing (KVMState *s); + +/** +* kvm_arch_irqchip_create: +* @KVMState: The KVMState pointer +* +* Allow architectures to create an in-kernel irq chip themselves. +* +* Returns: < 0: error +* 0: irq chip was not created +* > 0: irq chip was created +*/ +int kvm_arch_irqchip_create (KVMState *s);#endif
kvm-all.c +9 -2
@@ -1298,10 +1298,17 @@ static int kvm_irqchip_create(KVMState *s)return 0 ; } - ret =kvm_vm_ioctl (s,KVM_CREATE_IRQCHIP ); +/* First probe and see if there's a arch-specific hook to create the +* in-kernel irqchip for us */ + ret =kvm_arch_irqchip_create (s);if (ret <0 ) { -fprintf (stderr,"Create kernel irqchip failed\n" );return ret; + }else if (ret ==0 ) { + ret =kvm_vm_ioctl (s,KVM_CREATE_IRQCHIP ); +if (ret <0 ) { +fprintf (stderr,"Create kernel irqchip failed\n" ); +return ret; + } } kvm_kernel_irqchip = true;
stubs/Makefile.objs +1 -0
@@ -27,3 +27,4 @@ stub-obj-y += vm-stop.o stub-obj-y += vmstate.o stub-obj-$(CONFIG_WIN32) += fd-register.o stub-obj-y += cpus.o +stub-obj-y += kvm.o
stubs/kvm.c new file +7 -0
@@ -0,0 +1,7 @@ +#include "qemu-common.h" +#include "sysemu/kvm.h" + +int kvm_arch_irqchip_create (KVMState *s) +{ +return 0 ; +}
Signature · 1 line
1.9.0
[Qemu-devel] [PULL 16/45] target-arm: Implement AArch64 CurrentEL sysreg
In reply to Peter MaydellImplement the CurrentEL sysreg.
--- target-arm/cpu.h | 3 ++- target-arm/helper.c | 3 +++ target-arm/translate-a64.c | 7 +++++++ 3 files changed, 12 insertions(+), 1 deletion(-)
target-arm/cpu.h +2 -1
@@ -731,7 +731,8 @@ static inline uint64_t cpreg_to_kvm_id(uint32_t cpregid)#define ARM_CP_NOP (ARM_CP_SPECIAL | (1 << 8))#define ARM_CP_WFI (ARM_CP_SPECIAL | (2 << 8))#define ARM_CP_NZCV (ARM_CP_SPECIAL | (3 << 8)) -#define ARM_LAST_SPECIAL ARM_CP_NZCV +#define ARM_CP_CURRENTEL (ARM_CP_SPECIAL | (4 << 8)) +#define ARM_LAST_SPECIAL ARM_CP_CURRENTEL/* Used only as a terminator for ARMCPRegInfo lists */ #define ARM_CP_SENTINEL 0xffff/* Mask of only the flag bits in a type field */
target-arm/helper.c +3 -0
@@ -1533,6 +1533,9 @@ static const ARMCPRegInfo v8_cp_reginfo[] = { .opc0 = 3, .opc1 = 3, .opc2 = 7, .crn = 0, .crm = 0, .access = PL0_R, .type = ARM_CP_CONST, .resetvalue = 0x10 }, + { .name = "CURRENTEL", .state = ARM_CP_STATE_AA64, + .opc0 = 3, .opc1 = 0, .opc2 = 2, .crn = 4, .crm = 2, + .access = PL1_R, .type = ARM_CP_CURRENTEL }, REGINFO_SENTINEL };
target-arm/translate-a64.c +7 -0
@@ -1231,6 +1231,13 @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread,gen_set_nzcv (tcg_rt); }return ; +case ARM_CP_CURRENTEL : +/* Reads as current EL value from pstate, which is +* guaranteed to be constant by the tb flags. +*/ + tcg_rt =cpu_reg (s, rt); +tcg_gen_movi_i64 (tcg_rt, s->current_pl <<2 ); +return ;default :break ; }
Signature · 1 line
1.9.0
[Qemu-devel] [PULL 25/45] target-arm: Implement AArch64 TTBR*
In reply to Peter MaydellImplement the AArch64 TTBR* registers. For v7 these were already 64 bits to handle LPAE, but implemented as two separate uint32_t fields. Combine them into a single uint64_t which can be used for all purposes. Since this requires touching every use, take the opportunity to rename the field to the architectural name.
--- hw/arm/pxa2xx.c | 2 +- target-arm/cpu.h | 6 ++-- target-arm/helper.c | 89 ++++++++++++++++++----------------------------------- 3 files changed, 33 insertions(+), 64 deletions(-)
hw/arm/pxa2xx.c +1 -1
@@ -276,7 +276,7 @@ static void pxa2xx_pwrmode_write(CPUARMState *env, const ARMCPRegInfo *ri,ARM_CPU_MODE_SVC |CPSR_A |CPSR_F |CPSR_I ; s->cpu->env.cp15.c1_sys =0 ; s->cpu->env.cp15.c1_coproc =0 ; - s->cpu->env.cp15.c2_base0 =0 ; + s->cpu->env.cp15.ttbr0_el1 =0 ; s->cpu->env.cp15.c3 =0 ; s->pm_regs[PSSR >>2 ] |=0x8 ;/* Set STS */ s->pm_regs[RCSR >>2 ] |=0x8 ;/* Set GPR */
target-arm/cpu.h +2 -4
@@ -173,10 +173,8 @@ typedef struct CPUARMState {uint32_t c1_coproc;/* Coprocessor access register. */ uint32_t c1_xscaleauxcr;/* XScale auxiliary control register. */ uint32_t c1_scr;/* secure config register. */ -uint32_t c2_base0;/* MMU translation table base 0. */ -uint32_t c2_base0_hi;/* MMU translation table base 0, high 32 bits */ -uint32_t c2_base1;/* MMU translation table base 0. */ -uint32_t c2_base1_hi;/* MMU translation table base 1, high 32 bits */ +uint64_t ttbr0_el1;/* MMU translation table base 0. */ +uint64_t ttbr1_el1;/* MMU translation table base 1. */ uint64_t c2_control;/* MMU translation table base control. */ uint32_t c2_mask;/* MMU translation table base selection mask. */ uint32_t c2_base_mask;/* MMU translation table base 0 mask. */
target-arm/helper.c +30 -59
130 lines not on this page · raw message
Signature · 1 line
1.9.0
[Qemu-devel] [PULL 42/45] dma/pl330: Rename parent_obj
In reply to Peter MaydellFrom: Peter Crosthwaite <[email protected]>
As per current QOM conventions.
Message-id: abb137347ea1ee9c31487b544f3d5435fb17f6a4.1393372019.git.peter.crosthwaite@xilinx.com
--- hw/dma/pl330.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
hw/dma/pl330.c +2 -1
@@ -227,7 +227,8 @@ static const VMStateDescription vmstate_pl330_queue = { };struct PL330State { -SysBusDevice busdev; +SysBusDevice parent_obj; +MemoryRegion iomem;qemu_irq irq_abort;qemu_irq *irq;
Signature · 1 line
1.9.0
[Qemu-devel] [PULL 43/45] dma/pl330: Add event debugging printfs
In reply to Peter MaydellFrom: Peter Crosthwaite <[email protected]>
These are helpful to anyone trying to debug event sequencing.
Message-id: e82a0ad804db3de4f46839e55a9d287735ef870d.1393372019.git.peter.crosthwaite@xilinx.com
--- hw/dma/pl330.c | 2 ++ 1 file changed, 2 insertions(+)
hw/dma/pl330.c +2 -0
@@ -873,6 +873,7 @@ static void pl330_dmasev(PL330Chan *ch, uint8_t opcode, uint8_t *args, int len)DB_PRINT ("event interrupt raised %" PRId8"\n" , ev_id);qemu_irq_raise (ch->parent->irq[ev_id]); } +DB_PRINT ("event raised %" PRId8"\n" , ev_id); ch->parent->ev_status |= (1 << ev_id); }
@@ -975,6 +976,7 @@ static void pl330_dmawfe(PL330Chan *ch, uint8_t opcode, } } ch->parent->ev_status &= ~(1 << ev_id); +DB_PRINT ("event lowered %" PRIx8"\n" , ev_id); }else { ch->stall =1 ; }
Signature · 1 line
1.9.0
[Qemu-devel] [PULL 45/45] dma/pl330: implement dmaadnh instruction
In reply to Peter MaydellFrom: Peter Crosthwaite <[email protected]>
Implement the missing DMAADNH instruction. This is a minor variant of the DMAADDH instruction, so factor out to a common implementation for both (dmaadxh).
Message-id: 73ab13532a7cae53441da89b46c279b5f50785e3.1393372019.git.peter.crosthwaite@xilinx.com
--- hw/dma/pl330.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
hw/dma/pl330.c +16 -3
@@ -601,10 +601,12 @@ static inline void pl330_fault(PL330Chan *ch, uint32_t flags)* LEN - number of elements in ARGS array */ -static void pl330_dmaaddh (PL330Chan *ch,uint8_t opcode,uint8_t *args,int len) +static void pl330_dmaadxh (PL330Chan *ch,uint8_t *args,bool ra,bool neg) { -uint16_t im = (((uint16_t )args[1 ]) <<8 ) | ((uint16_t )args[0 ]); -uint8_t ra = (opcode >>1 ) &1 ; +uint32_t im = (args[1 ] <<8 ) | args[0 ]; +if (neg) { + im |=0xffffu <<16 ; + }if (ch->is_manager) {pl330_fault (ch,PL330_FAULT_UNDEF_INSTR );
@@ -617,6 +619,16 @@ static void pl330_dmaaddh(PL330Chan *ch, uint8_t opcode, uint8_t *args, int len) } } +static void pl330_dmaaddh (PL330Chan *ch,uint8_t opcode,uint8_t *args,int len) +{ +pl330_dmaadxh (ch, args,extract32 (opcode,1 ,1 ), false); +} + +static void pl330_dmaadnh (PL330Chan *ch,uint8_t opcode,uint8_t *args,int len) +{ +pl330_dmaadxh (ch, args,extract32 (opcode,1 ,1 ), true); +} +static void pl330_dmaend (PL330Chan *ch,uint8_t opcode,uint8_t *args,int len) {
@@ -1042,6 +1054,7 @@ static void pl330_dmawmb(PL330Chan *ch, uint8_t opcode,/* NULL terminated array of the instruction descriptions. */ static const PL330InsnDesc insn_desc[] = { { .opcode =0x54 , .opmask =0xFD , .size =3 , .exec = pl330_dmaaddh, }, + { .opcode =0x5c , .opmask =0xFD , .size =3 , .exec = pl330_dmaadnh, }, { .opcode =0x00 , .opmask =0xFF , .size =1 , .exec = pl330_dmaend, }, { .opcode =0x35 , .opmask =0xFF , .size =2 , .exec = pl330_dmaflushp, }, { .opcode =0xA0 , .opmask =0xFD , .size =6 , .exec = pl330_dmago, },
Signature · 1 line
1.9.0
[Qemu-devel] [PULL 39/45] dma/pl330: Delete overly verbose debug printf
In reply to Peter MaydellFrom: Peter Crosthwaite <[email protected]>
When using event synchronisation, this particular debug printf floods. Just delete it.
Message-id: dd94d19493f97c47497b9d8caf74ca43e70d58fd.1393372019.git.peter.crosthwaite@xilinx.com
--- hw/dma/pl330.c | 1 - 1 file changed, 1 deletion(-)
hw/dma/pl330.c +0 -1
@@ -1108,7 +1108,6 @@ static int pl330_chan_exec(PL330Chan *ch) ch->state != pl330_chan_waiting_periph && ch->state != pl330_chan_at_barrier && ch->state != pl330_chan_waiting_event) { -DB_PRINT ("%d\n" , ch->state);return 0 ; } ch->stall =0 ;
Signature · 1 line
1.9.0
[Qemu-devel] [PULL 40/45] dma/pl330: Fix misleading type
In reply to Peter MaydellFrom: Peter Crosthwaite <[email protected]>
This type really should just be a regular int as no usages rely on it's 32 bitness (it's only meaningful as a bit position and not a bit mask). This also fixes a printf which uses the variable with a regular %d.
Message-id: 2a99d31f377aee371476d9da8fd0d1b7efa30f63.1393372019.git.peter.crosthwaite@xilinx.com
--- hw/dma/pl330.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/dma/pl330.c +1 -1
@@ -1310,7 +1310,7 @@ static void pl330_iomem_write(void *opaque, hwaddr offset, uint64_t value, unsigned size) {PL330State *s = (PL330State *) opaque; -uint32_t i; +int i;DB_PRINT ("addr: %08x data: %08x\n" , (unsigned )offset, (unsigned )value);
Signature · 1 line
1.9.0
[Qemu-devel] [PULL 41/45] dma/pl330: printf format type sweep.
In reply to Peter MaydellFrom: Peter Crosthwaite <[email protected]>
Use PRI formats as appropriate rather than raw %x and %d. This fixes debug printfery on some host platforms. Fix types of debug only variables as appropriate.
Message-id: dbb5f5fd048b2d4a3cb5c6357577d11211a7a585.1393372019.git.peter.crosthwaite@xilinx.com
--- hw/dma/pl330.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-)
hw/dma/pl330.c +14 -12
@@ -577,7 +577,7 @@ static inline void pl330_queue_remove_tagged(PL330Queue *s, uint8_t tag)static inline void pl330_fault (PL330Chan *ch,uint32_t flags) { -DB_PRINT ("ch: %p, flags: %x\n" , ch, flags); +DB_PRINT ("ch: %p, flags: %" PRIx32"\n" , ch, flags); ch->fault_type |= flags;if (ch->state == pl330_chan_fault) {return ;
@@ -723,7 +723,8 @@ static void pl330_dmald(PL330Chan *ch, uint8_t opcode, uint8_t *args, int len) ch->stall =pl330_queue_put_insn (&ch->parent->read_queue, ch->src, size, num, inc,0 , ch->tag);if (!ch->stall) { -DB_PRINT ("channel:%d address:%08x size:%d num:%d %c\n" , +DB_PRINT ("channel:%" PRId8" address:%08" PRIx32" size:%" PRIx32 +" num:%" PRId32" %c\n" , ch->tag, ch->src, size, num, inc ?'Y' :'N' ); ch->src += inc ? size * num - (ch->src & (size -1 )) :0 ; }
@@ -868,7 +869,7 @@ static void pl330_dmasev(PL330Chan *ch, uint8_t opcode, uint8_t *args, int len) }if (ch->parent->inten & (1 << ev_id)) { ch->parent->int_status |= (1 << ev_id); -DB_PRINT ("event interrupt raised %d\n" , ev_id); +DB_PRINT ("event interrupt raised %" PRId8"\n" , ev_id);qemu_irq_raise (ch->parent->irq[ev_id]); } ch->parent->ev_status |= (1 << ev_id);
@@ -895,7 +896,8 @@ static void pl330_dmast(PL330Chan *ch, uint8_t opcode, uint8_t *args, int len) ch->stall =pl330_queue_put_insn (&ch->parent->write_queue, ch->dst, size, num, inc,0 , ch->tag);if (!ch->stall) { -DB_PRINT ("channel:%d address:%08x size:%d num:%d %c\n" , +DB_PRINT ("channel:%" PRId8" address:%08" PRIx32" size:%" PRIx32 +" num:%" PRId32" %c\n" , ch->tag, ch->dst, size, num, inc ?'Y' :'N' ); ch->dst += inc ? size * num - (ch->dst & (size -1 )) :0 ; }
@@ -1154,7 +1156,7 @@ static int pl330_exec_cycle(PL330Chan *channel)dma_memory_read (&address_space_memory, q->addr, buf, len);if (PL330_ERR_DEBUG >1 ) { -DB_PRINT ("PL330 read from memory @%08x (size = %08x):\n" , +DB_PRINT ("PL330 read from memory @%08" PRIx32" (size = %08x):\n" , q->addr, len);qemu_hexdump ((char *)buf, stderr,"" , len); }
@@ -1186,8 +1188,8 @@ static int pl330_exec_cycle(PL330Chan *channel)if (fifo_res ==PL330_FIFO_OK || q->z) {dma_memory_write (&address_space_memory, q->addr, buf, len);if (PL330_ERR_DEBUG >1 ) { -DB_PRINT ("PL330 read from memory @%08x (size = %08x):\n" , - q->addr, len); +DB_PRINT ("PL330 read from memory @%08" PRIx32 +" (size = %08x):\n" , q->addr, len);qemu_hexdump ((char *)buf, stderr,"" , len); }if (q->inc) {
@@ -1276,7 +1278,7 @@ static void pl330_debug_exec(PL330State *s) args[2 ] = (s->dbg[1 ] >>8 ) &0xff ; args[3 ] = (s->dbg[1 ] >>16 ) &0xff ; args[4 ] = (s->dbg[1 ] >>24 ) &0xff ; -DB_PRINT ("chan id: %d\n" , chan_id); +DB_PRINT ("chan id: %" PRIx8"\n" , chan_id);if (s->dbg[0 ] &1 ) { ch = &s->chan[chan_id]; }else {
@@ -1466,8 +1468,8 @@ static inline uint32_t pl330_iomem_read_imp(void *opaque,static uint64_t pl330_iomem_read (void *opaque,hwaddr offset,unsigned size) { -int ret =pl330_iomem_read_imp (opaque, offset); -DB_PRINT ("addr: %08x data: %08x\n" , (unsigned )offset, ret); +uint32_t ret =pl330_iomem_read_imp (opaque, offset); +DB_PRINT ("addr: %08" HWADDR_PRIx" data: %08" PRIx32"\n" , offset, ret);return ret; }
@@ -1553,7 +1555,7 @@ static void pl330_realize(DeviceState *dev, Error **errp) s->cfg[1 ] |=5 ;break ;default : -error_setg (errp,"Bad value for i-cache_len property: %d\n" , +error_setg (errp,"Bad value for i-cache_len property: %" PRIx8"\n" , s->i_cache_len);return ; }
@@ -1588,7 +1590,7 @@ static void pl330_realize(DeviceState *dev, Error **errp) s->cfg[CFG_CRD ] |=0x4 ;break ;default : -error_setg (errp,"Bad value for data_width property: %d\n" , +error_setg (errp,"Bad value for data_width property: %" PRIx8"\n" , s->data_width);return ; }
Signature · 1 line
1.9.0
[Qemu-devel] [PULL 12/45] arm: vgic device control api support
In reply to Peter MaydellFrom: Christoffer Dall <[email protected]>
Support creating the ARM vgic device through the device control API and setting the base address for the distributor and cpu interfaces in KVM VMs using this API.
Because the older KVM_CREATE_IRQCHIP interface needs the irq chip to be created prior to creating the VCPUs, we first test if we can use the device control API in kvm_arch_irqchip_create (using the test flag from the device control API). If we cannot, it means we have to fall back to KVM_CREATE_IRQCHIP and use the older ioctl at this point in time. If however, we can use the device control API, we don't do anything and wait until the arm_gic_kvm driver initializes and let that use the device control API.
Message-id: [email protected]
--- hw/intc/arm_gic_kvm.c | 22 ++++++++++++++-- include/hw/intc/arm_gic_common.h | 1 + target-arm/kvm.c | 55 +++++++++++++++++++++++++++++++++++----- target-arm/kvm_arm.h | 17 ++++++++----- 4 files changed, 80 insertions(+), 15 deletions(-)
hw/intc/arm_gic_kvm.c +20 -2
@@ -97,6 +97,7 @@ static void kvm_arm_gic_realize(DeviceState *dev, Error **errp)GICState *s =KVM_ARM_GIC (dev);SysBusDevice *sbd =SYS_BUS_DEVICE (dev);KVMARMGICClass *kgc =KVM_ARM_GIC_GET_CLASS (s); +int ret; kgc->parent_realize (dev, errp);if (error_is_set (errp)) {
@@ -119,13 +120,27 @@ static void kvm_arm_gic_realize(DeviceState *dev, Error **errp)for (i =0 ; i < s->num_cpu; i++) {sysbus_init_irq (sbd, &s->parent_irq[i]); } + +/* Try to create the device via the device control API */ + s->dev_fd =-1 ; + ret =kvm_create_device (kvm_state,KVM_DEV_TYPE_ARM_VGIC_V2 , false); +if (ret >=0 ) { + s->dev_fd = ret; + }else if (ret != -ENODEV && ret != -ENOTSUP ) { +error_setg_errno (errp, -ret,"error creating in-kernel VGIC" ); +return ; + } +/* Distributor */ memory_region_init_reservation (&s->iomem,OBJECT (s),"kvm-gic_dist" ,0x1000 );sysbus_init_mmio (sbd, &s->iomem);kvm_arm_register_device (&s->iomem, (KVM_ARM_DEVICE_VGIC_V2 <<KVM_ARM_DEVICE_ID_SHIFT ) - |KVM_VGIC_V2_ADDR_TYPE_DIST ); + |KVM_VGIC_V2_ADDR_TYPE_DIST , +KVM_DEV_ARM_VGIC_GRP_ADDR , +KVM_VGIC_V2_ADDR_TYPE_DIST , + s->dev_fd);/* CPU interface for current core. Unlike arm_gic, we don't * provide the "interface for core #N" memory regions, because * cores with a VGIC don't have those.
@@ -135,7 +150,10 @@ static void kvm_arm_gic_realize(DeviceState *dev, Error **errp)sysbus_init_mmio (sbd, &s->cpuiomem[0 ]);kvm_arm_register_device (&s->cpuiomem[0 ], (KVM_ARM_DEVICE_VGIC_V2 <<KVM_ARM_DEVICE_ID_SHIFT ) - |KVM_VGIC_V2_ADDR_TYPE_CPU ); + |KVM_VGIC_V2_ADDR_TYPE_CPU , +KVM_DEV_ARM_VGIC_GRP_ADDR , +KVM_VGIC_V2_ADDR_TYPE_CPU , + s->dev_fd); }static void kvm_arm_gic_class_init (ObjectClass *klass,void *data)
include/hw/intc/arm_gic_common.h +1 -0
@@ -104,6 +104,7 @@ typedef struct GICState {MemoryRegion cpuiomem[GIC_NCPU +1 ];/* CPU interfaces */ uint32_t num_irq;uint32_t revision; +int dev_fd;/* kvm device fd if backed by kvm vgic support */ } GICState;#define TYPE_ARM_GIC_COMMON "arm_gic_common"
target-arm/kvm.c +48 -7
90 lines not on this page · raw message
target-arm/kvm_arm.h +11 -6
@@ -18,16 +18,21 @@* kvm_arm_register_device: * @mr: memory region for this device * @devid: the KVM device ID +* @group: device control API group for setting addresses +* @attr: device control API address type +* @dev_fd: device control device file descriptor (or -1 if not supported) * * Remember the memory region @mr, and when it is mapped by the * machine model, tell the kernel that base address using the -* KVM_SET_DEVICE_ADDRESS ioctl. @devid should be the ID of -* the device as defined by KVM_SET_DEVICE_ADDRESS. -* The machine model may map and unmap the device multiple times; -* the kernel will only be told the final address at the point -* where machine init is complete. +* KVM_ARM_SET_DEVICE_ADDRESS ioctl or the newer device control API. @devid +* should be the ID of the device as defined by KVM_ARM_SET_DEVICE_ADDRESS or +* the arm-vgic device in the device control API. +* The machine model may map +* and unmap the device multiple times; the kernel will only be told the final +* address at the point where machine init is complete. */ -void kvm_arm_register_device (MemoryRegion *mr,uint64_t devid); +void kvm_arm_register_device (MemoryRegion *mr,uint64_t devid,uint64_t group, +uint64_t attr,int dev_fd);/** * write_list_to_kvmstate:
Signature · 1 line
1.9.0
[Qemu-devel] [PULL 23/45] target-arm: Implement AArch64 TCR_EL1
In reply to Peter MaydellImplement the AArch64 TCR_EL1, which is the 64 bit view of the AArch32 TTBCR. (The uses of the bits in the register are completely different, but in any given situation the CPU will always interpret them one way or the other. In fact for QEMU EL1 is always 64 bit, but we share the state field because this is the correct mapping to permit a future implementation of EL2.) We also make the AArch64 view the 'master' as far as migration and reset is concerned.
--- target-arm/cpu.h | 2 +- target-arm/helper.c | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-)
target-arm/cpu.h +1 -1
@@ -177,7 +177,7 @@ typedef struct CPUARMState {uint32_t c2_base0_hi;/* MMU translation table base 0, high 32 bits */ uint32_t c2_base1;/* MMU translation table base 0. */ uint32_t c2_base1_hi;/* MMU translation table base 1, high 32 bits */ -uint32_t c2_control;/* MMU translation table base control. */ +uint64_t c2_control;/* MMU translation table base control. */ uint32_t c2_mask;/* MMU translation table base selection mask. */ uint32_t c2_base_mask;/* MMU translation table base 0 mask. */ uint32_t c2_data;/* MPU data cachable bits. */
target-arm/helper.c +16 -3
@@ -1215,6 +1215,14 @@ static void vmsa_ttbcr_reset(CPUARMState *env, const ARMCPRegInfo *ri) env->cp15.c2_mask =0 ; } +static void vmsa_tcr_el1_write (CPUARMState *env,const ARMCPRegInfo *ri, +uint64_t value) +{ +/* For AArch64 the A1 bit could result in a change of ASID, so TLB flush. */ +tlb_flush (env,1 ); + env->cp15.c2_control = value; +} +static const ARMCPRegInfo vmsa_cp_reginfo[] = { { .name ="DFSR" , .cp =15 , .crn =5 , .crm =0 , .opc1 =0 , .opc2 =0 , .access =PL1_RW ,
@@ -1228,10 +1236,15 @@ static const ARMCPRegInfo vmsa_cp_reginfo[] = { { .name = "TTBR1", .cp = 15, .crn = 2, .crm = 0, .opc1 = 0, .opc2 = 1, .access = PL1_RW, .fieldoffset = offsetof(CPUARMState, cp15.c2_base1), .resetvalue = 0, }, - { .name = "TTBCR", .cp = 15, .crn = 2, .crm = 0, .opc1 = 0, .opc2 = 2, - .access = PL1_RW, .writefn = vmsa_ttbcr_write, - .resetfn = vmsa_ttbcr_reset, .raw_writefn = vmsa_ttbcr_raw_write, + { .name = "TCR_EL1", .state = ARM_CP_STATE_AA64, + .opc0 = 3, .crn = 2, .crm = 0, .opc1 = 0, .opc2 = 2, + .access = PL1_RW, .writefn = vmsa_tcr_el1_write, + .resetfn = vmsa_ttbcr_reset, .raw_writefn = raw_write, .fieldoffset = offsetof(CPUARMState, cp15.c2_control) }, + { .name = "TTBCR", .cp = 15, .crn = 2, .crm = 0, .opc1 = 0, .opc2 = 2, + .access = PL1_RW, .type = ARM_CP_NO_MIGRATE, .writefn = vmsa_ttbcr_write, + .resetfn = arm_cp_reset_ignore, .raw_writefn = vmsa_ttbcr_raw_write, + .fieldoffset = offsetoflow32(CPUARMState, cp15.c2_control) }, { .name = "DFAR", .cp = 15, .crn = 6, .crm = 0, .opc1 = 0, .opc2 = 0, .access = PL1_RW, .fieldoffset = offsetof(CPUARMState, cp15.c6_data), .resetvalue = 0, },
Signature · 1 line
1.9.0
[Qemu-devel] [PULL 36/45] target-arm: Add utility function for checking AA32/64 state of an EL
In reply to Peter MaydellThere are various situations where we need to behave differently depending on whether a given exception level is in AArch64 or AArch32 state. The state of the current exception level is stored in env->aarch64, but there's no equivalent guest-visible architected state bits for the status of the exception levels "above" the current one which may still affect execution. At the moment we only support EL1 (ie no EL2 or EL3) and insist that AArch64 capable CPUs run with EL1 in AArch64 state, but these may change in the future, so abstract out the "what state is this?" check into a utility function which can be enhanced later if necessary.
--- target-arm/cpu.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
target-arm/cpu.h +16 -0
@@ -633,6 +633,22 @@ static inline int arm_feature(CPUARMState *env, int feature)return (env->features & (1ULL << feature)) !=0 ; } +/* Return true if the specified exception level is running in AArch64 state. */ +static inline bool arm_el_is_aa64 (CPUARMState *env,int el) +{ +/* We don't currently support EL2 or EL3, and this isn't valid for EL0 +* (if we're in EL0, is_a64() is what you want, and if we're not in EL0 +* then the state of EL0 isn't well defined.) +*/ +assert (el ==1 ); +/* AArch64-capable CPUs always run with EL1 in AArch64 mode. This +* is a QEMU-imposed simplification which we may wish to change later. +* If we in future support EL2 and/or EL3, then the state of lower +* exception levels is controlled by the HCR.RW and SCR.RW bits. +*/ +return arm_feature (env,ARM_FEATURE_AARCH64 ); +} +void arm_cpu_list (FILE *f,fprintf_function cpu_fprintf);/* Interface between CPU and Interrupt controller. */
Signature · 1 line
1.9.0
[Qemu-devel] [PULL 37/45] include/qemu/crc32c.h: Rename include guards to match filename
In reply to Peter MaydellFrom: Will Newton <[email protected]>
Message-id: [email protected]
--- include/qemu/crc32c.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/qemu/crc32c.h +2 -2
@@ -25,8 +25,8 @@* */ -#ifndef QEMU_CRC32_H -#define QEMU_CRC32_H +#ifndef QEMU_CRC32C_H +#define QEMU_CRC32C_H #include "qemu-common.h"
Signature · 1 line
1.9.0
[Qemu-devel] [PULL 22/45] target-arm: Implement AArch64 SCTLR_EL1
In reply to Peter MaydellImplement the AArch64 view of the system control register SCTLR_EL1.
--- target-arm/cpu.h | 2 +- target-arm/helper.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-)
target-arm/cpu.h +1 -1
@@ -169,7 +169,7 @@ typedef struct CPUARMState {struct {uint32_t c0_cpuid;uint64_t c0_cssel;/* Cache size selection. */ -uint32_t c1_sys;/* System control register. */ +uint64_t c1_sys;/* System control register. */ uint32_t c1_coproc;/* Coprocessor access register. */ uint32_t c1_xscaleauxcr;/* XScale auxiliary control register. */ uint32_t c1_scr;/* secure config register. */
target-arm/helper.c +2 -1
@@ -1948,7 +1948,8 @@ void register_cp_regs_for_features(ARMCPU *cpu)/* Generic registers whose values depend on the implementation */ {ARMCPRegInfo sctlr = { - .name ="SCTLR" , .cp =15 , .crn =1 , .crm =0 , .opc1 =0 , .opc2 =0 , + .name ="SCTLR" , .state =ARM_CP_STATE_BOTH , + .opc0 =3 , .crn =1 , .crm =0 , .opc1 =0 , .opc2 =0 , .access = PL1_RW, .fieldoffset = offsetof(CPUARMState, cp15.c1_sys), .writefn = sctlr_write, .resetvalue = cpu->reset_sctlr, .raw_writefn = raw_write,
Signature · 1 line
1.9.0
[Qemu-devel] [PULL 35/45] target-arm: Implement AArch64 view of CPACR
In reply to Peter MaydellImplement the AArch64 view of the CPACR. The AArch64 CPACR is defined to have a lot of RES0 bits, but since the architecture defines that RES0 bits may be implemented as reads-as-written and we know that a v8 CPU will have no registered coprocessors for cp0..cp13 we can safely implement the whole register this way.
--- target-arm/cpu.h | 2 +- target-arm/helper.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-)
target-arm/cpu.h +1 -1
@@ -172,7 +172,7 @@ typedef struct CPUARMState {uint32_t c0_cpuid;uint64_t c0_cssel;/* Cache size selection. */ uint64_t c1_sys;/* System control register. */ -uint32_t c1_coproc;/* Coprocessor access register. */ +uint64_t c1_coproc;/* Coprocessor access register. */ uint32_t c1_xscaleauxcr;/* XScale auxiliary control register. */ uint32_t c1_scr;/* secure config register. */ uint64_t ttbr0_el1;/* MMU translation table base 0. */
target-arm/helper.c +2 -1
@@ -458,7 +458,8 @@ static const ARMCPRegInfo v6_cp_reginfo[] = {*/ { .name = "WFAR", .cp = 15, .crn = 6, .crm = 0, .opc1 = 0, .opc2 = 1, .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0, }, - { .name = "CPACR", .cp = 15, .crn = 1, .crm = 0, .opc1 = 0, .opc2 = 2, + { .name = "CPACR", .state = ARM_CP_STATE_BOTH, .opc0 = 3, + .crn = 1, .crm = 0, .opc1 = 0, .opc2 = 2, .access = PL1_RW, .fieldoffset = offsetof(CPUARMState, cp15.c1_coproc), .resetvalue = 0, .writefn = cpacr_write }, REGINFO_SENTINEL
Signature · 1 line
1.9.0
[Qemu-devel] [PULL 38/45] target-arm: Add support for AArch32 ARMv8 CRC32 instructions
In reply to Peter MaydellFrom: Will Newton <[email protected]>
Add support for AArch32 CRC32 and CRC32C instructions added in ARMv8 and add a CPU feature flag to enable these instructions.
The CRC32-C implementation used is the built-in qemu implementation and The CRC-32 implementation is from zlib. This requires adding zlib to LIBS to ensure it is linked for the linux-user binary.
Message-id: [email protected]
--- configure | 2 +- target-arm/cpu.c | 1 + target-arm/cpu.h | 1 + target-arm/helper.c | 39 +++++++++++++++++++++++++++++++++++ target-arm/helper.h | 3 +++ target-arm/translate.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 101 insertions(+), 1 deletion(-)
configure +1 -1
@@ -1657,7 +1657,7 @@ EOF "Make sure to have the zlib libs and headers installed." fi fi -libs_softmmu="$libs_softmmu -lz" +LIBS="$LIBS -lz" ########################################## # libseccomp check
target-arm/cpu.c +1 -0
@@ -924,6 +924,7 @@ static void arm_any_initfn(Object *obj)set_feature (&cpu->env,ARM_FEATURE_THUMB2EE );set_feature (&cpu->env,ARM_FEATURE_ARM_DIV );set_feature (&cpu->env,ARM_FEATURE_V7MP ); +set_feature (&cpu->env,ARM_FEATURE_CRC );#ifdef TARGET_AARCH64 set_feature (&cpu->env,ARM_FEATURE_AARCH64 );#endif
target-arm/cpu.h +1 -0
@@ -626,6 +626,7 @@ enum arm_features {ARM_FEATURE_AARCH64 ,/* supports 64 bit mode */ ARM_FEATURE_V8_AES ,/* implements AES part of v8 Crypto Extensions */ ARM_FEATURE_CBAR ,/* has cp15 CBAR */ + ARM_FEATURE_CRC, /* ARMv8 CRC instructions */ };static inline int arm_feature (CPUARMState *env,int feature)
target-arm/helper.c +39 -0
@@ -5,6 +5,8 @@#include "sysemu/arch_init.h" #include "sysemu/sysemu.h" #include "qemu/bitops.h" +#include "qemu/crc32c.h" +#include <zlib.h> /* For crc32 */ #ifndef CONFIG_USER_ONLY static inline int get_phys_addr(CPUARMState *env, uint32_t address,
@@ -4703,3 +4705,40 @@ int arm_rmode_to_sf(int rmode) }return rmode; } + +static void crc_init_buffer (uint8_t *buf,uint32_t val,uint32_t bytes) +{ +memset (buf,0 ,4 ); + +if (bytes ==1 ) { + buf[0 ] = val &0xff ; + }else if (bytes ==2 ) { + buf[0 ] = val &0xff ; + buf[1 ] = (val >>8 ) &0xff ; + }else { + buf[0 ] = val &0xff ; + buf[1 ] = (val >>8 ) &0xff ; + buf[2 ] = (val >>16 ) &0xff ; + buf[3 ] = (val >>24 ) &0xff ; + } +} + +uint32_t HELPER (crc32 )(uint32_t acc,uint32_t val,uint32_t bytes) +{ +uint8_t buf[4 ]; + +crc_init_buffer (buf, val, bytes); + +/* zlib crc32 converts the accumulator and output to one's complement. */ +return crc32 (acc ^0xffffffff , buf, bytes) ^0xffffffff ; +} + +uint32_t HELPER (crc32c )(uint32_t acc,uint32_t val,uint32_t bytes) +{ +uint8_t buf[4 ]; + +crc_init_buffer (buf, val, bytes); + +/* Linux crc32c converts the output to one's complement. */ +return crc32c (acc, buf, bytes) ^0xffffffff ; +}
target-arm/helper.h +3 -0
@@ -499,6 +499,9 @@ DEF_HELPER_3(neon_qzip32, void, env, i32, i32) DEF_HELPER_4(crypto_aese, void, env, i32, i32, i32) DEF_HELPER_4(crypto_aesmc, void, env, i32, i32, i32) +DEF_HELPER_FLAGS_3(crc32, TCG_CALL_NO_RWG_SE, i32, i32, i32, i32) +DEF_HELPER_FLAGS_3(crc32c, TCG_CALL_NO_RWG_SE, i32, i32, i32, i32) +#ifdef TARGET_AARCH64 #include "helper-a64.h" #endif
target-arm/translate.c +56 -0
68 lines not on this page · raw message
Signature · 1 line
1.9.0
[Qemu-devel] [PULL 44/45] dma/pl330: Fix buffer depth
In reply to Peter MaydellFrom: Peter Crosthwaite <[email protected]>
This is the product of the data-width and the depth arguments, I.e the depth of the FIFO is in terms of data entries and not bytes (which is what the original implementation was suggesting). Fix.
Message-id: c34de31031511538ccdb3164b48ee8a6a973ebd4.1393372019.git.peter.crosthwaite@xilinx.com
--- hw/dma/pl330.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/dma/pl330.c +1 -1
@@ -1606,7 +1606,7 @@ static void pl330_realize(DeviceState *dev, Error **errp)pl330_queue_init (&s->read_queue, s->rd_q_dep, s);pl330_queue_init (&s->write_queue, s->wr_q_dep, s); -pl330_fifo_init (&s->fifo, s->data_buffer_dep); +pl330_fifo_init (&s->fifo, s->data_width /4 * s->data_buffer_dep); }static Property pl330_properties[] = {
Signature · 1 line
1.9.0
[Qemu-devel] [PULL 17/45] target-arm: Implement AArch64 MIDR_EL1
In reply to Peter MaydellImplement the AArch64 view of the MIDR system register (for AArch64 it is a simple constant, unlike the complicated mess that TI925 imposes on the 32-bit view).
--- target-arm/helper.c | 3 +++ 1 file changed, 3 insertions(+)
target-arm/helper.c +3 -0
@@ -1720,6 +1720,9 @@ void register_cp_regs_for_features(ARMCPU *cpu) .writefn = arm_cp_write_ignore, .raw_writefn = raw_write, .fieldoffset = offsetof(CPUARMState, cp15.c0_cpuid), .type = ARM_CP_OVERRIDE }, + { .name = "MIDR_EL1", .state = ARM_CP_STATE_AA64, + .opc0 = 3, .opc1 = 0, .opc2 = 0, .crn = 0, .crm = 0, + .access = PL1_R, .resetvalue = cpu->midr, .type = ARM_CP_CONST }, { .name = "CTR", .cp = 15, .crn = 0, .crm = 0, .opc1 = 0, .opc2 = 1, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = cpu->ctr },
Signature · 1 line
1.9.0
[Qemu-devel] [PULL 24/45] target-arm: Implement AArch64 VBAR_EL1
In reply to Peter MaydellImplement the A64 view of the VBAR system register.
--- target-arm/cpu.h | 2 +- target-arm/helper.c | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-)
target-arm/cpu.h +1 -1
@@ -200,7 +200,7 @@ typedef struct CPUARMState {uint32_t c9_pmuserenr;/* perf monitor user enable */ uint32_t c9_pminten;/* perf monitor interrupt enables */ uint64_t mair_el1; -uint32_t c12_vbar;/* vector base address register */ +uint64_t c12_vbar;/* vector base address register */ uint32_t c13_fcse;/* FCSE PID. */ uint32_t c13_context;/* Context ID. */ uint64_t tpidr_el0;/* User RW Thread register. */
target-arm/helper.c +8 -1
@@ -533,6 +533,12 @@ static void pmintenclr_write(CPUARMState *env, const ARMCPRegInfo *ri,static void vbar_write (CPUARMState *env,const ARMCPRegInfo *ri,uint64_t value) { +/* Note that even though the AArch64 view of this register has bits +* [10:0] all RES0 we can only mask the bottom 5, to comply with the +* architectural requirements for bits which are RES0 only in some +* contexts. (ARMv8 would permit us to do no masking at all, but ARMv7 +* requires the bottom five bits to be RAZ/WI because they're UNK/SBZP.) +*/ env->cp15.c12_vbar = value & ~0x1Ful ; }
@@ -622,7 +628,8 @@ static const ARMCPRegInfo v7_cp_reginfo[] = { .access = PL1_RW, .type = ARM_CP_NO_MIGRATE, .fieldoffset = offsetof(CPUARMState, cp15.c9_pminten), .resetvalue = 0, .writefn = pmintenclr_write, }, - { .name = "VBAR", .cp = 15, .crn = 12, .crm = 0, .opc1 = 0, .opc2 = 0, + { .name = "VBAR", .state = ARM_CP_STATE_BOTH, + .opc0 = 3, .crn = 12, .crm = 0, .opc1 = 0, .opc2 = 0, .access = PL1_RW, .writefn = vbar_write, .fieldoffset = offsetof(CPUARMState, cp15.c12_vbar), .resetvalue = 0 },
Signature · 1 line
1.9.0
[Qemu-devel] [PULL 31/45] target-arm: Get MMU index information correct for A64 code
In reply to Peter MaydellEmit the correct MMU index information for loads and stores from A64 code, rather than hardwiring it to "always kernel mode", by storing the exception level in the TB flags, and make cpu_mmu_index() return the right answer when the CPU is in AArch64 mode.
--- target-arm/cpu.h | 11 ++++++++--- target-arm/translate-a64.c | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-)
target-arm/cpu.h +8 -3
@@ -1057,7 +1057,7 @@ static inline CPUARMState *cpu_init(const char *cpu_model)#define MMU_USER_IDX 1static inline int cpu_mmu_index (CPUARMState *env) { -return (env->uncached_cpsr &CPSR_M ) ==ARM_CPU_MODE_USR ?1 :0 ; +return arm_current_pl (env) ?0 :1 ; }#include "exec/cpu-all.h"
@@ -1084,7 +1084,9 @@ static inline int cpu_mmu_index (CPUARMState *env)#define ARM_TBFLAG_BSWAP_CODE_SHIFT 16#define ARM_TBFLAG_BSWAP_CODE_MASK (1 << ARM_TBFLAG_BSWAP_CODE_SHIFT) -/* Bit usage when in AArch64 state: currently no bits defined */ +/* Bit usage when in AArch64 state */ +#define ARM_TBFLAG_AA64_EL_SHIFT 0 +#define ARM_TBFLAG_AA64_EL_MASK (0x3 << ARM_TBFLAG_AA64_EL_SHIFT)/* some convenience accessor macros */ #define ARM_TBFLAG_AARCH64_STATE (F ) \
@@ -1103,13 +1105,16 @@ static inline int cpu_mmu_index (CPUARMState *env) (((F) & ARM_TBFLAG_CONDEXEC_MASK) >> ARM_TBFLAG_CONDEXEC_SHIFT)#define ARM_TBFLAG_BSWAP_CODE (F ) \ (((F) & ARM_TBFLAG_BSWAP_CODE_MASK) >> ARM_TBFLAG_BSWAP_CODE_SHIFT) +#define ARM_TBFLAG_AA64_EL (F ) \ + (((F) & ARM_TBFLAG_AA64_EL_MASK) >> ARM_TBFLAG_AA64_EL_SHIFT)static inline void cpu_get_tb_cpu_state (CPUARMState *env,target_ulong *pc,target_ulong *cs_base,int *flags) {if (is_a64 (env)) { *pc = env->pc; - *flags =ARM_TBFLAG_AARCH64_STATE_MASK ; + *flags =ARM_TBFLAG_AARCH64_STATE_MASK + | (arm_current_pl (env) <<ARM_TBFLAG_AA64_EL_SHIFT ); }else {int privmode; *pc = env->regs[15 ];
target-arm/translate-a64.c +1 -1
@@ -9013,7 +9013,7 @@ void gen_intermediate_code_internal_a64(ARMCPU *cpu, dc->condexec_mask =0 ; dc->condexec_cond =0 ;#if !defined(CONFIG_USER_ONLY ) - dc->user =0 ; + dc->user = (ARM_TBFLAG_AA64_EL (tb->flags) ==0 );#endif dc->vfp_enabled =0 ; dc->vec_len =0 ;
Signature · 1 line
1.9.0
[Qemu-devel] [PULL 04/45] target-arm: Fix incorrect arithmetic constructing short-form PAR for ATS ops
In reply to Peter MaydellCorrect some obviously nonsensical bit manipulation spotted by Coverity when constructing the short-form PAR value for ATS operations.
Message-id: [email protected]
--- target-arm/helper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
target-arm/helper.c +2 -2
@@ -1031,8 +1031,8 @@ static void ats_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) env->cp15.c7_par = phys_addr &0xfffff000 ; } }else { - env->cp15.c7_par = ((ret & (10 <<1 )) >>5 ) | - ((ret & (12 <<1 )) >>6 ) | + env->cp15.c7_par = ((ret & (1 <<10 )) >>5 ) | + ((ret & (1 <<12 )) >>6 ) | ((ret &0xf ) <<1 ) |1 ; } env->cp15.c7_par_hi =0 ;
Signature · 1 line
1.9.0
[Qemu-devel] [PULL 27/45] target-arm: Implement AArch64 generic timers
In reply to Peter MaydellImplement the AArch64 view of the generic timer system registers.
--- target-arm/cpu.h | 6 ++-- target-arm/helper.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 75 insertions(+), 14 deletions(-)
target-arm/cpu.h +3 -3
@@ -104,7 +104,7 @@ struct arm_boot_info;/* CPU state for each instance of a generic timer (in cp15 c14) */ typedef struct ARMGenericTimer {uint64_t cval;/* Timer CompareValue register */ -uint32_t ctl;/* Timer Control register */ +uint64_t ctl;/* Timer Control register */ }ARMGenericTimer ;#define GTIMER_PHYS 0
@@ -204,8 +204,8 @@ typedef struct CPUARMState {uint64_t tpidr_el0;/* User RW Thread register. */ uint64_t tpidrro_el0;/* User RO Thread register. */ uint64_t tpidr_el1;/* Privileged Thread register. */ -uint32_t c14_cntfrq;/* Counter Frequency register */ -uint32_t c14_cntkctl;/* Timer Control register */ +uint64_t c14_cntfrq;/* Counter Frequency register */ +uint64_t c14_cntkctl;/* Timer Control register */ ARMGenericTimer c14_timer[NUM_GTIMERS ];uint32_t c15_cpar;/* XScale Coprocessor Access Register */ uint32_t c15_ticonfig;/* TI925T configuration byte. */
target-arm/helper.c +72 -11
139 lines not on this page · raw message
Signature · 1 line
1.9.0
[Qemu-devel] [PULL 30/45] target-arm: Implement AArch64 OSLAR_EL1 sysreg as WI
In reply to Peter MaydellDefine a dummy version of the AArch64 OSLAR_EL1 system register which just ignores writes. Linux will always write to this (it is the OS lock used for debugging), but we don't support debug.
--- target-arm/helper.c | 4 ++++ 1 file changed, 4 insertions(+)
target-arm/helper.c +4 -0
@@ -1738,6 +1738,10 @@ static const ARMCPRegInfo v8_cp_reginfo[] = { { .name = "MDSCR_EL1", .state = ARM_CP_STATE_AA64, .opc0 = 2, .opc1 = 0, .crn = 0, .crm = 2, .opc2 = 2, .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, + /* We define a dummy WI OSLAR_EL1, because Linux writes to it. */ + { .name = "OSLAR_EL1", .state = ARM_CP_STATE_AA64, + .opc0 = 2, .opc1 = 0, .crn = 1, .crm = 0, .opc2 = 4, + .access = PL1_W, .type = ARM_CP_NOP }, REGINFO_SENTINEL };
Signature · 1 line
1.9.0
[Qemu-devel] [PULL 33/45] target-arm: Store AIF bits in env->pstate for AArch32
In reply to Peter MaydellTo avoid complication in code that otherwise would not need to care about whether EL1 is AArch32 or AArch64, we should store the interrupt mask bits (CPSR.AIF in AArch32 and PSTATE.DAIF in AArch64) in one place consistently regardless of EL1's mode. Since AArch64 has an extra enable bit (D for debug exceptions) which isn't visible in AArch32, this means we need to keep the enables in env->pstate. (This is also consistent with the general approach we're taking that we handle 32 bit CPUs as being like AArch64/ARMv8 CPUs but which only run in 32 bit mode.)
--- cpu-exec.c | 4 ++-- hw/arm/pxa2xx.c | 4 ++-- target-arm/cpu.c | 8 ++++---- target-arm/cpu.h | 12 +++++++++--- target-arm/helper.c | 29 +++++++++++++++++------------ 5 files changed, 34 insertions(+), 23 deletions(-)
cpu-exec.c +2 -2
@@ -477,7 +477,7 @@ int cpu_exec(CPUArchState *env) }#elif defined(TARGET_ARM)if (interrupt_request &CPU_INTERRUPT_FIQ - && !(env->uncached_cpsr &CPSR_F )) { + && !(env->daif &PSTATE_F )) { env->exception_index =EXCP_FIQ ; cc->do_interrupt (cpu); next_tb =0 ;
@@ -493,7 +493,7 @@ int cpu_exec(CPUArchState *env)pc contains a magic address. */ if (interrupt_request &CPU_INTERRUPT_HARD && ((IS_M (env) && env->regs[15 ] <0xfffffff0 ) - || !(env->uncached_cpsr &CPSR_I ))) { + || !(env->daif &PSTATE_I ))) { env->exception_index =EXCP_IRQ ; cc->do_interrupt (cpu); next_tb =0 ;
hw/arm/pxa2xx.c +2 -2
@@ -272,8 +272,8 @@ static void pxa2xx_pwrmode_write(CPUARMState *env, const ARMCPRegInfo *ri, goto message;case 3 : - s->cpu->env.uncached_cpsr = -ARM_CPU_MODE_SVC |CPSR_A |CPSR_F |CPSR_I ; + s->cpu->env.uncached_cpsr =ARM_CPU_MODE_SVC ; + s->cpu->env.daif =PSTATE_A |PSTATE_F |PSTATE_I ; s->cpu->env.cp15.c1_sys =0 ; s->cpu->env.cp15.c1_coproc =0 ; s->cpu->env.cp15.ttbr0_el1 =0 ;
target-arm/cpu.c +4 -4
@@ -94,8 +94,7 @@ static void arm_cpu_reset(CPUState *s)/* Userspace expects access to CTL_EL0 and the cache ops */ env->cp15.c1_sys |=SCTLR_UCT |SCTLR_UCI ;#else - env->pstate =PSTATE_D |PSTATE_A |PSTATE_I |PSTATE_F - | PSTATE_MODE_EL1h; + env->pstate = PSTATE_MODE_EL1h;#endif }
@@ -110,13 +109,14 @@ static void arm_cpu_reset(CPUState *s) }#else /* SVC mode with interrupts disabled. */ - env->uncached_cpsr =ARM_CPU_MODE_SVC |CPSR_A |CPSR_F |CPSR_I ; + env->uncached_cpsr =ARM_CPU_MODE_SVC ; + env->daif =PSTATE_D |PSTATE_A |PSTATE_I |PSTATE_F ;/* On ARMv7-M the CPSR_I is the value of the PRIMASK register, and is clear at reset. Initial SP and PC are loaded from ROM. */ if (IS_M (env)) {uint32_t pc;uint8_t *rom; - env->uncached_cpsr &= ~CPSR_I ; + env->daif &= ~PSTATE_I ; rom =rom_ptr (0 );if (rom) {/* We should really use ldl_phys here, in case the guest
target-arm/cpu.h +9 -3
@@ -135,6 +135,7 @@ typedef struct CPUARMState {* NZCV are kept in the split out env->CF/VF/NF/ZF, (which have the same * semantics as for AArch32, as described in the comments on each field) * nRW (also known as M[4]) is kept, inverted, in env->aarch64 +* DAIF (exception masks) are kept in env->daif * all other bits are stored in their correct places in env->pstate */ uint32_t pstate;
@@ -164,6 +165,7 @@ typedef struct CPUARMState {uint32_t GE ;/* cpsr[19:16] */ uint32_t thumb;/* cpsr[5]. 0 = arm mode, 1 = thumb mode. */ uint32_t condexec_bits;/* IT bits. cpsr[15:10,26:25]. */ +uint32_t daif;/* exception masks, in the bits they are in in PSTATE */ /* System control coprocessor (cp15) */ struct {
@@ -406,9 +408,11 @@ int cpu_arm_handle_mmu_fault (CPUARMState *env, target_ulong address, int rw,#define CPSR_Z (1U << 30)#define CPSR_N (1U << 31)#define CPSR_NZCV (CPSR_N | CPSR_Z | CPSR_C | CPSR_V) +#define CPSR_AIF (CPSR_A | CPSR_I | CPSR_F)#define CPSR_IT (CPSR_IT_0_1 | CPSR_IT_2_7) -#define CACHED_CPSR_BITS (CPSR_T | CPSR_GE | CPSR_IT | CPSR_Q | CPSR_NZCV) +#define CACHED_CPSR_BITS (CPSR_T | CPSR_AIF | CPSR_GE | CPSR_IT | CPSR_Q \ + | CPSR_NZCV)/* Bits writable in user mode. */ #define CPSR_USER (CPSR_NZCV | CPSR_Q | CPSR_GE)/* Execution state bits. MRS read as zero, MSR writes ignored. */
@@ -431,7 +435,8 @@ int cpu_arm_handle_mmu_fault (CPUARMState *env, target_ulong address, int rw,#define PSTATE_Z (1U << 30)#define PSTATE_N (1U << 31)#define PSTATE_NZCV (PSTATE_N | PSTATE_Z | PSTATE_C | PSTATE_V) -#define CACHED_PSTATE_BITS (PSTATE_NZCV) +#define PSTATE_DAIF (PSTATE_D | PSTATE_A | PSTATE_I | PSTATE_F) +#define CACHED_PSTATE_BITS (PSTATE_NZCV | PSTATE_DAIF)/* Mode values for AArch64 */ #define PSTATE_MODE_EL3h 13#define PSTATE_MODE_EL3t 12
@@ -452,7 +457,7 @@ static inline uint32_t pstate_read(CPUARMState *env)ZF = (env->ZF ==0 );return (env->NF &0x80000000 ) | (ZF <<30 ) | (env->CF <<29 ) | ((env->VF &0x80000000 ) >>3 ) - | env->pstate; + | env->pstate | env->daif; }static inline void pstate_write (CPUARMState *env,uint32_t val)
@@ -461,6 +466,7 @@ static inline void pstate_write(CPUARMState *env, uint32_t val) env->NF = val; env->CF = (val >>29 ) &1 ; env->VF = (val <<3 ) &0x80000000 ; + env->daif = val &PSTATE_DAIF ; env->pstate = val & ~CACHED_PSTATE_BITS ; }
target-arm/helper.c +17 -12
@@ -2475,7 +2475,7 @@ uint32_t cpsr_read(CPUARMState *env) (env->CF <<29 ) | ((env->VF &0x80000000 ) >>3 ) | (env->QF <<27 ) | (env->thumb <<5 ) | ((env->condexec_bits &3 ) <<25 ) | ((env->condexec_bits &0xfc ) <<8 ) - | (env->GE <<16 ); + | (env->GE <<16 ) | env->daif; }void cpsr_write (CPUARMState *env,uint32_t val,uint32_t mask)
@@ -2502,6 +2502,9 @@ void cpsr_write(CPUARMState *env, uint32_t val, uint32_t mask) env->GE = (val >>16 ) &0xf ; } + env->daif &= ~(CPSR_AIF & mask); + env->daif |= val &CPSR_AIF & mask; +if ((env->uncached_cpsr ^ val) & mask &CPSR_M ) {if (bad_mode_switch (env, val &CPSR_M )) {/* Attempt to switch to an invalid mode: this is UNPREDICTABLE.
@@ -2963,7 +2966,7 @@ void arm_cpu_do_interrupt(CPUState *cs) env->condexec_bits =0 ;/* Switch to the new mode, and to the correct instruction set. */ env->uncached_cpsr = (env->uncached_cpsr & ~CPSR_M ) | new_mode; - env->uncached_cpsr |= mask; + env->daif |= mask;/* this is a lie, as the was no c1_sys on V4T/V5, but who cares * and we should just guard the thumb mode on V4 */ if (arm_feature (env,ARM_FEATURE_V4T )) {
@@ -3636,12 +3639,12 @@ uint32_t HELPER(v7m_mrs)(CPUARMState *env, uint32_t reg)case 9 :/* PSP */ return env->v7m.current_sp ? env->regs[13 ] : env->v7m.other_sp;case 16 :/* PRIMASK */ -return (env->uncached_cpsr &CPSR_I ) !=0 ; +return (env->daif &PSTATE_I ) !=0 ;case 17 :/* BASEPRI */ case 18 :/* BASEPRI_MAX */ return env->v7m.basepri;case 19 :/* FAULTMASK */ -return (env->uncached_cpsr &CPSR_F ) !=0 ; +return (env->daif &PSTATE_F ) !=0 ;case 20 :/* CONTROL */ return env->v7m.control;default :
@@ -3688,10 +3691,11 @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t reg, uint32_t val) env->v7m.other_sp = val;break ;case 16 :/* PRIMASK */ -if (val &1 ) - env->uncached_cpsr |=CPSR_I ; -else - env->uncached_cpsr &= ~CPSR_I ; +if (val &1 ) { + env->daif |=PSTATE_I ; + }else { + env->daif &= ~PSTATE_I ; + }break ;case 17 :/* BASEPRI */ env->v7m.basepri = val &0xff ;
@@ -3702,10 +3706,11 @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t reg, uint32_t val) env->v7m.basepri = val;break ;case 19 :/* FAULTMASK */ -if (val &1 ) - env->uncached_cpsr |=CPSR_F ; -else - env->uncached_cpsr &= ~CPSR_F ; +if (val &1 ) { + env->daif |=PSTATE_F ; + }else { + env->daif &= ~PSTATE_F ; + }break ;case 20 :/* CONTROL */ env->v7m.control = val &3 ;
Signature · 1 line
1.9.0
[Qemu-devel] [PULL 29/45] target-arm: Implement AArch64 dummy breakpoint and watchpoint registers
In reply to Peter MaydellIn AArch64 the breakpoint and watchpoint registers are mandatory, so the kernel always accesses them on bootup. Implement dummy versions, which read as written but have no actual effect.
--- target-arm/cpu.h | 4 ++++ target-arm/helper.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+)
target-arm/cpu.h +4 -0
@@ -216,6 +216,10 @@ typedef struct CPUARMState {uint32_t c15_diagnostic;/* diagnostic register */ uint32_t c15_power_diagnostic;uint32_t c15_power_control;/* power control */ +uint64_t dbgbvr[16 ];/* breakpoint value registers */ +uint64_t dbgbcr[16 ];/* breakpoint control registers */ +uint64_t dbgwvr[16 ];/* watchpoint value registers */ +uint64_t dbgwcr[16 ];/* watchpoint control registers */ } cp15;struct {
target-arm/helper.c +32 -0
@@ -1761,6 +1761,37 @@ static CPAccessResult ctr_el0_access(CPUARMState *env, const ARMCPRegInfo *ri)return CP_ACCESS_OK ; } +static void define_aarch64_debug_regs (ARMCPU *cpu) +{ +/* Define breakpoint and watchpoint registers. These do nothing +* but read as written, for now. +*/ +int i; + +for (i =0 ; i <16 ; i++) { +ARMCPRegInfo dbgregs[] = { + { .name ="DBGBVR" , .state =ARM_CP_STATE_AA64 , + .opc0 =2 , .opc1 =0 , .crn =0 , .crm = i, .opc2 =4 , + .access =PL1_RW , + .fieldoffset = offsetof(CPUARMState, cp15.dbgbvr[i]) }, + { .name ="DBGBCR" , .state =ARM_CP_STATE_AA64 , + .opc0 =2 , .opc1 =0 , .crn =0 , .crm = i, .opc2 =5 , + .access =PL1_RW , + .fieldoffset = offsetof(CPUARMState, cp15.dbgbcr[i]) }, + { .name ="DBGWVR" , .state =ARM_CP_STATE_AA64 , + .opc0 =2 , .opc1 =0 , .crn =0 , .crm = i, .opc2 =6 , + .access =PL1_RW , + .fieldoffset = offsetof(CPUARMState, cp15.dbgwvr[i]) }, + { .name ="DBGWCR" , .state =ARM_CP_STATE_AA64 , + .opc0 =2 , .opc1 =0 , .crn =0 , .crm = i, .opc2 =7 , + .access =PL1_RW , + .fieldoffset = offsetof(CPUARMState, cp15.dbgwcr[i]) }, +REGINFO_SENTINEL + }; +define_arm_cp_regs (cpu, dbgregs); + } +} +void register_cp_regs_for_features (ARMCPU *cpu) {/* Register all the coprocessor registers based on feature bits */
@@ -1902,6 +1933,7 @@ void register_cp_regs_for_features(ARMCPU *cpu) };define_arm_cp_regs (cpu, v8_idregs);define_arm_cp_regs (cpu, v8_cp_reginfo); +define_aarch64_debug_regs (cpu); }if (arm_feature (env,ARM_FEATURE_MPU )) {/* These are the MPU registers prior to PMSAv6. Any new
Signature · 1 line
1.9.0
[Qemu-devel] [PULL 34/45] target-arm: A64: Implement MSR (immediate) instructions
In reply to Peter MaydellImplement the MSR (immediate) instructions, which can update the PSTATE SP and DAIF fields.
--- target-arm/helper.h | 2 ++ target-arm/op_helper.c | 25 +++++++++++++++++++++++++ target-arm/translate-a64.c | 25 ++++++++++++++++++++++++- 3 files changed, 51 insertions(+), 1 deletion(-)
target-arm/helper.h +2 -0
@@ -63,6 +63,8 @@ DEF_HELPER_2(get_cp_reg, i32, env, ptr) DEF_HELPER_3(set_cp_reg64, void, env, ptr, i64) DEF_HELPER_2(get_cp_reg64, i64, env, ptr) +DEF_HELPER_3(msr_i_pstate, void, env, i32, i32) + DEF_HELPER_2(get_r13_banked, i32, env, i32)DEF_HELPER_3 (set_r13_banked, void, env, i32, i32)
target-arm/op_helper.c +25 -0
@@ -319,6 +319,31 @@ uint64_t HELPER(get_cp_reg64)(CPUARMState *env, void *rip)return ri->readfn (env, ri); } +void HELPER (msr_i_pstate )(CPUARMState *env,uint32_t op,uint32_t imm) +{ +/* MSR_i to update PSTATE. This is OK from EL0 only if UMA is set. +* Note that SPSel is never OK from EL0; we rely on handle_msr_i() +* to catch that case at translate time. +*/ +if (arm_current_pl (env) ==0 && !(env->cp15.c1_sys &SCTLR_UMA )) { +raise_exception (env,EXCP_UDEF ); + } + +switch (op) { +case 0x05 :/* SPSel */ + env->pstate =deposit32 (env->pstate,0 ,1 , imm); +break ; +case 0x1e :/* DAIFSet */ + env->daif |= (imm <<6 ) &PSTATE_DAIF ; +break ; +case 0x1f :/* DAIFClear */ + env->daif &= ~((imm <<6 ) &PSTATE_DAIF ); +break ; +default : +g_assert_not_reached (); + } +} +/* ??? Flag setting arithmetic is awkward because we need to do comparisons. The only way to do that in TCG is a conditional branch, which clobbers all our temporaries. For now implement these as helper functions. */
target-arm/translate-a64.c +24 -1
@@ -1128,7 +1128,30 @@ static void handle_sync(DisasContext *s, uint32_t insn,static void handle_msr_i (DisasContext *s,uint32_t insn,unsigned int op1,unsigned int op2,unsigned int crm) { -unsupported_encoding (s, insn); +int op = op1 <<3 | op2; +switch (op) { +case 0x05 :/* SPSel */ +if (s->current_pl ==0 ) { +unallocated_encoding (s); +return ; + } +/* fall through */ +case 0x1e :/* DAIFSet */ +case 0x1f :/* DAIFClear */ + { +TCGv_i32 tcg_imm =tcg_const_i32 (crm); +TCGv_i32 tcg_op =tcg_const_i32 (op); +gen_a64_set_pc_im (s->pc -4 ); +gen_helper_msr_i_pstate (cpu_env, tcg_op, tcg_imm); +tcg_temp_free_i32 (tcg_imm); +tcg_temp_free_i32 (tcg_op); + s->is_jmp =DISAS_UPDATE ; +break ; + } +default : +unallocated_encoding (s); +return ; + } }static void gen_get_nzcv (TCGv_i64 tcg_rt)
Signature · 1 line
1.9.0
[Qemu-devel] [PULL 05/45] hw/intc/exynos4210_combiner: Don't overrun output_irq array in init
In reply to Peter MaydellThe Exynos4210 combiner has IIC_NIRQ inputs and IIC_NGRP outputs; use the correct constant in the loop initializing our output sysbus IRQs so that we don't overrun the output_irq[] array.
Message-id: [email protected]
--- hw/intc/exynos4210_combiner.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/intc/exynos4210_combiner.c +1 -1
@@ -418,7 +418,7 @@ static int exynos4210_combiner_init(SysBusDevice *sbd)qdev_init_gpio_in (dev, exynos4210_combiner_handler,IIC_NIRQ );/* Connect SysBusDev irqs to device specific irqs */ -for (i =0 ; i <IIC_NIRQ ; i++) { +for (i =0 ; i <IIC_NGRP ; i++) {sysbus_init_irq (sbd, &s->output_irq[i]); }
Signature · 1 line
1.9.0
[Qemu-devel] [PULL 13/45] hw: arm_gic_kvm: Add KVM VGIC save/restore logic
In reply to Peter MaydellFrom: Christoffer Dall <[email protected]>
Save and restore the ARM KVM VGIC state from the kernel. We rely on QEMU to marshal the GICState data structure and therefore simply synchronize the kernel state with the QEMU emulated state in both directions.
We take some care on the restore path to check the VGIC has been configured with enough IRQs and CPU interfaces that we can properly restore the state, and for separate set/clear registers we first fully clear the registers and then set the required bits.
Message-id: [email protected]
--- hw/intc/arm_gic_kvm.c | 424 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 422 insertions(+), 2 deletions(-)
hw/intc/arm_gic_kvm.c +422 -2
@@ -3,6 +3,7 @@* * Copyright (c) 2012 Linaro Limited * Written by Peter Maydell +* Save/Restore logic added by Christoffer Dall. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by
@@ -23,6 +24,20 @@#include "kvm_arm.h" #include "gic_internal.h" +//#define DEBUG_GIC_KVM + +#ifdef DEBUG_GIC_KVM +static const int debug_gic_kvm =1 ; +#else +static const int debug_gic_kvm =0 ; +#endif + +#define DPRINTF (fmt, ...) do { \ + if (debug_gic_kvm) { \ + printf("arm_gic: " fmt , ## __VA_ARGS__); \ + } \ + } while (0) +#define TYPE_KVM_ARM_GIC "kvm-arm-gic"#define KVM_ARM_GIC (obj) \ OBJECT_CHECK(GICState, (obj), TYPE_KVM_ARM_GIC)
@@ -72,14 +87,419 @@ static void kvm_arm_gic_set_irq(void *opaque, int irq, int level)kvm_set_irq (kvm_state, kvm_irq, !!level); } +static bool kvm_arm_gic_can_save_restore (GICState *s) +{ +return s->dev_fd >=0 ; +} + +static void kvm_gic_access (GICState *s,int group,int offset, +int cpu,uint32_t *val,bool write) +{ +struct kvm_device_attr attr; +int type; +int err; + + cpu = cpu &0xff ; + + attr.flags =0 ; + attr.group = group; + attr.attr = (((uint64_t )cpu <<KVM_DEV_ARM_VGIC_CPUID_SHIFT ) & +KVM_DEV_ARM_VGIC_CPUID_MASK ) | + (((uint64_t )offset <<KVM_DEV_ARM_VGIC_OFFSET_SHIFT ) & +KVM_DEV_ARM_VGIC_OFFSET_MASK ); + attr.addr = (uintptr_t )val; + +if (write) { + type =KVM_SET_DEVICE_ATTR ; + }else { + type =KVM_GET_DEVICE_ATTR ; + } + + err =kvm_device_ioctl (s->dev_fd, type, &attr); +if (err <0 ) { +fprintf (stderr,"KVM_{SET/GET}_DEVICE_ATTR failed: %s\n" , +strerror (-err)); +abort (); + } +} + +static void kvm_gicd_access (GICState *s,int offset,int cpu, +uint32_t *val,bool write) +{ +kvm_gic_access (s,KVM_DEV_ARM_VGIC_GRP_DIST_REGS , + offset, cpu, val, write); +} + +static void kvm_gicc_access (GICState *s,int offset,int cpu, +uint32_t *val,bool write) +{ +kvm_gic_access (s,KVM_DEV_ARM_VGIC_GRP_CPU_REGS , + offset, cpu, val, write); +} + +#define for_each_irq_reg (_ctr, _max_irq, _field_width) \ + for (_ctr = 0; _ctr < ((_max_irq) / (32 / (_field_width))); _ctr++) + +/* +* Translate from the in-kernel field for an IRQ value to/from the qemu +* representation. +*/ +typedef void (*vgic_translate_fn )(GICState *s,int irq,int cpu, +uint32_t *field,bool to_kernel); + +/* synthetic translate function used for clear/set registers to completely +* clear a setting using a clear-register before setting the remaing bits +* using a set-register */ +static void translate_clear (GICState *s,int irq,int cpu, +uint32_t *field,bool to_kernel) +{ +if (to_kernel) { + *field = ~0 ; + }else { +/* does not make sense: qemu model doesn't use set/clear regs */ +abort (); + } +} + +static void translate_enabled (GICState *s,int irq,int cpu, +uint32_t *field,bool to_kernel) +{ +int cm = (irq <GIC_INTERNAL ) ? (1 << cpu) :ALL_CPU_MASK ; + +if (to_kernel) { + *field =GIC_TEST_ENABLED (irq, cm); + }else { +if (*field &1 ) { +GIC_SET_ENABLED (irq, cm); + } + } +} + +static void translate_pending (GICState *s,int irq,int cpu, +uint32_t *field,bool to_kernel) +{ +int cm = (irq <GIC_INTERNAL ) ? (1 << cpu) :ALL_CPU_MASK ; + +if (to_kernel) { + *field =gic_test_pending (s, irq, cm); + }else { +if (*field &1 ) { +GIC_SET_PENDING (irq, cm); +/* TODO: Capture is level-line is held high in the kernel */ + } + } +} + +static void translate_active (GICState *s,int irq,int cpu, +uint32_t *field,bool to_kernel) +{ +int cm = (irq <GIC_INTERNAL ) ? (1 << cpu) :ALL_CPU_MASK ; + +if (to_kernel) { + *field =GIC_TEST_ACTIVE (irq, cm); + }else { +if (*field &1 ) { +GIC_SET_ACTIVE (irq, cm); + } + } +} + +static void translate_trigger (GICState *s,int irq,int cpu, +uint32_t *field,bool to_kernel) +{ +if (to_kernel) { + *field = (GIC_TEST_EDGE_TRIGGER (irq)) ?0x2 :0x0 ; + }else { +if (*field &0x2 ) { +GIC_SET_EDGE_TRIGGER (irq); + } + } +} + +static void translate_priority (GICState *s,int irq,int cpu, +uint32_t *field,bool to_kernel) +{ +if (to_kernel) { + *field =GIC_GET_PRIORITY (irq, cpu) &0xff ; + }else { +gic_set_priority (s, cpu, irq, *field &0xff ); + } +} + +static void translate_targets (GICState *s,int irq,int cpu, +uint32_t *field,bool to_kernel) +{ +if (to_kernel) { + *field = s->irq_target[irq] &0xff ; + }else { + s->irq_target[irq] = *field &0xff ; + } +} + +static void translate_sgisource (GICState *s,int irq,int cpu, +uint32_t *field,bool to_kernel) +{ +if (to_kernel) { + *field = s->sgi_pending[irq][cpu] &0xff ; + }else { + s->sgi_pending[irq][cpu] = *field &0xff ; + } +} + +/* Read a register group from the kernel VGIC */ +static void kvm_dist_get (GICState *s,uint32_t offset,int width, +int maxirq,vgic_translate_fn translate_fn) +{ +uint32_t reg; +int i; +int j; +int irq; +int cpu; +int regsz =32 / width;/* irqs per kernel register */ +uint32_t field; + +for_each_irq_reg (i, maxirq, width) { + irq = i * regsz; + cpu =0 ; +while ((cpu < s->num_cpu && irq <GIC_INTERNAL ) || cpu ==0 ) { +kvm_gicd_access (s, offset, cpu, ®, false); +for (j =0 ; j < regsz; j++) { + field =extract32 (reg, j * width, width); +translate_fn (s, irq + j, cpu, &field, false); + } + + cpu++; + } + offset +=4 ; + } +} + +/* Write a register group to the kernel VGIC */ +static void kvm_dist_put (GICState *s,uint32_t offset,int width, +int maxirq,vgic_translate_fn translate_fn) +{ +uint32_t reg; +int i; +int j; +int irq; +int cpu; +int regsz =32 / width;/* irqs per kernel register */ +uint32_t field; + +for_each_irq_reg (i, maxirq, width) { + irq = i * regsz; + cpu =0 ; +while ((cpu < s->num_cpu && irq <GIC_INTERNAL ) || cpu ==0 ) { + reg =0 ; +for (j =0 ; j < regsz; j++) { +translate_fn (s, irq + j, cpu, &field, true); + reg =deposit32 (reg, j * width, width, field); + } +kvm_gicd_access (s, offset, cpu, ®, true); + + cpu++; + } + offset +=4 ; + } +} +static void kvm_arm_gic_put (GICState *s) { -/* TODO: there isn't currently a kernel interface to set the GIC state */ +uint32_t reg; +int i; +int cpu; +int num_cpu; +int num_irq; + +if (!kvm_arm_gic_can_save_restore (s)) { +DPRINTF ("Cannot put kernel gic state, no kernel interface" ); +return ; + } + +/* Note: We do the restore in a slightly different order than the save +* (where the order doesn't matter and is simply ordered according to the +* register offset values */ + +/***************************************************************** +* Distributor State +*/ + +/* s->enabled -> GICD_CTLR */ + reg = s->enabled; +kvm_gicd_access (s,0x0 ,0 , ®, true); + +/* Sanity checking on GICD_TYPER and s->num_irq, s->num_cpu */ +kvm_gicd_access (s,0x4 ,0 , ®, false); + num_irq = ((reg &0x1f ) +1 ) *32 ; + num_cpu = ((reg &0xe0 ) >>5 ) +1 ; + +if (num_irq < s->num_irq) { +fprintf (stderr,"Restoring %u IRQs, but kernel supports max %d\n" , + s->num_irq, num_irq); +abort (); + }else if (num_cpu != s->num_cpu) { +fprintf (stderr,"Restoring %u CPU interfaces, kernel only has %d\n" , + s->num_cpu, num_cpu); +/* Did we not create the VCPUs in the kernel yet? */ +abort (); + } + +/* TODO: Consider checking compatibility with the IIDR ? */ + +/* irq_state[n].enabled -> GICD_ISENABLERn */ +kvm_dist_put (s,0x180 ,1 , s->num_irq, translate_clear); +kvm_dist_put (s,0x100 ,1 , s->num_irq, translate_enabled); + +/* s->irq_target[irq] -> GICD_ITARGETSRn +* (restore targets before pending to ensure the pending state is set on +* the appropriate CPU interfaces in the kernel) */ +kvm_dist_put (s,0x800 ,8 , s->num_irq, translate_targets); + +/* irq_state[n].pending + irq_state[n].level -> GICD_ISPENDRn */ +kvm_dist_put (s,0x280 ,1 , s->num_irq, translate_clear); +kvm_dist_put (s,0x200 ,1 , s->num_irq, translate_pending); + +/* irq_state[n].active -> GICD_ISACTIVERn */ +kvm_dist_put (s,0x380 ,1 , s->num_irq, translate_clear); +kvm_dist_put (s,0x300 ,1 , s->num_irq, translate_active); + +/* irq_state[n].trigger -> GICD_ICFRn */ +kvm_dist_put (s,0xc00 ,2 , s->num_irq, translate_trigger); + +/* s->priorityX[irq] -> ICD_IPRIORITYRn */ +kvm_dist_put (s,0x400 ,8 , s->num_irq, translate_priority); + +/* s->sgi_pending -> ICD_CPENDSGIRn */ +kvm_dist_put (s,0xf10 ,8 ,GIC_NR_SGIS , translate_clear); +kvm_dist_put (s,0xf20 ,8 ,GIC_NR_SGIS , translate_sgisource); + + +/***************************************************************** +* CPU Interface(s) State +*/ + +for (cpu =0 ; cpu < s->num_cpu; cpu++) { +/* s->cpu_enabled[cpu] -> GICC_CTLR */ + reg = s->cpu_enabled[cpu]; +kvm_gicc_access (s,0x00 , cpu, ®, true); + +/* s->priority_mask[cpu] -> GICC_PMR */ + reg = (s->priority_mask[cpu] &0xff ); +kvm_gicc_access (s,0x04 , cpu, ®, true); + +/* s->bpr[cpu] -> GICC_BPR */ + reg = (s->bpr[cpu] &0x7 ); +kvm_gicc_access (s,0x08 , cpu, ®, true); + +/* s->abpr[cpu] -> GICC_ABPR */ + reg = (s->abpr[cpu] &0x7 ); +kvm_gicc_access (s,0x1c , cpu, ®, true); + +/* s->apr[n][cpu] -> GICC_APRn */ +for (i =0 ; i <4 ; i++) { + reg = s->apr[i][cpu]; +kvm_gicc_access (s,0xd0 + i *4 , cpu, ®, true); + } + } }static void kvm_arm_gic_get (GICState *s) { -/* TODO: there isn't currently a kernel interface to get the GIC state */ +uint32_t reg; +int i; +int cpu; + +if (!kvm_arm_gic_can_save_restore (s)) { +DPRINTF ("Cannot get kernel gic state, no kernel interface" ); +return ; + } + +/***************************************************************** +* Distributor State +*/ + +/* GICD_CTLR -> s->enabled */ +kvm_gicd_access (s,0x0 ,0 , ®, false); + s->enabled = reg &1 ; + +/* Sanity checking on GICD_TYPER -> s->num_irq, s->num_cpu */ +kvm_gicd_access (s,0x4 ,0 , ®, false); + s->num_irq = ((reg &0x1f ) +1 ) *32 ; + s->num_cpu = ((reg &0xe0 ) >>5 ) +1 ; + +if (s->num_irq >GIC_MAXIRQ ) { +fprintf (stderr,"Too many IRQs reported from the kernel: %d\n" , + s->num_irq); +abort (); + } + +/* GICD_IIDR -> ? */ +kvm_gicd_access (s,0x8 ,0 , ®, false); + +/* Verify no GROUP 1 interrupts configured in the kernel */ +for_each_irq_reg (i, s->num_irq,1 ) { +kvm_gicd_access (s,0x80 + (i *4 ),0 , ®, false); +if (reg !=0 ) { +fprintf (stderr,"Unsupported GICD_IGROUPRn value: %08x\n" , + reg); +abort (); + } + } + +/* Clear all the IRQ settings */ +for (i =0 ; i < s->num_irq; i++) { +memset (&s->irq_state[i],0 ,sizeof (s->irq_state[0 ])); + } + +/* GICD_ISENABLERn -> irq_state[n].enabled */ +kvm_dist_get (s,0x100 ,1 , s->num_irq, translate_enabled); + +/* GICD_ISPENDRn -> irq_state[n].pending + irq_state[n].level */ +kvm_dist_get (s,0x200 ,1 , s->num_irq, translate_pending); + +/* GICD_ISACTIVERn -> irq_state[n].active */ +kvm_dist_get (s,0x300 ,1 , s->num_irq, translate_active); + +/* GICD_ICFRn -> irq_state[n].trigger */ +kvm_dist_get (s,0xc00 ,2 , s->num_irq, translate_trigger); + +/* GICD_IPRIORITYRn -> s->priorityX[irq] */ +kvm_dist_get (s,0x400 ,8 , s->num_irq, translate_priority); + +/* GICD_ITARGETSRn -> s->irq_target[irq] */ +kvm_dist_get (s,0x800 ,8 , s->num_irq, translate_targets); + +/* GICD_CPENDSGIRn -> s->sgi_pending */ +kvm_dist_get (s,0xf10 ,8 ,GIC_NR_SGIS , translate_sgisource); + + +/***************************************************************** +* CPU Interface(s) State +*/ + +for (cpu =0 ; cpu < s->num_cpu; cpu++) { +/* GICC_CTLR -> s->cpu_enabled[cpu] */ +kvm_gicc_access (s,0x00 , cpu, ®, false); + s->cpu_enabled[cpu] = (reg &1 ); + +/* GICC_PMR -> s->priority_mask[cpu] */ +kvm_gicc_access (s,0x04 , cpu, ®, false); + s->priority_mask[cpu] = (reg &0xff ); + +/* GICC_BPR -> s->bpr[cpu] */ +kvm_gicc_access (s,0x08 , cpu, ®, false); + s->bpr[cpu] = (reg &0x7 ); + +/* GICC_ABPR -> s->abpr[cpu] */ +kvm_gicc_access (s,0x1c , cpu, ®, false); + s->abpr[cpu] = (reg &0x7 ); + +/* GICC_APRn -> s->apr[n][cpu] */ +for (i =0 ; i <4 ; i++) { +kvm_gicc_access (s,0xd0 + i *4 , cpu, ®, false); + s->apr[i][cpu] = reg; + } + } }static void kvm_arm_gic_reset (DeviceState *dev)
Signature · 1 line
1.9.0
[Qemu-devel] [PULL 14/45] target-arm: Fix raw read and write functions on AArch64 registers
In reply to Peter MaydellThe raw read and write functions were using the ARM_CP_64BIT flag in ri->type to determine whether to treat the register's state field as uint32_t or uint64_t; however AArch64 register info structs don't use that flag. Abstract out the "how big is the field?" test into a function and fix it to work for AArch64 registers. For this to work we must ensure that the reginfo structs put into the hashtable have the correct state field for their use, not the placeholder STATE_BOTH.
--- target-arm/cpu.c | 2 +- target-arm/cpu.h | 8 ++++++++ target-arm/helper.c | 8 ++++++-- 3 files changed, 15 insertions(+), 3 deletions(-)
target-arm/cpu.c +1 -1
@@ -60,7 +60,7 @@ static void cp_reg_reset(gpointer key, gpointer value, gpointer opaque)return ; } -if (ri->type &ARM_CP_64BIT ) { +if (cpreg_field_is_64bit (ri)) {CPREG_FIELD64 (&cpu->env, ri) = ri->resetvalue; }else {CPREG_FIELD32 (&cpu->env, ri) = ri->resetvalue;
target-arm/cpu.h +8 -0
@@ -959,6 +959,14 @@ uint64_t arm_cp_read_zero(CPUARMState *env, const ARMCPRegInfo *ri);*/ void arm_cp_reset_ignore (CPUARMState *env,const ARMCPRegInfo *opaque); +/* Return true if this reginfo struct's field in the cpu state struct +* is 64 bits wide. +*/ +static inline bool cpreg_field_is_64bit (const ARMCPRegInfo *ri) +{ +return (ri->state ==ARM_CP_STATE_AA64 ) || (ri->type &ARM_CP_64BIT ); +} +static inline bool cp_access_ok (int current_pl,const ARMCPRegInfo *ri,int isread) {
target-arm/helper.c +6 -2
@@ -109,7 +109,7 @@ static int aarch64_fpu_gdb_set_reg(CPUARMState *env, uint8_t *buf, int reg)static uint64_t raw_read (CPUARMState *env,const ARMCPRegInfo *ri) { -if (ri->type &ARM_CP_64BIT ) { +if (cpreg_field_is_64bit (ri)) {return CPREG_FIELD64 (env, ri); }else {return CPREG_FIELD32 (env, ri);
@@ -119,7 +119,7 @@ static uint64_t raw_read(CPUARMState *env, const ARMCPRegInfo *ri)static void raw_write (CPUARMState *env,const ARMCPRegInfo *ri,uint64_t value) { -if (ri->type &ARM_CP_64BIT ) { +if (cpreg_field_is_64bit (ri)) {CPREG_FIELD64 (env, ri) = value; }else {CPREG_FIELD32 (env, ri) = value;
@@ -1962,6 +1962,10 @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r,if (opaque) { r2->opaque = opaque; } +/* reginfo passed to helpers is correct for the actual access, +* and is never ARM_CP_STATE_BOTH: +*/ + r2->state = state;/* Make sure reginfo passed to helpers for wildcarded regs * has the correct crm/opc1/opc2 for this reg, not CP_ANY: */
Signature · 1 line
1.9.0
[Qemu-devel] [PULL 15/45] target-arm: A64: Make cache ID registers visible to AArch64
In reply to Peter MaydellMake the cache ID system registers (CLIDR, CSSELR, CCSIDR, CTR) visible to AArch64. These are mostly simple 64-bit extensions of the existing 32 bit system registers and so can share reginfo definitions. CTR needs to have a split definition, but we can clean up the temporary user-mode implementation in favour of using the CPU-specified reset value, and implement the system-mode-required semantics of restricting its EL0 accessibility if SCTLR.UCT is not set.
--- target-arm/cpu.c | 2 ++ target-arm/cpu.h | 2 +- target-arm/cpu64.c | 1 + target-arm/helper.c | 31 +++++++++++++++++++++---------- 4 files changed, 25 insertions(+), 11 deletions(-)
target-arm/cpu.c +2 -0
@@ -91,6 +91,8 @@ static void arm_cpu_reset(CPUState *s) env->aarch64 =1 ;#if defined(CONFIG_USER_ONLY ) env->pstate = PSTATE_MODE_EL0t; +/* Userspace expects access to CTL_EL0 */ + env->cp15.c1_sys |=SCTLR_UCT ;#else env->pstate =PSTATE_D |PSTATE_A |PSTATE_I |PSTATE_F | PSTATE_MODE_EL1h;
target-arm/cpu.h +1 -1
@@ -166,7 +166,7 @@ typedef struct CPUARMState {/* System control coprocessor (cp15) */ struct {uint32_t c0_cpuid; -uint32_t c0_cssel;/* Cache size selection. */ +uint64_t c0_cssel;/* Cache size selection. */ uint32_t c1_sys;/* System control register. */ uint32_t c1_coproc;/* Coprocessor access register. */ uint32_t c1_xscaleauxcr;/* XScale auxiliary control register. */
target-arm/cpu64.c +1 -0
@@ -45,6 +45,7 @@ static void aarch64_any_initfn(Object *obj)set_feature (&cpu->env,ARM_FEATURE_ARM_DIV );set_feature (&cpu->env,ARM_FEATURE_V7MP );set_feature (&cpu->env,ARM_FEATURE_AARCH64 ); + cpu->ctr = 0x80030003; /* 32 byte I and D cacheline size, VIPT icache */ }#endif
target-arm/helper.c +21 -10
@@ -629,9 +629,11 @@ static const ARMCPRegInfo v7_cp_reginfo[] = { { .name = "SCR", .cp = 15, .crn = 1, .crm = 1, .opc1 = 0, .opc2 = 0, .access = PL1_RW, .fieldoffset = offsetof(CPUARMState, cp15.c1_scr), .resetvalue = 0, }, - { .name = "CCSIDR", .cp = 15, .crn = 0, .crm = 0, .opc1 = 1, .opc2 = 0, + { .name = "CCSIDR", .state = ARM_CP_STATE_BOTH, + .opc0 = 3, .crn = 0, .crm = 0, .opc1 = 1, .opc2 = 0, .access = PL1_R, .readfn = ccsidr_read, .type = ARM_CP_NO_MIGRATE }, - { .name = "CSSELR", .cp = 15, .crn = 0, .crm = 0, .opc1 = 2, .opc2 = 0, + { .name = "CSSELR", .state = ARM_CP_STATE_BOTH, + .opc0 = 3, .crn = 0, .crm = 0, .opc1 = 2, .opc2 = 0, .access = PL1_RW, .fieldoffset = offsetof(CPUARMState, cp15.c0_cssel), .writefn = csselr_write, .resetvalue = 0 }, /* Auxiliary ID register: this actually has an IMPDEF value but for now
@@ -1524,13 +1526,6 @@ static const ARMCPRegInfo v8_cp_reginfo[] = { { .name = "FPSR", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 3, .opc2 = 1, .crn = 4, .crm = 4, .access = PL0_RW, .readfn = aa64_fpsr_read, .writefn = aa64_fpsr_write }, - /* This claims a 32 byte cacheline size for icache and dcache, VIPT icache. - * It will eventually need to have a CPU-specified reset value. - */ - { .name = "CTR_EL0", .state = ARM_CP_STATE_AA64, - .opc0 = 3, .opc1 = 3, .opc2 = 1, .crn = 0, .crm = 0, - .access = PL0_R, .type = ARM_CP_CONST, - .resetvalue = 0x80030003 },/* Prohibit use of DC ZVA. OPTME: implement DC ZVA and allow its use. * For system mode the DZP bit here will need to be computed, not constant. */
@@ -1550,6 +1545,17 @@ static void sctlr_write(CPUARMState *env, const ARMCPRegInfo *ri,tlb_flush (env,1 ); } +static CPAccessResult ctr_el0_access (CPUARMState *env,const ARMCPRegInfo *ri) +{ +/* Only accessible in EL0 if SCTLR.UCT is set (and only in AArch64, +* but the AArch32 CTR has its own reginfo struct) +*/ +if (arm_current_pl (env) ==0 && !(env->cp15.c1_sys &SCTLR_UCT )) { +return CP_ACCESS_TRAP ; + } +return CP_ACCESS_OK ; +} +void register_cp_regs_for_features (ARMCPU *cpu) {/* Register all the coprocessor registers based on feature bits */
@@ -1634,7 +1640,8 @@ void register_cp_regs_for_features(ARMCPU *cpu) .raw_writefn = raw_write, };ARMCPRegInfo clidr = { - .name ="CLIDR" , .cp =15 , .crn =0 , .crm =0 , .opc1 =1 , .opc2 =1 , + .name ="CLIDR" , .state =ARM_CP_STATE_BOTH , + .opc0 =3 , .crn =0 , .crm =0 , .opc1 =1 , .opc2 =1 , .access =PL1_R , .type =ARM_CP_CONST , .resetvalue = cpu->clidr };define_one_arm_cp_reg (cpu, &pmcr);
@@ -1713,6 +1720,10 @@ void register_cp_regs_for_features(ARMCPU *cpu) { .name = "CTR", .cp = 15, .crn = 0, .crm = 0, .opc1 = 0, .opc2 = 1, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = cpu->ctr }, + { .name = "CTR_EL0", .state = ARM_CP_STATE_AA64, + .opc0 = 3, .opc1 = 3, .opc2 = 1, .crn = 0, .crm = 0, + .access = PL0_R, .accessfn = ctr_el0_access, + .type = ARM_CP_CONST, .resetvalue = cpu->ctr }, { .name = "TCMTR", .cp = 15, .crn = 0, .crm = 0, .opc1 = 0, .opc2 = 2, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 },
Signature · 1 line
1.9.0
[Qemu-devel] [PULL 20/45] target-arm: Implement AArch64 dummy MDSCR_EL1
In reply to Peter MaydellWe don't support letting the guest do debug, but Linux prods the monitor debug system control register anyway, so implement a dummy RAZ/WI version.
--- target-arm/helper.c | 6 ++++++ 1 file changed, 6 insertions(+)
target-arm/helper.c +6 -0
@@ -1656,6 +1656,12 @@ static const ARMCPRegInfo v8_cp_reginfo[] = { .opc0 = 1, .opc2 = 0, .crn = 8, .crm = 7, .opc2 = 7, .access = PL1_W, .type = ARM_CP_NO_MIGRATE, .writefn = tlbi_aa64_vaa_write }, +/* Dummy implementation of monitor debug system control register: +* we don't support debug. +*/ + { .name = "MDSCR_EL1", .state = ARM_CP_STATE_AA64, + .opc0 = 2, .opc1 = 0, .crn = 0, .crm = 2, .opc2 = 2, + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, REGINFO_SENTINEL };
Signature · 1 line
1.9.0
[Qemu-devel] [PULL 26/45] target-arm: Implement AArch64 MPIDR
In reply to Peter MaydellImplement the AArch64 MPIDR system register.
--- target-arm/helper.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
target-arm/helper.c +4 -2
@@ -1435,7 +1435,8 @@ static uint64_t mpidr_read(CPUARMState *env, const ARMCPRegInfo *ri) {CPUState *cs =CPU (arm_env_get_cpu (env));uint32_t mpidr = cs->cpu_index; -/* We don't support setting cluster ID ([8..11]) +/* We don't support setting cluster ID ([8..11]) (known as Aff1 +* in later ARM ARM versions), or any of the higher affinity level fields, * so these bits always RAZ. */ if (arm_feature (env,ARM_FEATURE_V7MP )) {
@@ -1450,7 +1451,8 @@ static uint64_t mpidr_read(CPUARMState *env, const ARMCPRegInfo *ri) }static const ARMCPRegInfo mpidr_cp_reginfo[] = { - { .name ="MPIDR" , .cp =15 , .crn =0 , .crm =0 , .opc1 =0 , .opc2 =5 , + { .name ="MPIDR" , .state =ARM_CP_STATE_BOTH , + .opc0 =3 , .crn =0 , .crm =0 , .opc1 =0 , .opc2 =5 , .access =PL1_R , .readfn = mpidr_read, .type =ARM_CP_NO_MIGRATE },REGINFO_SENTINEL };
Signature · 1 line
1.9.0
[Qemu-devel] [PULL 28/45] target-arm: Implement AArch64 ID and feature registers
In reply to Peter MaydellImplement the AArch64-specific ID and feature registers. Although many of these are currently not used by the architecture (and so always zero for all implementations), we define the full set of fields in the ARMCPU struct for symmetry.
--- target-arm/cpu-qom.h | 10 ++++++++++ target-arm/helper.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+)
target-arm/cpu-qom.h +10 -0
@@ -132,6 +132,16 @@ typedef struct ARMCPU {uint32_t id_isar3;uint32_t id_isar4;uint32_t id_isar5; +uint64_t id_aa64pfr0; +uint64_t id_aa64pfr1; +uint64_t id_aa64dfr0; +uint64_t id_aa64dfr1; +uint64_t id_aa64afr0; +uint64_t id_aa64afr1; +uint64_t id_aa64isar0; +uint64_t id_aa64isar1; +uint64_t id_aa64mmfr0; +uint64_t id_aa64mmfr1;uint32_t clidr;/* The elements of this array are the CCSIDR values for each cache, * in the order L1DCache, L1ICache, L2DCache, L2ICache, etc.
target-arm/helper.c +45 -0
51 lines not on this page · raw message
Signature · 1 line
1.9.0
[Qemu-devel] [PULL 19/45] target-arm: Implement AArch64 TLB invalidate ops
In reply to Peter MaydellImplement the AArch64 TLB invalidate operations. This is the full set of TLBI ops defined for a CPU which doesn't implement EL2 or EL3.
--- target-arm/helper.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+)
target-arm/helper.c +73 -0
@@ -1525,6 +1525,30 @@ static CPAccessResult aa64_cacheop_access(CPUARMState *env,return CP_ACCESS_OK ; } +static void tlbi_aa64_va_write (CPUARMState *env,const ARMCPRegInfo *ri, +uint64_t value) +{ +/* Invalidate by VA (AArch64 version) */ +uint64_t pageaddr = value <<12 ; +tlb_flush_page (env, pageaddr); +} + +static void tlbi_aa64_vaa_write (CPUARMState *env,const ARMCPRegInfo *ri, +uint64_t value) +{ +/* Invalidate by VA, all ASIDs (AArch64 version) */ +uint64_t pageaddr = value <<12 ; +tlb_flush_page (env, pageaddr); +} + +static void tlbi_aa64_asid_write (CPUARMState *env,const ARMCPRegInfo *ri, +uint64_t value) +{ +/* Invalidate by ASID (AArch64 version) */ +int asid =extract64 (value,48 ,16 ); +tlb_flush (env, asid ==0 ); +} +static const ARMCPRegInfo v8_cp_reginfo[] = {/* Minimal set of EL0-visible registers. This will need to be expanded * significantly for system emulation of AArch64 CPUs.
@@ -1583,6 +1607,55 @@ static const ARMCPRegInfo v8_cp_reginfo[] = { { .name = "DC_CISW", .state = ARM_CP_STATE_AA64, .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 14, .opc2 = 2, .access = PL1_W, .type = ARM_CP_NOP }, + /* TLBI operations */ + { .name = "TLBI_VMALLE1IS", .state = ARM_CP_STATE_AA64, + .opc0 = 1, .opc2 = 0, .crn = 8, .crm = 3, .opc2 = 0, + .access = PL1_W, .type = ARM_CP_NO_MIGRATE, + .writefn = tlbiall_write }, + { .name = "TLBI_VAE1IS", .state = ARM_CP_STATE_AA64, + .opc0 = 1, .opc2 = 0, .crn = 8, .crm = 3, .opc2 = 1, + .access = PL1_W, .type = ARM_CP_NO_MIGRATE, + .writefn = tlbi_aa64_va_write }, + { .name = "TLBI_ASIDE1IS", .state = ARM_CP_STATE_AA64, + .opc0 = 1, .opc2 = 0, .crn = 8, .crm = 3, .opc2 = 2, + .access = PL1_W, .type = ARM_CP_NO_MIGRATE, + .writefn = tlbi_aa64_asid_write }, + { .name = "TLBI_VAAE1IS", .state = ARM_CP_STATE_AA64, + .opc0 = 1, .opc2 = 0, .crn = 8, .crm = 3, .opc2 = 3, + .access = PL1_W, .type = ARM_CP_NO_MIGRATE, + .writefn = tlbi_aa64_vaa_write }, + { .name = "TLBI_VALE1IS", .state = ARM_CP_STATE_AA64, + .opc0 = 1, .opc2 = 0, .crn = 8, .crm = 3, .opc2 = 5, + .access = PL1_W, .type = ARM_CP_NO_MIGRATE, + .writefn = tlbi_aa64_va_write }, + { .name = "TLBI_VAALE1IS", .state = ARM_CP_STATE_AA64, + .opc0 = 1, .opc2 = 0, .crn = 8, .crm = 3, .opc2 = 7, + .access = PL1_W, .type = ARM_CP_NO_MIGRATE, + .writefn = tlbi_aa64_vaa_write }, + { .name = "TLBI_VMALLE1", .state = ARM_CP_STATE_AA64, + .opc0 = 1, .opc2 = 0, .crn = 8, .crm = 7, .opc2 = 0, + .access = PL1_W, .type = ARM_CP_NO_MIGRATE, + .writefn = tlbiall_write }, + { .name = "TLBI_VAE1", .state = ARM_CP_STATE_AA64, + .opc0 = 1, .opc2 = 0, .crn = 8, .crm = 7, .opc2 = 1, + .access = PL1_W, .type = ARM_CP_NO_MIGRATE, + .writefn = tlbi_aa64_va_write }, + { .name = "TLBI_ASIDE1", .state = ARM_CP_STATE_AA64, + .opc0 = 1, .opc2 = 0, .crn = 8, .crm = 7, .opc2 = 2, + .access = PL1_W, .type = ARM_CP_NO_MIGRATE, + .writefn = tlbi_aa64_asid_write }, + { .name = "TLBI_VAAE1", .state = ARM_CP_STATE_AA64, + .opc0 = 1, .opc2 = 0, .crn = 8, .crm = 7, .opc2 = 3, + .access = PL1_W, .type = ARM_CP_NO_MIGRATE, + .writefn = tlbi_aa64_vaa_write }, + { .name = "TLBI_VALE1", .state = ARM_CP_STATE_AA64, + .opc0 = 1, .opc2 = 0, .crn = 8, .crm = 7, .opc2 = 5, + .access = PL1_W, .type = ARM_CP_NO_MIGRATE, + .writefn = tlbi_aa64_va_write }, + { .name = "TLBI_VAALE1", .state = ARM_CP_STATE_AA64, + .opc0 = 1, .opc2 = 0, .crn = 8, .crm = 7, .opc2 = 7, + .access = PL1_W, .type = ARM_CP_NO_MIGRATE, + .writefn = tlbi_aa64_vaa_write }, REGINFO_SENTINEL };
Signature · 1 line
1.9.0
[Qemu-devel] [PULL 32/45] target-arm: A64: Implement WFI
In reply to Peter MaydellImplement the WFI instruction for A64; this just involves wiring up the instruction, and adding a gen_a64_set_pc_im() which was accidentally omitted from the A64 decoder top loop.
--- target-arm/translate-a64.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
target-arm/translate-a64.c +4 -1
@@ -1080,9 +1080,11 @@ static void handle_hint(DisasContext *s, uint32_t insn,switch (selector) {case 0 :/* NOP */ return ; +case 3 :/* WFI */ + s->is_jmp =DISAS_WFI ; +return ;case 1 :/* YIELD */ case 2 :/* WFE */ -case 3 :/* WFI */ case 4 :/* SEV */ case 5 :/* SEVL */ /* we treat all as NOP at least for now */
@@ -9124,6 +9126,7 @@ void gen_intermediate_code_internal_a64(ARMCPU *cpu,/* This is a special case because we don't want to just halt the CPU * if trying to debug across a WFI. */ +gen_a64_set_pc_im (dc->pc);gen_helper_wfi (cpu_env);break ; }
Signature · 1 line
1.9.0
[Qemu-devel] [PULL 08/45] hw/intc/arm_gic: Fix GIC_SET_LEVEL
In reply to Peter MaydellFrom: Christoffer Dall <[email protected]>
The GIC_SET_LEVEL macro unfortunately overwrote the entire level bitmask instead of just or'ing on the necessary bits, causing active level PPIs on a core to clear PPIs on other cores.
Message-id: [email protected]
--- hw/intc/gic_internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/intc/gic_internal.h +1 -1
@@ -40,7 +40,7 @@#define GIC_SET_MODEL (irq) s->irq_state[irq].model = true#define GIC_CLEAR_MODEL (irq) s->irq_state[irq].model = false#define GIC_TEST_MODEL (irq) s->irq_state[irq].model -#define GIC_SET_LEVEL (irq, cm) s->irq_state[irq].level = (cm) +#define GIC_SET_LEVEL (irq, cm) s->irq_state[irq].level |= (cm)#define GIC_CLEAR_LEVEL (irq, cm) s->irq_state[irq].level &= ~(cm)#define GIC_TEST_LEVEL (irq, cm) ((s->irq_state[irq].level & (cm)) != 0)#define GIC_SET_EDGE_TRIGGER (irq) s->irq_state[irq].edge_trigger = true
Signature · 1 line
1.9.0
[Qemu-devel] [PULL 02/45] hw/net/stellaris_enet: Avoid unintended sign extension
In reply to Peter MaydellAdd a cast to avoid an unintended sign extension that would mean we returned 0xffffffff in the high 32 bits for an IA0 read if bit 31 in the MAC address was 1. (This is harmless since we'll only be doing 4 byte reads, but it could be confusing, so best avoided.)
Message-id: [email protected]
--- hw/net/stellaris_enet.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
hw/net/stellaris_enet.c +2 -1
@@ -176,7 +176,8 @@ static uint64_t stellaris_enet_read(void *opaque, hwaddr offset,return val;case 0x14 :/* IA0 */ return s->conf.macaddr.a[0 ] | (s->conf.macaddr.a[1 ] <<8 ) - | (s->conf.macaddr.a[2 ] <<16 ) | (s->conf.macaddr.a[3 ] <<24 ); + | (s->conf.macaddr.a[2 ] <<16 ) + | ((uint32_t )s->conf.macaddr.a[3 ] <<24 );case 0x18 :/* IA1 */ return s->conf.macaddr.a[4 ] | (s->conf.macaddr.a[5 ] <<8 );case 0x1c :/* THR */
Signature · 1 line
1.9.0
[Qemu-devel] [PULL 09/45] linux-headers: Update from v3.14-rc3
In reply to Peter MaydellFrom: Christoffer Dall <[email protected]>
Update to tag v3.14-rc3 (6d0abeca3242a88cab8232e4acd7e2bf088f3bc2)
Message-id: [email protected]
--- linux-headers/asm-arm/kvm.h | 28 ++++++++++++++++++++++++++++ linux-headers/asm-arm64/kvm.h | 30 +++++++++++++++++++++++++++++- linux-headers/asm-powerpc/kvm.h | 3 +++ linux-headers/asm-x86/hyperv.h | 16 +++++++++++++--- linux-headers/linux/kvm.h | 1 + 5 files changed, 74 insertions(+), 4 deletions(-)
linux-headers/asm-arm/kvm.h +28 -0
@@ -119,6 +119,26 @@ struct kvm_arch_memory_slot {#define KVM_REG_ARM_32_CRN_MASK 0x0000000000007800#define KVM_REG_ARM_32_CRN_SHIFT 11 +#define ARM_CP15_REG_SHIFT_MASK (x,n) \ + (((x) << KVM_REG_ARM_ ## n ## _SHIFT) & KVM_REG_ARM_ ## n ## _MASK) + +#define __ARM_CP15_REG (op1,crn,crm,op2) \ + (KVM_REG_ARM | (15 << KVM_REG_ARM_COPROC_SHIFT) | \ + ARM_CP15_REG_SHIFT_MASK(op1, OPC1) | \ + ARM_CP15_REG_SHIFT_MASK(crn, 32_CRN) | \ + ARM_CP15_REG_SHIFT_MASK(crm, CRM) | \ + ARM_CP15_REG_SHIFT_MASK(op2, 32_OPC2)) + +#define ARM_CP15_REG32 (...) (__ARM_CP15_REG(__VA_ARGS__) | KVM_REG_SIZE_U32) + +#define __ARM_CP15_REG64 (op1,crm) \ + (__ARM_CP15_REG(op1, 0, crm, 0) | KVM_REG_SIZE_U64) +#define ARM_CP15_REG64 (...) __ARM_CP15_REG64(__VA_ARGS__) + +#define KVM_REG_ARM_TIMER_CTL ARM_CP15_REG32(0, 14, 3, 1) +#define KVM_REG_ARM_TIMER_CNT ARM_CP15_REG64(1, 14) +#define KVM_REG_ARM_TIMER_CVAL ARM_CP15_REG64(3, 14) +/* Normal registers are mapped as coprocessor 16. */ #define KVM_REG_ARM_CORE (0x0010 << KVM_REG_ARM_COPROC_SHIFT)#define KVM_REG_ARM_CORE_REG (name) (offsetof(struct kvm_regs, name) / 4)
@@ -143,6 +163,14 @@ struct kvm_arch_memory_slot {#define KVM_REG_ARM_VFP_FPINST 0x1009#define KVM_REG_ARM_VFP_FPINST2 0x100A +/* Device Control API: ARM VGIC */ +#define KVM_DEV_ARM_VGIC_GRP_ADDR 0 +#define KVM_DEV_ARM_VGIC_GRP_DIST_REGS 1 +#define KVM_DEV_ARM_VGIC_GRP_CPU_REGS 2 +#define KVM_DEV_ARM_VGIC_CPUID_SHIFT 32 +#define KVM_DEV_ARM_VGIC_CPUID_MASK (0xffULL << KVM_DEV_ARM_VGIC_CPUID_SHIFT) +#define KVM_DEV_ARM_VGIC_OFFSET_SHIFT 0 +#define KVM_DEV_ARM_VGIC_OFFSET_MASK (0xffffffffULL << KVM_DEV_ARM_VGIC_OFFSET_SHIFT)/* KVM_IRQ_LINE irq field index values */ #define KVM_ARM_IRQ_TYPE_SHIFT 24
linux-headers/asm-arm64/kvm.h +29 -1
@@ -55,8 +55,9 @@ struct kvm_regs {#define KVM_ARM_TARGET_AEM_V8 0#define KVM_ARM_TARGET_FOUNDATION_V8 1#define KVM_ARM_TARGET_CORTEX_A57 2 +#define KVM_ARM_TARGET_XGENE_POTENZA 3 -#define KVM_ARM_NUM_TARGETS 3 +#define KVM_ARM_NUM_TARGETS 4/* KVM_ARM_SET_DEVICE_ADDR ioctl id encoding */ #define KVM_ARM_DEVICE_TYPE_SHIFT 0
@@ -129,6 +130,33 @@ struct kvm_arch_memory_slot {#define KVM_REG_ARM64_SYSREG_OP2_MASK 0x0000000000000007#define KVM_REG_ARM64_SYSREG_OP2_SHIFT 0 +#define ARM64_SYS_REG_SHIFT_MASK (x,n) \ + (((x) << KVM_REG_ARM64_SYSREG_ ## n ## _SHIFT) & \ + KVM_REG_ARM64_SYSREG_ ## n ## _MASK) + +#define __ARM64_SYS_REG (op0,op1,crn,crm,op2) \ + (KVM_REG_ARM64 | KVM_REG_ARM64_SYSREG | \ + ARM64_SYS_REG_SHIFT_MASK(op0, OP0) | \ + ARM64_SYS_REG_SHIFT_MASK(op1, OP1) | \ + ARM64_SYS_REG_SHIFT_MASK(crn, CRN) | \ + ARM64_SYS_REG_SHIFT_MASK(crm, CRM) | \ + ARM64_SYS_REG_SHIFT_MASK(op2, OP2)) + +#define ARM64_SYS_REG (...) (__ARM64_SYS_REG(__VA_ARGS__) | KVM_REG_SIZE_U64) + +#define KVM_REG_ARM_TIMER_CTL ARM64_SYS_REG(3, 3, 14, 3, 1) +#define KVM_REG_ARM_TIMER_CNT ARM64_SYS_REG(3, 3, 14, 3, 2) +#define KVM_REG_ARM_TIMER_CVAL ARM64_SYS_REG(3, 3, 14, 0, 2) + +/* Device Control API: ARM VGIC */ +#define KVM_DEV_ARM_VGIC_GRP_ADDR 0 +#define KVM_DEV_ARM_VGIC_GRP_DIST_REGS 1 +#define KVM_DEV_ARM_VGIC_GRP_CPU_REGS 2 +#define KVM_DEV_ARM_VGIC_CPUID_SHIFT 32 +#define KVM_DEV_ARM_VGIC_CPUID_MASK (0xffULL << KVM_DEV_ARM_VGIC_CPUID_SHIFT) +#define KVM_DEV_ARM_VGIC_OFFSET_SHIFT 0 +#define KVM_DEV_ARM_VGIC_OFFSET_MASK (0xffffffffULL << KVM_DEV_ARM_VGIC_OFFSET_SHIFT) +/* KVM_IRQ_LINE irq field index values */ #define KVM_ARM_IRQ_TYPE_SHIFT 24#define KVM_ARM_IRQ_TYPE_MASK 0xff
linux-headers/asm-powerpc/kvm.h +3 -0
@@ -545,6 +545,7 @@ struct kvm_get_htab_header {#define KVM_REG_PPC_TCSCR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xb1)#define KVM_REG_PPC_PID (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xb2)#define KVM_REG_PPC_ACOP (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xb3) +#define KVM_REG_PPC_WORT (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xb4)#define KVM_REG_PPC_VRSAVE (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0xb4)#define KVM_REG_PPC_LPCR (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0xb5)
@@ -553,6 +554,8 @@ struct kvm_get_htab_header {/* Architecture compatibility level */ #define KVM_REG_PPC_ARCH_COMPAT (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0xb7) +#define KVM_REG_PPC_DABRX (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0xb8) +/* Transactional Memory checkpointed state: * This is all GPRs, all VSX regs and a subset of SPRs */
linux-headers/asm-x86/hyperv.h +13 -3
@@ -28,6 +28,9 @@/* Partition Reference Counter (HV_X64_MSR_TIME_REF_COUNT) available*/ #define HV_X64_MSR_TIME_REF_COUNT_AVAILABLE (1 << 1) +/* A partition's reference time stamp counter (TSC) page */ +#define HV_X64_MSR_REFERENCE_TSC 0x40000021 +/* * There is a single feature flag that signifies the presence of the MSR * that can be used to retrieve both the local APIC Timer frequency as
@@ -149,9 +152,6 @@/* MSR used to read the per-partition time reference counter */ #define HV_X64_MSR_TIME_REF_COUNT 0x40000020 -/* A partition's reference time stamp counter (TSC) page */ -#define HV_X64_MSR_REFERENCE_TSC 0x40000021 -/* MSR used to retrieve the TSC frequency */ #define HV_X64_MSR_TSC_FREQUENCY 0x40000022
@@ -201,6 +201,9 @@#define HV_X64_MSR_APIC_ASSIST_PAGE_ADDRESS_MASK \ (~((1ull << HV_X64_MSR_APIC_ASSIST_PAGE_ADDRESS_SHIFT) - 1)) +#define HV_X64_MSR_TSC_REFERENCE_ENABLE 0x00000001 +#define HV_X64_MSR_TSC_REFERENCE_ADDRESS_SHIFT 12 +#define HV_PROCESSOR_POWER_STATE_C0 0#define HV_PROCESSOR_POWER_STATE_C1 1#define HV_PROCESSOR_POWER_STATE_C2 2
@@ -213,4 +216,11 @@#define HV_STATUS_INVALID_ALIGNMENT 4#define HV_STATUS_INSUFFICIENT_BUFFERS 19 +typedef struct _HV_REFERENCE_TSC_PAGE { +__u32 tsc_sequence; +__u32 res1; +__u64 tsc_scale; +__s64 tsc_offset; +}HV_REFERENCE_TSC_PAGE , *PHV_REFERENCE_TSC_PAGE ; +#endif
linux-headers/linux/kvm.h +1 -0
@@ -854,6 +854,7 @@ struct kvm_device_attr {#define KVM_DEV_VFIO_GROUP 1#define KVM_DEV_VFIO_GROUP_ADD 1#define KVM_DEV_VFIO_GROUP_DEL 2 +#define KVM_DEV_TYPE_ARM_VGIC_V2 5/* * ioctls for VM fds
Signature · 1 line
1.9.0
[Qemu-devel] [PULL 01/45] hw/misc/arm_sysctl: Fix bad boundary check on mb clock accesses
In reply to Peter MaydellFix incorrect use of sizeof() rather than ARRAY_SIZE() to guard accesses into the mb_clock[] array, which was allowing a malicious guest to overwrite the end of the array.
Message-id: [email protected]
Cc: [email protected]
--- hw/misc/arm_sysctl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/misc/arm_sysctl.c +2 -2
@@ -276,7 +276,7 @@ static bool vexpress_cfgctrl_read(arm_sysctl_state *s, unsigned int dcc, }break ;case SYS_CFG_OSC : -if (site ==SYS_CFG_SITE_MB && device <sizeof (s->mb_clock)) { +if (site ==SYS_CFG_SITE_MB && device <ARRAY_SIZE (s->mb_clock)) {/* motherboard clock */ *val = s->mb_clock[device];return true;
@@ -324,7 +324,7 @@ static bool vexpress_cfgctrl_write(arm_sysctl_state *s, unsigned int dcc,switch (function) {case SYS_CFG_OSC : -if (site ==SYS_CFG_SITE_MB && device <sizeof (s->mb_clock)) { +if (site ==SYS_CFG_SITE_MB && device <ARRAY_SIZE (s->mb_clock)) {/* motherboard clock */ s->mb_clock[device] = val;return true;
Signature · 1 line
1.9.0
[Qemu-devel] [PULL 21/45] target-arm: Implement AArch64 memory attribute registers
In reply to Peter MaydellImplement the AArch64 memory attribute registers. Since QEMU doesn't model caches it does not need to care about memory attributes at all, and we can simply make these read-as-written.
We did not previously implement the AArch32 versions of the MAIR registers, which went unnoticed because of the overbroad TLB_LOCKDOWN reginfo definition; provide them now to keep the 64<->32 register relationship clear.
We already provided AMAIR registers for 32 bit as simple RAZ/WI; extend that to provide a 64 bit RAZ/WI AMAIR_EL1.
--- target-arm/cpu.h | 3 +++ target-arm/helper.c | 24 +++++++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-)
target-arm/cpu.h +3 -0
@@ -74,8 +74,10 @@*/ #ifdef HOST_WORDS_BIGENDIAN #define offsetoflow32 (S ,M ) (offsetof(S, M) + sizeof(uint32_t)) +#define offsetofhigh32 (S ,M ) offsetof(S, M)#else #define offsetoflow32 (S ,M ) offsetof(S, M) +#define offsetofhigh32 (S ,M ) (offsetof(S, M) + sizeof(uint32_t))#endif /* Meanings of the ARMCPU object's two inbound GPIO lines */
@@ -197,6 +199,7 @@ typedef struct CPUARMState {uint32_t c9_pmxevtyper;/* perf monitor event type */ uint32_t c9_pmuserenr;/* perf monitor user enable */ uint32_t c9_pminten;/* perf monitor interrupt enables */ +uint64_t mair_el1;uint32_t c12_vbar;/* vector base address register */ uint32_t c13_fcse;/* FCSE PID. */ uint32_t c13_context;/* Context ID. */
target-arm/helper.c +23 -1
@@ -641,6 +641,26 @@ static const ARMCPRegInfo v7_cp_reginfo[] = {*/ { .name = "AIDR", .cp = 15, .crn = 0, .crm = 0, .opc1 = 1, .opc2 = 7, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 }, + /* MAIR can just read-as-written because we don't implement caches + * and so don't need to care about memory attributes. + */ + { .name = "MAIR_EL1", .state = ARM_CP_STATE_AA64, + .opc0 = 3, .opc1 = 0, .crn = 10, .crm = 2, .opc2 = 0, + .access = PL1_RW, .fieldoffset = offsetof(CPUARMState, cp15.mair_el1), + .resetvalue = 0 }, + /* For non-long-descriptor page tables these are PRRR and NMRR; + * regardless they still act as reads-as-written for QEMU. + * The override is necessary because of the overly-broad TLB_LOCKDOWN + * definition. + */ + { .name = "MAIR0", .state = ARM_CP_STATE_AA32, .type = ARM_CP_OVERRIDE, + .cp = 15, .opc1 = 0, .crn = 10, .crm = 2, .opc2 = 0, .access = PL1_RW, + .fieldoffset = offsetoflow32(CPUARMState, cp15.mair_el1), + .resetfn = arm_cp_reset_ignore }, + { .name = "MAIR1", .state = ARM_CP_STATE_AA32, .type = ARM_CP_OVERRIDE, + .cp = 15, .opc1 = 0, .crn = 10, .crm = 2, .opc2 = 1, .access = PL1_RW, + .fieldoffset = offsetofhigh32(CPUARMState, cp15.mair_el1), + .resetfn = arm_cp_reset_ignore }, REGINFO_SENTINEL };
@@ -1467,9 +1487,11 @@ static const ARMCPRegInfo lpae_cp_reginfo[] = {/* NOP AMAIR0/1: the override is because these clash with the rather * broadly specified TLB_LOCKDOWN entry in the generic cp_reginfo. */ - { .name = "AMAIR0", .cp = 15, .crn = 10, .crm = 3, .opc1 = 0, .opc2 = 0, + { .name = "AMAIR0", .state = ARM_CP_STATE_BOTH, + .opc0 = 3, .crn = 10, .crm = 3, .opc1 = 0, .opc2 = 0, .access = PL1_RW, .type = ARM_CP_CONST | ARM_CP_OVERRIDE, .resetvalue = 0 }, + /* AMAIR1 is mapped to AMAIR_EL1[63:32] */ { .name = "AMAIR1", .cp = 15, .crn = 10, .crm = 3, .opc1 = 0, .opc2 = 1, .access = PL1_RW, .type = ARM_CP_CONST | ARM_CP_OVERRIDE, .resetvalue = 0 },
Signature · 1 line
1.9.0
[Qemu-devel] [PULL 18/45] target-arm: Implement AArch64 cache invalidate/clean ops
In reply to Peter MaydellImplement all the AArch64 cache invalidate and clean ops (which are all NOPs since QEMU doesn't emulate the cache). The only remaining unimplemented cache op is DC ZVA.
--- target-arm/cpu.c | 4 ++-- target-arm/helper.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 2 deletions(-)
target-arm/cpu.c +2 -2
@@ -91,8 +91,8 @@ static void arm_cpu_reset(CPUState *s) env->aarch64 =1 ;#if defined(CONFIG_USER_ONLY ) env->pstate = PSTATE_MODE_EL0t; -/* Userspace expects access to CTL_EL0 */ - env->cp15.c1_sys |=SCTLR_UCT ; +/* Userspace expects access to CTL_EL0 and the cache ops */ + env->cp15.c1_sys |=SCTLR_UCT |SCTLR_UCI ;#else env->pstate =PSTATE_D |PSTATE_A |PSTATE_I |PSTATE_F | PSTATE_MODE_EL1h;
target-arm/helper.c +47 -0
59 lines not on this page · raw message
Signature · 1 line
1.9.0
[Qemu-devel] [PULL 03/45] hw/timer/arm_timer: Avoid array overrun for bad addresses
In reply to Peter MaydellThe integrator's timer read/write functions log an error for bad addresses in guest accesses, but were falling through and using an out of bounds array index rather than returning early. Fix this.
Message-id: [email protected]
Cc: [email protected]
--- hw/timer/arm_timer.c | 2 ++ 1 file changed, 2 insertions(+)
hw/timer/arm_timer.c +2 -0
@@ -320,6 +320,7 @@ static uint64_t icp_pit_read(void *opaque, hwaddr offset, n = offset >>8 ;if (n >2 ) {qemu_log_mask (LOG_GUEST_ERROR ,"%s: Bad timer %d\n" , __func__, n); +return 0 ; }return arm_timer_read (s->timer[n], offset &0xff );
@@ -334,6 +335,7 @@ static void icp_pit_write(void *opaque, hwaddr offset, n = offset >>8 ;if (n >2 ) {qemu_log_mask (LOG_GUEST_ERROR ,"%s: Bad timer %d\n" , __func__, n); +return ; }arm_timer_write (s->timer[n], offset &0xff , value);
Signature · 1 line
1.9.0
[Qemu-devel] [PULL 07/45] target-arm: Load correct access bits from ARMv5 level 2 page table descriptors
In reply to Peter MaydellIn ARMv5 level 2 page table descriptors, each 4K or 64K page is split into four subpages, each of which can have different access permission settings, which are specified by four two-bit fields in the l2 descriptor. A long-standing cut-and-paste error meant we were using the wrong bits in the virtual address to select the access-permission field for 4K pages.
The error has presumably not been noticed before because most guests don't make use of the ability to set the access permissions differently for each 1K subpage: if the guest gives the whole page the same access permissions it doesn't matter which of the 4 AP fields we select. (The whole issue is irrelevant for ARMv7 CPUs anyway because subpages aren't supported there.)
Message-id: [email protected]
--- target-arm/helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target-arm/helper.c +1 -1
@@ -2798,7 +2798,7 @@ static int get_phys_addr_v5(CPUARMState *env, uint32_t address, int access_type,break ;case 2 :/* 4k page. */ phys_addr = (desc &0xfffff000 ) | (address &0xfff ); - ap = (desc >> (4 + ((address >>13 ) &6 ))) &3 ; + ap = (desc >> (4 + ((address >>9 ) &6 ))) &3 ; *page_size =0x1000 ;break ;case 3 :/* 1k page. */
Signature · 1 line
1.9.0
[Qemu-devel] [PULL 06/45] hw/arm/musicpal: Remove nonexistent CDTP2, CDTP3 registers
In reply to Peter MaydellThe ethernet device in the musicpal only has two tx queues, but we modelled it with four CTDP registers, presumably a cut and paste from the rx queue registers. Since the tx_queue[] array is only 2 entries long this allowed a guest to overrun this buffer. Remove the nonexistent registers.
Message-id: [email protected]
--- hw/arm/musicpal.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
hw/arm/musicpal.c +2 -4
@@ -92,8 +92,6 @@#define MP_ETH_CRDP3 0x4AC#define MP_ETH_CTDP0 0x4E0#define MP_ETH_CTDP1 0x4E4 -#define MP_ETH_CTDP2 0x4E8 -#define MP_ETH_CTDP3 0x4EC/* MII PHY access */ #define MP_ETH_SMIR_DATA 0x0000FFFF
@@ -308,7 +306,7 @@ static uint64_t mv88w8618_eth_read(void *opaque, hwaddr offset, case MP_ETH_CRDP0 ... MP_ETH_CRDP3:return s->rx_queue[(offset -MP_ETH_CRDP0 )/4 ]; - case MP_ETH_CTDP0 ... MP_ETH_CTDP3: + case MP_ETH_CTDP0 ... MP_ETH_CTDP1:return s->tx_queue[(offset -MP_ETH_CTDP0 )/4 ];default :
@@ -362,7 +360,7 @@ static void mv88w8618_eth_write(void *opaque, hwaddr offset, s->cur_rx[(offset -MP_ETH_CRDP0 )/4 ] = value;break ; - case MP_ETH_CTDP0 ... MP_ETH_CTDP3: + case MP_ETH_CTDP0 ... MP_ETH_CTDP1: s->tx_queue[(offset -MP_ETH_CTDP0 )/4 ] = value;break ; }
Signature · 1 line
1.9.0
Peter Maydell
AppliedQuoted 12 lines · Peter Maydell
The following changes since commit
d5001cf787ad0514839a81d0f2e771e01e076e21:xilinx: Delete
hw/include/xilinx.h(2014-02-26 14:54:45 +1000)are available in the git repository at:
git://git.linaro.org/people/pmaydell/qemu-arm.gittags/pull-target-arm-20140226for you to fetch changes up to
c04018e93390e31b40044f3db92c173fb0ccb3d2:dma/pl330: implement dmaadnh instruction (2014-02-26 17:20:09 +0000)
Quoted 8 lines
----------------------------------------------------------------
target-arm queue:
* fixes for various Coverity-spotted bugs
* support new KVM device control API for VGIC
* support KVM VGIC save/restore/migration
* more AArch64 system mode foundations
* support ARMv8 CRC instructions for A32/T32
* PL330 minor fixes and cleanup
Applied, thanks.
-- PMM