target-arm queue
Subsystems (6)
One ARM pull request... mostly bugfixes and small-to-medium stuff.
thanks
-- PMM
The following changes since commit e854d0cf7847e70f5ed5dad5820fc1bbeda6f29e:
Merge remote-tracking branch 'remotes/kraxel/tags/pull-vga-20160606-1' into staging (2016-06-06 13:58:24 +0100)
are available in the git repository at:
git://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20160606
for you to fetch changes up to 7e700e1fd059ac18949b774f7e93dc78cad40023:
zynqmp: Add the ZCU102 board (2016-06-06 15:39:35 +0100)
----------------------------------------------------------------
target-arm queue:
* support instruction syndrome info for data aborts from A64 to EL2
* add HSTR_EL2 register
* fix incorrect ESR IL bits in various syndrome register cases
* virt: fix limit of 64-bit ACPI/ECAM PCI MMIO range
* virt: support virtual PMU (if using KVM)
* gicv2: RAZ/WI non-sec access to sec interrupts
* i2c: add aspeed i2c controller
* virt: Reject gic-version=host for non-KVM (don't segv on aarch64 host)
* xlnx-zynqmp: Add a secure prop to en/disable ARM Security Extensions
* xlnx-zynqmp: Support KVM on AArch64 hosts
* ptimer: Various fixes for awkward corner cases
* char: QOMify various ARM UART models
* char: get rid of qemu_char_get_next_serial
* target-arm: Fix TTBR selecting logic on AArch32 Stage 2 translation
* zynqmp: Add the ZCU102 board
----------------------------------------------------------------
Alistair Francis (2):
target-arm: Add the HSTR_EL2 register
zynqmp: Add the ZCU102 board
Ard Biesheuvel (1):
hw/arm/virt: fix limit of 64-bit ACPI/ECAM PCI MMIO range
Cole Robinson (1):
hw/arm/virt: Reject gic-version=host for non-KVM
Cédric Le Goater (1):
i2c: add aspeed i2c controller
Dmitry Osipenko (5):
hw/ptimer: Fix issues caused by the adjusted timer limit value hw/ptimer: Perform counter wrap around if timer already expired hw/ptimer: Update .delta on period/freq change hw/ptimer: Support "on the fly" timer mode switch hw/ptimer: Introduce ptimer_get_limit
Edgar E. Iglesias (5):
target-arm: A64: Create Instruction Syndromes for Data Aborts
xlnx-zynqmp: Add a secure prop to en/disable ARM Security Extensions
xlnx-zynqmp: Make the RPU subsystem optional
xlnx-zynqmp: Delay realization of GIC until post CPU realization
xlnx-zynqmp: Use the in kernel GIC model for KVM runs
Jens Wiklander (1):
hw/intc/gic: RAZ/WI non-sec access to sec interrupts
Peter Maydell (2):
target-arm: Set IL bit in syndromes for insn abort, watchpoint, swstep
target-arm: Don't try to set ESR IL bit in arm_cpu_do_interrupt_aarch64()
Sergey Sorokin (1):
target-arm: Fix TTBR selecting logic on AArch32 Stage 2 translation
Shannon Zhao (3):
target-arm: kvm64: set guest PMUv3 feature bit if supported hw/arm/virt: Add PMU node for virt machine hw/arm/virt-acpi-build: Add PMU IRQ number in ACPI table
xiaoqiang zhao (6):
hw/char: QOM'ify pl011 model
hw/char: QOM'ify cadence_uart model
hw/char: QOM'ify digic-uart model
hw/char: QOM'ify stm32f2xx_usart model
hw/char: QOM'ify xilinx_uartlite model
char: get rid of qemu_char_get_next_serial
hw/arm/ast2400.c | 16 ++ hw/arm/bcm2835_peripherals.c | 16 +- hw/arm/digic.c | 2 + hw/arm/highbank.c | 3 +- hw/arm/integratorcp.c | 5 +- hw/arm/realview.c | 9 +- hw/arm/stellaris.c | 6 +- hw/arm/stm32f205_soc.c | 1 + hw/arm/versatilepb.c | 9 +- hw/arm/vexpress.c | 9 +- hw/arm/virt-acpi-build.c | 7 +- hw/arm/virt.c | 40 ++- hw/arm/xilinx_zynq.c | 5 +- hw/arm/xlnx-ep108.c | 8 + hw/arm/xlnx-zynqmp.c | 122 +++++---- hw/char/cadence_uart.c | 13 +- hw/char/digic-uart.c | 10 +- hw/char/pl011.c | 11 +- hw/char/stm32f2xx_usart.c | 15 +- hw/char/xilinx_uartlite.c | 10 +- hw/core/ptimer.c | 88 +++--- hw/i2c/Makefile.objs | 1 + hw/i2c/aspeed_i2c.c | 450 +++++++++++++++++++++++++++++++ hw/intc/arm_gic.c | 68 ++++- hw/microblaze/petalogix_s3adsp1800_mmu.c | 5 +- include/hw/arm/ast2400.h | 2 + include/hw/arm/virt.h | 4 + include/hw/arm/xlnx-zynqmp.h | 5 + include/hw/char/cadence_uart.h | 17 ++ include/hw/char/pl011.h | 52 ++++ include/hw/char/xilinx_uartlite.h | 35 +++ include/hw/i2c/aspeed_i2c.h | 62 +++++ include/hw/ptimer.h | 1 + include/sysemu/char.h | 1 - include/sysemu/kvm.h | 1 + qemu-char.c | 16 -- stubs/kvm.c | 5 + target-arm/cpu.h | 17 +- target-arm/helper.c | 48 ++-- target-arm/internals.h | 6 +- target-arm/kvm64.c | 46 ++++ target-arm/op_helper.c | 49 +++- target-arm/translate-a64.c | 140 ++++++++-- target-arm/translate.c | 5 +- target-arm/translate.h | 2 + 45 files changed, 1230 insertions(+), 213 deletions(-) create mode 100644 hw/i2c/aspeed_i2c.c create mode 100644 include/hw/char/pl011.h create mode 100644 include/hw/char/xilinx_uartlite.h create mode 100644 include/hw/i2c/aspeed_i2c.h
[Qemu-devel] [PULL 15/28] xlnx-zynqmp: Use the in kernel GIC model for KVM runs
From: "Edgar E. Iglesias" <[email protected]>
Use the in kernel GIC model when running with KVM enabled.
Message-id: [email protected]
--- hw/arm/xlnx-zynqmp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
hw/arm/xlnx-zynqmp.c +3 -1
@@ -22,6 +22,8 @@#include "hw/arm/xlnx-zynqmp.h" #include "hw/intc/arm_gic_common.h" #include "exec/address-spaces.h" +#include "sysemu/kvm.h" +#include "kvm_arm.h" #define GIC_NUM_SPI_INTR 160
@@ -135,7 +137,7 @@ static void xlnx_zynqmp_init(Object *obj) qdev_prop_allow_set_link_before_realize, OBJ_PROP_LINK_UNREF_ON_RELEASE, &error_abort); -object_initialize (&s->gic,sizeof (s->gic),TYPE_ARM_GIC ); +object_initialize (&s->gic,sizeof (s->gic),gic_class_name ());qdev_set_parent_bus (DEVICE (&s->gic),sysbus_get_default ());for (i =0 ; i <XLNX_ZYNQMP_NUM_GEMS ; i++) {
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 16/28] hw/ptimer: Fix issues caused by the adjusted timer limit value
In reply to Peter MaydellFrom: Dmitry Osipenko <[email protected]>
Multiple issues here related to the timer with a adjusted .limit value:
1) ptimer_get_count() returns incorrect counter value for the disabled timer after loading the counter with a small value, because adjusted limit value is used instead of the original.
For instance:
1) ptimer_stop(t)
2) ptimer_set_period(t, 1)
3) ptimer_set_limit(t, 0, 1)
4) ptimer_get_count(t) <-- would return 10000 instead of 0
2) ptimer_get_count() might return incorrect value for the timer running with a adjusted limit value.
For instance:
1) ptimer_stop(t)
2) ptimer_set_period(t, 1)
3) ptimer_set_limit(t, 10, 1)
4) ptimer_run(t)
5) ptimer_get_count(t) <-- might return value > 10
3) Neither ptimer_set_period() nor ptimer_set_freq() are adjusting the limit value, so it is still possible to make timer timeout value arbitrary small.
For instance:
1) ptimer_set_period(t, 10000)
2) ptimer_set_limit(t, 1, 0)
3) ptimer_set_period(t, 1) <-- bypass limit correction
Fix all of the above issues by adjusting timer period instead of the limit. Perform the adjustment for periodic timer only. Use the delta value instead of the limit to make decision whether adjustment is required, as limit could be altered while timer is running, resulting in incorrect value returned by ptimer_get_count.
Message-id: cd141f74f5737480ec586b9c7d18cce1d69884e2.1464367869.git.digetx@gmail.com
--- hw/core/ptimer.c | 51 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 20 deletions(-)
hw/core/ptimer.c +31 -20
@@ -35,6 +35,9 @@ static void ptimer_trigger(ptimer_state *s)static void ptimer_reload (ptimer_state *s) { +uint32_t period_frac = s->period_frac; +uint64_t period = s->period; +if (s->delta ==0 ) {ptimer_trigger (s); s->delta = s->limit;
@@ -45,10 +48,24 @@ static void ptimer_reload(ptimer_state *s)return ; } +/* +* Artificially limit timeout rate to something +* achievable under QEMU. Otherwise, QEMU spends all +* its time generating timer interrupts, and there +* is no forward progress. +* About ten microseconds is the fastest that really works +* on the current generation of host machines. +*/ + +if (s->enabled ==1 && (s->delta * period <10000 ) && !use_icount) { + period =10000 / s->delta; + period_frac =0 ; + } + s->last_event = s->next_event; - s->next_event = s->last_event + s->delta * s->period; -if (s->period_frac) { - s->next_event += ((int64_t )s->period_frac * s->delta) >>32 ; + s->next_event = s->last_event + s->delta * period; +if (period_frac) { + s->next_event += ((int64_t )period_frac * s->delta) >>32 ; }timer_mod (s->timer, s->next_event); }
@@ -83,6 +100,13 @@ uint64_t ptimer_get_count(ptimer_state *s)uint64_t div;int clz1, clz2;int shift; +uint32_t period_frac = s->period_frac; +uint64_t period = s->period; + +if ((s->enabled ==1 ) && !use_icount && (s->delta * period <10000 )) { + period =10000 / s->delta; + period_frac =0 ; + }/* We need to divide time by period, where time is stored in rem (64-bit integer) and period is stored in period/period_frac
@@ -95,7 +119,7 @@ uint64_t ptimer_get_count(ptimer_state *s)*/ rem = s->next_event - now; - div = s->period; + div = period; clz1 =clz64 (rem); clz2 =clz64 (div);
@@ -104,13 +128,13 @@ uint64_t ptimer_get_count(ptimer_state *s) rem <<= shift; div <<= shift;if (shift >=32 ) { - div |= ((uint64_t )s->period_frac << (shift -32 )); + div |= ((uint64_t )period_frac << (shift -32 )); }else {if (shift !=0 ) - div |= (s->period_frac >> (32 - shift)); + div |= (period_frac >> (32 - shift));/* Look at remaining bits of period_frac and round div up if necessary. */ -if ((uint32_t )(s->period_frac << shift)) +if ((uint32_t )(period_frac << shift)) div +=1 ; } counter = rem / div;
@@ -182,19 +206,6 @@ void ptimer_set_freq(ptimer_state *s, uint32_t freq)count = limit. */ void ptimer_set_limit (ptimer_state *s,uint64_t limit,int reload) { -/* -* Artificially limit timeout rate to something -* achievable under QEMU. Otherwise, QEMU spends all -* its time generating timer interrupts, and there -* is no forward progress. -* About ten microseconds is the fastest that really works -* on the current generation of host machines. -*/ - -if (!use_icount && limit * s->period <10000 && s->period) { - limit =10000 / s->period; - } - s->limit = limit;if (reload) s->delta = limit;
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 17/28] hw/ptimer: Perform counter wrap around if timer already expired
In reply to Peter MaydellFrom: Dmitry Osipenko <[email protected]>
ptimer_get_count() might be called while QEMU timer already been expired. In that case ptimer would return counter = 0, which might be undesirable in case of polled timer. Do counter wrap around for periodic timer to keep it distributed. In order to achieve more accurate emulation behaviour of certain hardware, don't perform wrap around when in icount mode and return counter = 0 in that case (that doesn't affect polled counter distribution).
Message-id: 4ce381c7d24d85d165ff251d2875d16a4b6a5c04.1464367869.git.digetx@gmail.com
--- hw/core/ptimer.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)
hw/core/ptimer.c +13 -6
@@ -84,14 +84,16 @@ static void ptimer_tick(void *opaque)uint64_t ptimer_get_count (ptimer_state *s) { -int64_t now;uint64_t counter;if (s->enabled) { - now =qemu_clock_get_ns (QEMU_CLOCK_VIRTUAL ); +int64_t now =qemu_clock_get_ns (QEMU_CLOCK_VIRTUAL ); +int64_t next = s->next_event; +bool expired = (now - next >=0 ); +bool oneshot = (s->enabled ==2 ); +/* Figure out the current counter value. */ -if (now - s->next_event >0 - || s->period ==0 ) { +if (s->period ==0 || (expired && (oneshot || use_icount))) {/* Prevent timer underflowing if it should already have triggered. */ counter =0 ;
@@ -103,7 +105,7 @@ uint64_t ptimer_get_count(ptimer_state *s)uint32_t period_frac = s->period_frac;uint64_t period = s->period; -if ((s->enabled ==1 ) && !use_icount && (s->delta * period <10000 )) { +if (!oneshot && (s->delta * period <10000 ) && !use_icount) { period =10000 / s->delta; period_frac =0 ; }
@@ -118,7 +120,7 @@ uint64_t ptimer_get_count(ptimer_state *s)backwards. */ - rem = s->next_event - now; + rem = expired ? now - next : next - now; div = period; clz1 =clz64 (rem);
@@ -138,6 +140,11 @@ uint64_t ptimer_get_count(ptimer_state *s) div +=1 ; } counter = rem / div; + +if (expired && counter !=0 ) { +/* Wrap around periodic counter. */ + counter = s->limit - (counter -1 ) % s->limit; + } } }else { counter = s->delta;
Signature · 1 line
1.9.1
Re: [Qemu-devel] [PULL 17/28] hw/ptimer: Perform counter wrap around if timer already expired
Quoted 63 lines · Peter Maydell
From: Dmitry Osipenko <[email protected]>
ptimer_get_count()might be called while QEMU timer already been expired. In that case ptimer would return counter = 0, which might be undesirable in case of polled timer. Do counter wrap around for periodic timer to keep it distributed. In order to achieve more accurate emulation behaviour of certain hardware, don't perform wrap around when in icount mode and return counter = 0 in that case (that doesn't affect polled counter distribution).Signed-off-by Dmitry Osipenko <[email protected]>Reviewed-by Peter Crosthwaite <[email protected]>Message-id: 4ce381c7d24d85d165ff251d2875d16a4b6a5c04.1464367869.git.digetx@gmail.com
Signed-off-by Peter Maydell <[email protected]>--- hw/core/ptimer.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)hw/core/ptimer.c +8
-6@@ -84,14 +84,16 @@ static void ptimer_tick(void *opaque)uint64_t ptimer_get_count (ptimer_state *s) { -int64_t now;uint64_t counter;if (s->enabled) { - now =qemu_clock_get_ns (QEMU_CLOCK_VIRTUAL ); +int64_t now =qemu_clock_get_ns (QEMU_CLOCK_VIRTUAL ); +int64_t next = s->next_event; +bool expired = (now - next >=0 ); +bool oneshot = (s->enabled ==2 ); +/* Figure out the current counter value. */ -if (now - s->next_event >0 - || s->period ==0 ) { +if (s->period ==0 || (expired && (oneshot || use_icount))) {/* Prevent timer underflowing if it should already have triggered. */ counter =0 ;@@ -103,7 +105,7 @@ uint64_t ptimer_get_count(ptimer_state *s)uint32_t period_frac = s->period_frac;uint64_t period = s->period; -if ((s->enabled ==1 ) && !use_icount && (s->delta * period <10000 )) { +if (!oneshot && (s->delta * period <10000 ) && !use_icount) { period =10000 / s->delta; period_frac =0 ; }@@ -118,7 +120,7 @@ uint64_t ptimer_get_count(ptimer_state *s)backwards. */ - rem = s->next_event - now; + rem = expired ? now - next : next - now; div = period; clz1 =clz64 (rem);@@ -138,6 +140,11 @@ uint64_t ptimer_get_count(ptimer_state *s) div +=1 ;
hw/core/ptimer.c uint64_t ptimer_get_count(ptimer_state *s) · line 150
Quoted 10 lines
hw/core/ptimer.c +5
-0} counter = rem / div; + +if (expired && counter !=0 ) { +/* Wrap around periodic counter. */ + counter = s->limit - (counter -1 ) % s->limit; + } } }else { counter = s->delta;
Hi Peter,
Whilst testing Artyom's qemu-system-sparc patch today, I noticed another regression which I've bisected down to the above commit.
Booting my NetBSD/OpenBSD test images with current git master causes the following warning to appear on the console: "WARNING: negative runtime; monotonic clock has gone backwards".
Could this be a regression or does qemu-system-sparc make an incorrect assumption as to how the timer should work in this scenario?
ATB,
Mark.
Re: [Qemu-devel] [PULL 17/28] hw/ptimer: Perform counter wrap around if timer already expired
Quoted 16 lines · Mark Cave-Ayland
Quoted 10 lines · Peter Maydell
From: Dmitry Osipenko <[email protected]>
ptimer_get_count()might be called while QEMU timer already been expired. In that case ptimer would return counter = 0, which might be undesirable in case of polled timer. Do counter wrap around for periodic timer to keep it distributed. In order to achieve more accurate emulation behaviour of certain hardware, don't perform wrap around when in icount mode and return counter = 0 in that case (that doesn't affect polled counter distribution).Whilst testing Artyom's qemu-system-sparc patch today, I noticed another regression which I've bisected down to the above commit.
Quoted 6 lines
Booting my NetBSD/OpenBSD test images with current git master causes the following warning to appear on the console: "WARNING: negative runtime; monotonic clock has gone backwards".
Could this be a regression or does qemu-system-sparc make an incorrect assumption as to how the timer should work in this scenario?
I'm not sure -- Dmitry ?
thanks
-- PMM
Re: [Qemu-devel] [PULL 17/28] hw/ptimer: Perform counter wrap around if timer already expired
Quoted 22 lines · Peter Maydell
Quoted 20 lines · Mark Cave-Ayland
Quoted 10 lines · Peter Maydell
From: Dmitry Osipenko <[email protected]>
ptimer_get_count()might be called while QEMU timer already been expired. In that case ptimer would return counter = 0, which might be undesirable in case of polled timer. Do counter wrap around for periodic timer to keep it distributed. In order to achieve more accurate emulation behaviour of certain hardware, don't perform wrap around when in icount mode and return counter = 0 in that case (that doesn't affect polled counter distribution).Whilst testing Artyom's qemu-system-sparc patch today, I noticed another regression which I've bisected down to the above commit.
Booting my NetBSD/OpenBSD test images with current git master causes the following warning to appear on the console: "WARNING: negative runtime; monotonic clock has gone backwards".
Quoted 8 lines
Quoted 2 lines
Could this be a regression or does qemu-system-sparc make an incorrect assumption as to how the timer should work in this scenario?
I'm not sure -- Dmitry ?
thanks
-- PMM
The problem could be due to the IRQ being raised after the poll of the wrapped around counter in non-icount mode, so CPU "sees the future". In that case patch should be reverted and reworked. During the review of the patch we decided that it shouldn't be an issue. I'll take a closer look at it and try to reproduce the issue.
Signature · 1 line
Dmitry
Re: [Qemu-devel] [PULL 17/28] hw/ptimer: Perform counter wrap around if timer already expired
Quoted 32 lines · Dmitry Osipenko
Quoted 22 lines · Peter Maydell
Quoted 20 lines · Mark Cave-Ayland
Quoted 10 lines · Peter Maydell
From: Dmitry Osipenko <[email protected]>
ptimer_get_count()might be called while QEMU timer already been expired. In that case ptimer would return counter = 0, which might be undesirable in case of polled timer. Do counter wrap around for periodic timer to keep it distributed. In order to achieve more accurate emulation behaviour of certain hardware, don't perform wrap around when in icount mode and return counter = 0 in that case (that doesn't affect polled counter distribution).Whilst testing Artyom's qemu-system-sparc patch today, I noticed another regression which I've bisected down to the above commit.
Booting my NetBSD/OpenBSD test images with current git master causes the following warning to appear on the console: "WARNING: negative runtime; monotonic clock has gone backwards".
Quoted 8 lines
Quoted 2 lines
Could this be a regression or does qemu-system-sparc make an incorrect assumption as to how the timer should work in this scenario?
I'm not sure -- Dmitry ?
thanks
-- PMM
Quoted 5 lines
The problem could be due to the IRQ being raised after the poll of the wrapped around counter in non-icount mode, so CPU "sees the future". In that case patch should be reverted and reworked. During the review of the patch we decided that it shouldn't be an issue. I'll take a closer look at it and try to reproduce the issue.
Hi Dmitry,
Thanks for looking at this. The reproducer with NetBSD is fairly easy:
./qemu-system-sparc -cdrom NetBSD-6.1.5-sparc.iso -boot d
Hit 1 followed by Enter for the first couple of questions, and by the time you get asked for the terminal settings you should find that the message has been emitted somewhere on the console.
ATB,
Mark.
(repost due to mail client crash - apologies if this is a repeat)
Re: [Qemu-devel] [PULL 17/28] hw/ptimer: Perform counter wrap around if timer already expired
Quoted 51 lines · Mark Cave-Ayland
Quoted 32 lines · Dmitry Osipenko
Quoted 22 lines · Peter Maydell
Quoted 20 lines · Mark Cave-Ayland
Quoted 10 lines · Peter Maydell
From: Dmitry Osipenko <[email protected]>
ptimer_get_count()might be called while QEMU timer already been expired. In that case ptimer would return counter = 0, which might be undesirable in case of polled timer. Do counter wrap around for periodic timer to keep it distributed. In order to achieve more accurate emulation behaviour of certain hardware, don't perform wrap around when in icount mode and return counter = 0 in that case (that doesn't affect polled counter distribution).Whilst testing Artyom's qemu-system-sparc patch today, I noticed another regression which I've bisected down to the above commit.
Booting my NetBSD/OpenBSD test images with current git master causes the following warning to appear on the console: "WARNING: negative runtime; monotonic clock has gone backwards".
Quoted 8 lines
Quoted 2 lines
Could this be a regression or does qemu-system-sparc make an incorrect assumption as to how the timer should work in this scenario?
I'm not sure -- Dmitry ?
thanks
-- PMMQuoted 5 lines
The problem could be due to the IRQ being raised after the poll of the wrapped around counter in non-icount mode, so CPU "sees the future". In that case patch should be reverted and reworked. During the review of the patch we decided that it shouldn't be an issue. I'll take a closer look at it and try to reproduce the issue.
Hi Dmitry,
Thanks for looking at this. The reproducer with NetBSD is fairly easy:
./qemu-system-sparc -cdrom NetBSD-6.1.5-sparc.iso -boot d
Hit 1 followed by Enter for the first couple of questions, and by the time you get asked for the terminal settings you should find that the message has been emitted somewhere on the console.
Quoted 6 lines
ATB,
Mark.
(repost due to mail client crash - apologies if this is a repeat)
Hi Mark,
Thanks for the guide. I successfully reproduced the issue (it's exactly what I supposed in my previous reply) and will send fix for it shortly. Sorry for inconvenience.
Signature · 1 line
Dmitry
[Qemu-devel] [PULL 19/28] hw/ptimer: Support "on the fly" timer mode switch
In reply to Peter MaydellFrom: Dmitry Osipenko <[email protected]>
Allow switching between periodic <-> oneshot modes while timer is running.
Message-id: f030be6e28fbd219e1e8d22297aee367bd9af5bb.1464367869.git.digetx@gmail.com
--- hw/core/ptimer.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
hw/core/ptimer.c +7 -6
@@ -163,16 +163,17 @@ void ptimer_set_count(ptimer_state *s, uint64_t count)void ptimer_run (ptimer_state *s,int oneshot) { -if (s->enabled) { -return ; - } -if (s->period ==0 ) { +bool was_disabled = !s->enabled; + +if (was_disabled && s->period ==0 ) {fprintf (stderr,"Timer with period zero, disabling\n" );return ; } s->enabled = oneshot ?2 :1 ; - s->next_event =qemu_clock_get_ns (QEMU_CLOCK_VIRTUAL ); -ptimer_reload (s); +if (was_disabled) { + s->next_event =qemu_clock_get_ns (QEMU_CLOCK_VIRTUAL ); +ptimer_reload (s); + } }/* Pause a timer. Note that this may cause it to "lose" time, even if it
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 11/28] hw/arm/virt: Reject gic-version=host for non-KVM
In reply to Peter MaydellFrom: Cole Robinson <[email protected]>
If you try to gic-version=host with TCG on a KVM aarch64 host, qemu segfaults, since host requires KVM APIs.
Explicitly reject gic-version=host if KVM is not enabled
https://bugzilla.redhat.com/show_bug.cgi?id=1339977
Message-id: b1b3b0dd143b7995a7f4062966b80a2cf3e3c71e.1464273085.git.crobinso@redhat.com
--- hw/arm/virt.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
hw/arm/virt.c +5 -1
@@ -1153,10 +1153,14 @@ static void machvirt_init(MachineState *machine)* KVM is not available yet */ if (!gic_version) { +if (!kvm_enabled ()) { +error_report ("gic-version=host requires KVM" ); +exit (1 ); + } + gic_version =kvm_arm_vgic_probe ();if (!gic_version) {error_report ("Unable to determine GIC version supported by host" ); -error_printf ("KVM acceleration is probably not supported\n" );exit (1 ); } }
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 13/28] xlnx-zynqmp: Make the RPU subsystem optional
In reply to Peter MaydellFrom: "Edgar E. Iglesias" <[email protected]>
The way we currently model the RPU subsystem is of quite limited use. In addition to that, it causes problems for KVM and for GDB debugging.
Make the RPU optional by adding a has_rpu property and default to having it disabled.
This changes the default setup from having the RPU to not longer having it.
Message-id: [email protected]
--- hw/arm/xlnx-zynqmp.c | 62 +++++++++++++++++++++++++++----------------- include/hw/arm/xlnx-zynqmp.h | 2 ++ 2 files changed, 40 insertions(+), 24 deletions(-)
hw/arm/xlnx-zynqmp.c +38 -24
@@ -83,6 +83,41 @@ static inline int arm_gic_ppi_index(int cpu_nr, int ppi_index)return GIC_NUM_SPI_INTR + cpu_nr *GIC_INTERNAL + ppi_index; } +static void xlnx_zynqmp_create_rpu (XlnxZynqMPState *s,const char *boot_cpu, +Error **errp) +{ +Error *err =NULL ; +int i; + +for (i =0 ; i <XLNX_ZYNQMP_NUM_RPU_CPUS ; i++) { +char *name; + +object_initialize (&s->rpu_cpu[i],sizeof (s->rpu_cpu[i]), +"cortex-r5-" TYPE_ARM_CPU ); +object_property_add_child (OBJECT (s),"rpu-cpu[*]" , +OBJECT (&s->rpu_cpu[i]), &error_abort); + + name =object_get_canonical_path_component (OBJECT (&s->rpu_cpu[i])); +if (strcmp (name, boot_cpu)) { +/* Secondary CPUs start in PSCI powered-down state */ +object_property_set_bool (OBJECT (&s->rpu_cpu[i]), true, +"start-powered-off" , &error_abort); + }else { + s->boot_cpu_ptr = &s->rpu_cpu[i]; + } +g_free (name); + +object_property_set_bool (OBJECT (&s->rpu_cpu[i]), true,"reset-hivecs" , + &error_abort); +object_property_set_bool (OBJECT (&s->rpu_cpu[i]), true,"realized" , + &err); +if (err) { +error_propagate (errp, err); +return ; + } + } +} +static void xlnx_zynqmp_init (Object *obj) {XlnxZynqMPState *s =XLNX_ZYNQMP (obj);
@@ -95,13 +130,6 @@ static void xlnx_zynqmp_init(Object *obj) &error_abort); } -for (i =0 ; i <XLNX_ZYNQMP_NUM_RPU_CPUS ; i++) { -object_initialize (&s->rpu_cpu[i],sizeof (s->rpu_cpu[i]), -"cortex-r5-" TYPE_ARM_CPU ); -object_property_add_child (obj,"rpu-cpu[*]" ,OBJECT (&s->rpu_cpu[i]), - &error_abort); - } - object_property_add_link(obj, "ddr-ram", TYPE_MEMORY_REGION, (Object **)&s->ddr_ram, qdev_prop_allow_set_link_before_realize,
@@ -260,23 +288,8 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)qdev_connect_gpio_out (DEVICE (&s->apu_cpu[i]),1 , irq); } -for (i =0 ; i <XLNX_ZYNQMP_NUM_RPU_CPUS ; i++) { -char *name; - - name =object_get_canonical_path_component (OBJECT (&s->rpu_cpu[i])); -if (strcmp (name, boot_cpu)) { -/* Secondary CPUs start in PSCI powered-down state */ -object_property_set_bool (OBJECT (&s->rpu_cpu[i]), true, -"start-powered-off" , &error_abort); - }else { - s->boot_cpu_ptr = &s->rpu_cpu[i]; - } -g_free (name); - -object_property_set_bool (OBJECT (&s->rpu_cpu[i]), true,"reset-hivecs" , - &error_abort); -object_property_set_bool (OBJECT (&s->rpu_cpu[i]), true,"realized" , - &err); +if (s->has_rpu) { +xlnx_zynqmp_create_rpu (s, boot_cpu, &err);if (err) {error_propagate (errp, err);return ;
@@ -373,6 +386,7 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)static Property xlnx_zynqmp_props[] = {DEFINE_PROP_STRING ("boot-cpu" , XlnxZynqMPState, boot_cpu),DEFINE_PROP_BOOL ("secure" , XlnxZynqMPState, secure, false), +DEFINE_PROP_BOOL ("has_rpu" , XlnxZynqMPState, has_rpu, false),DEFINE_PROP_END_OF_LIST () };
include/hw/arm/xlnx-zynqmp.h +2 -0
@@ -87,6 +87,8 @@ typedef struct XlnxZynqMPState {/* Has the ARM Security extensions? */ bool secure; +/* Has the RPU subsystem? */ +bool has_rpu; } XlnxZynqMPState;#define XLNX_ZYNQMP_H
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 14/28] xlnx-zynqmp: Delay realization of GIC until post CPU realization
In reply to Peter MaydellFrom: "Edgar E. Iglesias" <[email protected]>
Delay the realization of the GIC until after CPUs are realized. This is needed for KVM as the in-kernel GIC model will fail if it is realized with no available CPUs.
Message-id: [email protected]
--- hw/arm/xlnx-zynqmp.c | 56 +++++++++++++++++++++++++++++----------------------- 1 file changed, 31 insertions(+), 25 deletions(-)
hw/arm/xlnx-zynqmp.c +31 -25
@@ -224,33 +224,9 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)qdev_prop_set_uint32 (DEVICE (&s->gic),"num-irq" ,GIC_NUM_SPI_INTR +32 );qdev_prop_set_uint32 (DEVICE (&s->gic),"revision" ,2 );qdev_prop_set_uint32 (DEVICE (&s->gic),"num-cpu" ,XLNX_ZYNQMP_NUM_APU_CPUS ); -object_property_set_bool (OBJECT (&s->gic), true,"realized" , &err); -if (err) { -error_propagate (errp, err); -return ; - } -assert (ARRAY_SIZE (xlnx_zynqmp_gic_regions) ==XLNX_ZYNQMP_GIC_REGIONS ); -for (i =0 ; i <XLNX_ZYNQMP_GIC_REGIONS ; i++) { -SysBusDevice *gic =SYS_BUS_DEVICE (&s->gic); -const XlnxZynqMPGICRegion *r = &xlnx_zynqmp_gic_regions[i]; -MemoryRegion *mr =sysbus_mmio_get_region (gic, r->region_index); -uint32_t addr = r->address; -int j; - -sysbus_mmio_map (gic, r->region_index, addr); - -for (j =0 ; j <XLNX_ZYNQMP_GIC_ALIASES ; j++) { -MemoryRegion *alias = &s->gic_mr[i][j]; - - addr +=XLNX_ZYNQMP_GIC_REGION_SIZE ; -memory_region_init_alias (alias,OBJECT (s),"zynqmp-gic-alias" , mr, -0 ,XLNX_ZYNQMP_GIC_REGION_SIZE ); -memory_region_add_subregion (system_memory, addr, alias); - } - } +/* Realize APUs before realizing the GIC. KVM requires this. */ for (i =0 ; i <XLNX_ZYNQMP_NUM_APU_CPUS ; i++) { -qemu_irq irq;char *name; object_property_set_int(OBJECT(&s->apu_cpu[i]), QEMU_PSCI_CONDUIT_SMC,
@@ -276,6 +252,36 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)error_propagate (errp, err);return ; } + } + +object_property_set_bool (OBJECT (&s->gic), true,"realized" , &err); +if (err) { +error_propagate (errp, err); +return ; + } + +assert (ARRAY_SIZE (xlnx_zynqmp_gic_regions) ==XLNX_ZYNQMP_GIC_REGIONS ); +for (i =0 ; i <XLNX_ZYNQMP_GIC_REGIONS ; i++) { +SysBusDevice *gic =SYS_BUS_DEVICE (&s->gic); +const XlnxZynqMPGICRegion *r = &xlnx_zynqmp_gic_regions[i]; +MemoryRegion *mr =sysbus_mmio_get_region (gic, r->region_index); +uint32_t addr = r->address; +int j; + +sysbus_mmio_map (gic, r->region_index, addr); + +for (j =0 ; j <XLNX_ZYNQMP_GIC_ALIASES ; j++) { +MemoryRegion *alias = &s->gic_mr[i][j]; + + addr +=XLNX_ZYNQMP_GIC_REGION_SIZE ; +memory_region_init_alias (alias,OBJECT (s),"zynqmp-gic-alias" , mr, +0 ,XLNX_ZYNQMP_GIC_REGION_SIZE ); +memory_region_add_subregion (system_memory, addr, alias); + } + } + +for (i =0 ; i <XLNX_ZYNQMP_NUM_APU_CPUS ; i++) { +qemu_irq irq; sysbus_connect_irq(SYS_BUS_DEVICE(&s->gic), i, qdev_get_gpio_in(DEVICE(&s->apu_cpu[i]),
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 20/28] hw/ptimer: Introduce ptimer_get_limit
In reply to Peter MaydellFrom: Dmitry Osipenko <[email protected]>
Currently ptimer users are used to store copy of the limit value, because ptimer doesn't provide facility to retrieve the limit. Let's provide it.
Message-id: 8f1fa9f90d8dbf8086fb02f3b4835eaeb4089cf6.1464367869.git.digetx@gmail.com
--- hw/core/ptimer.c | 5 +++++ include/hw/ptimer.h | 1 + 2 files changed, 6 insertions(+)
hw/core/ptimer.c +5 -0
@@ -225,6 +225,11 @@ void ptimer_set_limit(ptimer_state *s, uint64_t limit, int reload) } } +uint64_t ptimer_get_limit (ptimer_state *s) +{ +return s->limit; +} +const VMStateDescription vmstate_ptimer = { .name ="ptimer" , .version_id =1 ,
include/hw/ptimer.h +1 -0
@@ -19,6 +19,7 @@ typedef void (*ptimer_cb)(void *opaque);ptimer_state *ptimer_init (QEMUBH *bh);void ptimer_set_period (ptimer_state *s,int64_t period);void ptimer_set_freq (ptimer_state *s,uint32_t freq); +uint64_t ptimer_get_limit (ptimer_state *s);void ptimer_set_limit (ptimer_state *s,uint64_t limit,int reload);uint64_t ptimer_get_count (ptimer_state *s);void ptimer_set_count (ptimer_state *s,uint64_t count);
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 12/28] xlnx-zynqmp: Add a secure prop to en/disable ARM Security Extensions
In reply to Peter MaydellFrom: "Edgar E. Iglesias" <[email protected]>
Add a secure prop to en/disable ARM Security Extensions. This is particularly useful for KVM runs.
Default to disabled to match the behavior of KVM.
This changes the default setup from having the ARM Security Extensions to not longer having them.
Message-id: [email protected]
--- hw/arm/xlnx-zynqmp.c | 3 +++ include/hw/arm/xlnx-zynqmp.h | 3 +++ 2 files changed, 6 insertions(+)
hw/arm/xlnx-zynqmp.c +3 -0
@@ -238,6 +238,8 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp) }g_free (name); +object_property_set_bool (OBJECT (&s->apu_cpu[i]), + s->secure,"has_el3" ,NULL );object_property_set_int (OBJECT (&s->apu_cpu[i]),GIC_BASE_ADDR ,"reset-cbar" , &error_abort); object_property_set_bool(OBJECT(&s->apu_cpu[i]), true, "realized",
@@ -370,6 +372,7 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)static Property xlnx_zynqmp_props[] = {DEFINE_PROP_STRING ("boot-cpu" , XlnxZynqMPState, boot_cpu), +DEFINE_PROP_BOOL ("secure" , XlnxZynqMPState, secure, false),DEFINE_PROP_END_OF_LIST () };
include/hw/arm/xlnx-zynqmp.h +3 -0
@@ -84,6 +84,9 @@ typedef struct XlnxZynqMPState {char *boot_cpu;ARMCPU *boot_cpu_ptr; + +/* Has the ARM Security extensions? */ +bool secure; } XlnxZynqMPState;#define XLNX_ZYNQMP_H
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 04/28] target-arm: Don't try to set ESR IL bit in arm_cpu_do_interrupt_aarch64()
In reply to Peter MaydellRemove some incorrect code from arm_cpu_do_interrupt_aarch64() which attempts to set the IL bit in the syndrome register based on the value of env->thumb. This is wrong in several ways:
* IL doesn't indicate Thumb-vs-ARM, it indicates instruction length (which may be 16 or 32 for Thumb and is always 32 for ARM)
* not every syndrome format uses IL like this -- for some IL is always set, and for some it is always clear
* the code is changing esr_el[new_el] even for interrupt entry, which is not supposed to modify ESR_ELx at all
Delete the code, and instead rely on the syndrome value in env->exception.syndrome having already been set up with the correct value of IL.
Message-id: [email protected]
--- target-arm/helper.c | 3 --- 1 file changed, 3 deletions(-)
target-arm/helper.c +0 -3
@@ -6365,9 +6365,6 @@ static void arm_cpu_do_interrupt_aarch64(CPUState *cs) env->elr_el[new_el] = env->pc; }else { env->banked_spsr[aarch64_banked_spsr_index (new_el)] =cpsr_read (env); -if (!env->thumb) { - env->cp15.esr_el[new_el] |=1 <<25 ; - } env->elr_el[new_el] = env->regs[15 ];aarch64_sync_32_to_64 (env);
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 05/28] hw/arm/virt: fix limit of 64-bit ACPI/ECAM PCI MMIO range
In reply to Peter MaydellFrom: Ard Biesheuvel <[email protected]>
Set the MMIO range limit field to 'base + size - 1' as required.
Message-id: [email protected]
--- hw/arm/virt-acpi-build.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
hw/arm/virt-acpi-build.c +2 -1
@@ -231,7 +231,8 @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap,aml_append (rbuf,aml_qword_memory (AML_POS_DECODE ,AML_MIN_FIXED ,AML_MAX_FIXED ,AML_NON_CACHEABLE ,AML_READ_WRITE ,0x0000 , - base_mmio_high, base_mmio_high,0x0000 , + base_mmio_high, + base_mmio_high + size_mmio_high -1 ,0x0000 , size_mmio_high)); }
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 08/28] hw/arm/virt-acpi-build: Add PMU IRQ number in ACPI table
In reply to Peter MaydellFrom: Shannon Zhao <[email protected]>
Add PMU IRQ number in ACPI table, then we can use PMU in guest through ACPI.
Message-id: [email protected]
--- hw/arm/virt-acpi-build.c | 4 ++++ 1 file changed, 4 insertions(+)
hw/arm/virt-acpi-build.c +4 -0
@@ -539,6 +539,10 @@ build_madt(GArray *table_data, GArray *linker, VirtGuestInfo *guest_info) gicc->arm_mpidr = armcpu->mp_affinity; gicc->uid = i; gicc->flags =cpu_to_le32 (ACPI_GICC_ENABLED ); + +if (armcpu->has_pmu) { + gicc->performance_interrupt =cpu_to_le32 (PPI (VIRTUAL_PMU_IRQ )); + } }if (guest_info->gic_version ==3 ) {
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 09/28] hw/intc/gic: RAZ/WI non-sec access to sec interrupts
In reply to Peter MaydellFrom: Jens Wiklander <[email protected]>
Treat non-secure accesses to registers and bits in registers of secure interrupts as RAZ/WI.
Message-id: [email protected]
--- hw/intc/arm_gic.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 62 insertions(+), 6 deletions(-)
hw/intc/arm_gic.c +62 -6
@@ -661,6 +661,11 @@ static uint32_t gic_dist_readb(void *opaque, hwaddr offset, MemTxAttrs attrs) goto bad_reg; res =0 ;for (i =0 ; i <8 ; i++) { +if (s->security_extn && !attrs.secure && + !GIC_TEST_GROUP (irq + i,1 << cpu)) { +continue ;/* Ignore Non-secure access of Group0 IRQ */ + } +if (GIC_TEST_ENABLED (irq + i, cm)) { res |= (1 << i); }
@@ -677,6 +682,11 @@ static uint32_t gic_dist_readb(void *opaque, hwaddr offset, MemTxAttrs attrs) res =0 ; mask = (irq <GIC_INTERNAL ) ? cm :ALL_CPU_MASK ;for (i =0 ; i <8 ; i++) { +if (s->security_extn && !attrs.secure && + !GIC_TEST_GROUP (irq + i,1 << cpu)) { +continue ;/* Ignore Non-secure access of Group0 IRQ */ + } +if (gic_test_pending (s, irq + i, mask)) { res |= (1 << i); }
@@ -689,6 +699,11 @@ static uint32_t gic_dist_readb(void *opaque, hwaddr offset, MemTxAttrs attrs) res =0 ; mask = (irq <GIC_INTERNAL ) ? cm :ALL_CPU_MASK ;for (i =0 ; i <8 ; i++) { +if (s->security_extn && !attrs.secure && + !GIC_TEST_GROUP (irq + i,1 << cpu)) { +continue ;/* Ignore Non-secure access of Group0 IRQ */ + } +if (GIC_TEST_ACTIVE (irq + i, mask)) { res |= (1 << i); }
@@ -722,6 +737,11 @@ static uint32_t gic_dist_readb(void *opaque, hwaddr offset, MemTxAttrs attrs) goto bad_reg; res =0 ;for (i =0 ; i <4 ; i++) { +if (s->security_extn && !attrs.secure && + !GIC_TEST_GROUP (irq + i,1 << cpu)) { +continue ;/* Ignore Non-secure access of Group0 IRQ */ + } +if (GIC_TEST_MODEL (irq + i)) res |= (1 << (i *2 ));if (GIC_TEST_EDGE_TRIGGER (irq + i))
@@ -742,7 +762,12 @@ static uint32_t gic_dist_readb(void *opaque, hwaddr offset, MemTxAttrs attrs)/* GICD_SPENDSGIRn */ } - res = s->sgi_pending[irq][cpu]; +if (s->security_extn && !attrs.secure && + !GIC_TEST_GROUP (irq,1 << cpu)) { + res =0 ;/* Ignore Non-secure access of Group0 IRQ */ + }else { + res = s->sgi_pending[irq][cpu]; + } }else if (offset <0xfd0 ) { goto bad_reg; }else if (offset <0x1000 ) {
@@ -862,6 +887,11 @@ static void gic_dist_writeb(void *opaque, hwaddr offset, (irq <GIC_INTERNAL ) ? (1 << cpu) :GIC_TARGET (irq + i);int cm = (irq <GIC_INTERNAL ) ? (1 << cpu) :ALL_CPU_MASK ; +if (s->security_extn && !attrs.secure && + !GIC_TEST_GROUP (irq + i,1 << cpu)) { +continue ;/* Ignore Non-secure access of Group0 IRQ */ + } +if (!GIC_TEST_ENABLED (irq + i, cm)) {DPRINTF ("Enabled IRQ %d\n" , irq + i);trace_gic_enable_irq (irq + i);
@@ -889,6 +919,11 @@ static void gic_dist_writeb(void *opaque, hwaddr offset,if (value & (1 << i)) {int cm = (irq <GIC_INTERNAL ) ? (1 << cpu) :ALL_CPU_MASK ; +if (s->security_extn && !attrs.secure && + !GIC_TEST_GROUP (irq + i,1 << cpu)) { +continue ;/* Ignore Non-secure access of Group0 IRQ */ + } +if (GIC_TEST_ENABLED (irq + i, cm)) {DPRINTF ("Disabled IRQ %d\n" , irq + i);trace_gic_disable_irq (irq + i);
@@ -907,6 +942,11 @@ static void gic_dist_writeb(void *opaque, hwaddr offset,for (i =0 ; i <8 ; i++) {if (value & (1 << i)) { +if (s->security_extn && !attrs.secure && + !GIC_TEST_GROUP (irq + i,1 << cpu)) { +continue ;/* Ignore Non-secure access of Group0 IRQ */ + } +GIC_SET_PENDING (irq + i,GIC_TARGET (irq + i)); } }
@@ -920,6 +960,11 @@ static void gic_dist_writeb(void *opaque, hwaddr offset, }for (i =0 ; i <8 ; i++) { +if (s->security_extn && !attrs.secure && + !GIC_TEST_GROUP (irq + i,1 << cpu)) { +continue ;/* Ignore Non-secure access of Group0 IRQ */ + } +/* ??? This currently clears the pending bit for all CPUs, even for per-CPU interrupts. It's unclear whether this is the corect behavior. */
@@ -960,6 +1005,11 @@ static void gic_dist_writeb(void *opaque, hwaddr offset,if (irq <GIC_NR_SGIS ) value |=0xaa ;for (i =0 ; i <4 ; i++) { +if (s->security_extn && !attrs.secure && + !GIC_TEST_GROUP (irq + i,1 << cpu)) { +continue ;/* Ignore Non-secure access of Group0 IRQ */ + } +if (s->revision ==REV_11MPCORE || s->revision ==REV_NVIC ) {if (value & (1 << (i *2 ))) {GIC_SET_MODEL (irq + i);
@@ -983,9 +1033,12 @@ static void gic_dist_writeb(void *opaque, hwaddr offset, } irq = (offset -0xf10 ); - s->sgi_pending[irq][cpu] &= ~value; -if (s->sgi_pending[irq][cpu] ==0 ) { -GIC_CLEAR_PENDING (irq,1 << cpu); +if (!s->security_extn || attrs.secure || +GIC_TEST_GROUP (irq,1 << cpu)) { + s->sgi_pending[irq][cpu] &= ~value; +if (s->sgi_pending[irq][cpu] ==0 ) { +GIC_CLEAR_PENDING (irq,1 << cpu); + } } }else if (offset <0xf30 ) {/* GICD_SPENDSGIRn */
@@ -994,8 +1047,11 @@ static void gic_dist_writeb(void *opaque, hwaddr offset, } irq = (offset -0xf20 ); -GIC_SET_PENDING (irq,1 << cpu); - s->sgi_pending[irq][cpu] |= value; +if (!s->security_extn || attrs.secure || +GIC_TEST_GROUP (irq,1 << cpu)) { +GIC_SET_PENDING (irq,1 << cpu); + s->sgi_pending[irq][cpu] |= value; + } }else { goto bad_reg; }
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 23/28] hw/char: QOM'ify digic-uart model
In reply to Peter MaydellFrom: xiaoqiang zhao <[email protected]>
* drop qemu_char_get_next_serial and use chardev prop
* change affected board code to use the new way
Message-id: [email protected]
--- hw/arm/digic.c | 2 ++ hw/char/digic-uart.c | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-)
hw/arm/digic.c +2 -0
@@ -23,6 +23,7 @@#include "qemu/osdep.h" #include "qapi/error.h" #include "hw/arm/digic.h" +#include "sysemu/sysemu.h" #define DIGIC4_TIMER_BASE (n) (0xc0210000 + (n) * 0x100)
@@ -84,6 +85,7 @@ static void digic_realize(DeviceState *dev, Error **errp)sysbus_mmio_map (sbd,0 ,DIGIC4_TIMER_BASE (i)); } +qdev_prop_set_chr (DEVICE (&s->uart),"chardev" , serial_hds[0 ]);object_property_set_bool (OBJECT (&s->uart), true,"realized" , &err);if (err !=NULL ) {error_propagate (errp, err);
hw/char/digic-uart.c +6 -4
@@ -145,8 +145,6 @@ static void digic_uart_realize(DeviceState *dev, Error **errp) {DigicUartState *s =DIGIC_UART (dev); -/* FIXME use a qdev chardev prop instead of qemu_char_get_next_serial() */ - s->chr =qemu_char_get_next_serial ();if (s->chr) {qemu_chr_add_handlers (s->chr, uart_can_rx, uart_rx, uart_event, s); }
@@ -172,6 +170,11 @@ static const VMStateDescription vmstate_digic_uart = { } }; +static Property digic_uart_properties[] = { +DEFINE_PROP_CHR ("chardev" , DigicUartState, chr), +DEFINE_PROP_END_OF_LIST (), +}; +static void digic_uart_class_init (ObjectClass *klass,void *data) {DeviceClass *dc =DEVICE_CLASS (klass);
@@ -179,8 +182,7 @@ static void digic_uart_class_init(ObjectClass *klass, void *data) dc->realize = digic_uart_realize; dc->reset = digic_uart_reset; dc->vmsd = &vmstate_digic_uart; -/* Reason: realize() method uses qemu_char_get_next_serial() */ - dc->cannot_instantiate_with_device_add_yet = true; + dc->props = digic_uart_properties; }static const TypeInfo digic_uart_info = {
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 03/28] target-arm: Set IL bit in syndromes for insn abort, watchpoint, swstep
In reply to Peter MaydellFor some exception syndrome types, the IL bit should always be set. This includes the instruction abort, watchpoint and software step syndrome types; add the missing ARM_EL_IL bit to the syndrome values returned by syn_insn_abort(), syn_swstep() and syn_watchpoint().
Message-id: [email protected]
--- target-arm/internals.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
target-arm/internals.h +3 -3
@@ -367,7 +367,7 @@ static inline uint32_t syn_fp_access_trap(int cv, int cond, bool is_16bit)static inline uint32_t syn_insn_abort (int same_el,int ea,int s1ptw,int fsc) {return (EC_INSNABORT <<ARM_EL_EC_SHIFT ) | (same_el <<ARM_EL_EC_SHIFT ) - | (ea <<9 ) | (s1ptw <<7 ) | fsc; + |ARM_EL_IL | (ea <<9 ) | (s1ptw <<7 ) | fsc; } static inline uint32_t syn_data_abort_no_iss(int same_el,
@@ -396,13 +396,13 @@ static inline uint32_t syn_data_abort_with_iss(int same_el,static inline uint32_t syn_swstep (int same_el,int isv,int ex) {return (EC_SOFTWARESTEP <<ARM_EL_EC_SHIFT ) | (same_el <<ARM_EL_EC_SHIFT ) - | (isv <<24 ) | (ex <<6 ) |0x22 ; + |ARM_EL_IL | (isv <<24 ) | (ex <<6 ) |0x22 ; }static inline uint32_t syn_watchpoint (int same_el,int cm,int wnr) {return (EC_WATCHPOINT <<ARM_EL_EC_SHIFT ) | (same_el <<ARM_EL_EC_SHIFT ) - | (cm <<8 ) | (wnr <<6 ) |0x22 ; + |ARM_EL_IL | (cm <<8 ) | (wnr <<6 ) |0x22 ; }static inline uint32_t syn_breakpoint (int same_el)
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 06/28] target-arm: kvm64: set guest PMUv3 feature bit if supported
In reply to Peter MaydellFrom: Shannon Zhao <[email protected]>
Check if kvm supports guest PMUv3. If so, set the corresponding feature bit for vcpu.
Message-id: [email protected]
--- target-arm/cpu.h | 2 ++ target-arm/kvm64.c | 5 +++++ 2 files changed, 7 insertions(+)
target-arm/cpu.h +2 -0
@@ -574,6 +574,8 @@ struct ARMCPU {bool powered_off;/* CPU has security extension */ bool has_el3; +/* CPU has PMU (Performance Monitor Unit) */ +bool has_pmu;/* CPU has memory protection unit */ bool has_mpu;
target-arm/kvm64.c +5 -0
@@ -461,6 +461,11 @@ int kvm_arch_init_vcpu(CPUState *cs)if (!arm_feature (&cpu->env,ARM_FEATURE_AARCH64 )) { cpu->kvm_init_features[0 ] |=1 <<KVM_ARM_VCPU_EL1_32BIT ; } +if (kvm_irqchip_in_kernel () && +kvm_check_extension (cs->kvm_state,KVM_CAP_ARM_PMU_V3 )) { + cpu->has_pmu = true; + cpu->kvm_init_features[0 ] |=1 <<KVM_ARM_VCPU_PMU_V3 ; + }/* Do KVM_ARM_VCPU_INIT ioctl */ ret =kvm_arm_vcpu_init (cs);
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 24/28] hw/char: QOM'ify stm32f2xx_usart model
In reply to Peter MaydellFrom: xiaoqiang zhao <[email protected]>
* drop qemu_char_get_next_serial and use chardev prop
* change affected board code to use the new way
Message-id: [email protected]
--- hw/arm/stm32f205_soc.c | 1 + hw/char/stm32f2xx_usart.c | 15 +++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-)
hw/arm/stm32f205_soc.c +1 -0
@@ -107,6 +107,7 @@ static void stm32f205_soc_realize(DeviceState *dev_soc, Error **errp)/* Attach UART (uses USART registers) and USART controllers */ for (i =0 ; i <STM_NUM_USARTS ; i++) { usartdev =DEVICE (&(s->usart[i])); +qdev_prop_set_chr (usartdev,"chardev" , i <MAX_SERIAL_PORTS ? serial_hds[i] :NULL );object_property_set_bool (OBJECT (&s->usart[i]), true,"realized" , &err);if (err !=NULL ) {error_propagate (errp, err);
hw/char/stm32f2xx_usart.c +11 -4
@@ -190,6 +190,11 @@ static const MemoryRegionOps stm32f2xx_usart_ops = { .endianness = DEVICE_NATIVE_ENDIAN, }; +static Property stm32f2xx_usart_properties[] = { +DEFINE_PROP_CHR ("chardev" , STM32F2XXUsartState, chr), +DEFINE_PROP_END_OF_LIST (), +}; +static void stm32f2xx_usart_init (Object *obj) {STM32F2XXUsartState *s =STM32F2XX_USART (obj);
@@ -199,9 +204,11 @@ static void stm32f2xx_usart_init(Object *obj)memory_region_init_io (&s->mmio, obj, &stm32f2xx_usart_ops, s,TYPE_STM32F2XX_USART ,0x2000 );sysbus_init_mmio (SYS_BUS_DEVICE (obj), &s->mmio); +} -/* FIXME use a qdev chardev prop instead of qemu_char_get_next_serial() */ - s->chr =qemu_char_get_next_serial (); +static void stm32f2xx_usart_realize (DeviceState *dev,Error **errp) +{ +STM32F2XXUsartState *s =STM32F2XX_USART (dev);if (s->chr) { qemu_chr_add_handlers(s->chr, stm32f2xx_usart_can_receive,
@@ -214,8 +221,8 @@ static void stm32f2xx_usart_class_init(ObjectClass *klass, void *data)DeviceClass *dc =DEVICE_CLASS (klass); dc->reset = stm32f2xx_usart_reset; -/* Reason: instance_init() method uses qemu_char_get_next_serial() */ - dc->cannot_instantiate_with_device_add_yet = true; + dc->props = stm32f2xx_usart_properties; + dc->realize = stm32f2xx_usart_realize; }static const TypeInfo stm32f2xx_usart_info = {
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 26/28] char: get rid of qemu_char_get_next_serial
In reply to Peter MaydellFrom: xiaoqiang zhao <[email protected]>
since there is no user of qemu_char_get_next_serial any more, it's time to let it go away.
Message-id: [email protected]
--- include/sysemu/char.h | 1 - qemu-char.c | 16 ---------------- 2 files changed, 17 deletions(-)
include/sysemu/char.h +0 -1
@@ -403,7 +403,6 @@ void register_char_driver(const char *name, ChardevBackendKind kind,extern int term_escape_char; -CharDriverState *qemu_char_get_next_serial (void );/* console.c */ typedef CharDriverState *(VcHandler )(ChardevVC *vc,Error **errp);
qemu-char.c +0 -16
@@ -4088,22 +4088,6 @@ CharDriverState *qemu_chr_find(const char *name)return NULL ; } -/* Get a character (serial) device interface. */ -CharDriverState *qemu_char_get_next_serial (void ) -{ -static int next_serial; -CharDriverState *chr; - -/* FIXME: This function needs to go away: use chardev properties! */ - -while (next_serial <MAX_SERIAL_PORTS && serial_hds[next_serial]) { - chr = serial_hds[next_serial++]; -qemu_chr_fe_claim_no_fail (chr); -return chr; - } -return NULL ; -} -QemuOptsList qemu_chardev_opts = { .name ="chardev" , .implied_opt_name ="backend" ,
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 28/28] zynqmp: Add the ZCU102 board
In reply to Peter MaydellFrom: Alistair Francis <[email protected]>
Most Zynq UltraScale+ users will be targetting and using the ZCU102 board instead of the development focused EP108. To make our QEMU machine names clearer add a ZCU102 machine model.
Message-id: cc82eec026b2febfca252d73362bb7084616c1ad.1464213234.git.alistair.francis@xilinx.com
--- hw/arm/xlnx-ep108.c | 8 ++++++++ 1 file changed, 8 insertions(+)
hw/arm/xlnx-ep108.c +8 -0
@@ -114,3 +114,11 @@ static void xlnx_ep108_machine_init(MachineClass *mc) } DEFINE_MACHINE("xlnx-ep108", xlnx_ep108_machine_init) + +static void xlnx_zcu102_machine_init (MachineClass *mc) +{ + mc->desc ="Xilinx ZynqMP ZCU102 board" ; + mc->init = xlnx_ep108_init; +} + +DEFINE_MACHINE ("xlnx-zcu102" , xlnx_zcu102_machine_init)
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 07/28] hw/arm/virt: Add PMU node for virt machine
In reply to Peter MaydellFrom: Shannon Zhao <[email protected]>
Add a virtual PMU device for virt machine while use PPI 7 for PMU overflow interrupt number.
Message-id: [email protected]
--- hw/arm/virt.c | 33 +++++++++++++++++++++++++++++++++ include/hw/arm/virt.h | 4 ++++ include/sysemu/kvm.h | 1 + stubs/kvm.c | 5 +++++ target-arm/kvm64.c | 41 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 84 insertions(+)
hw/arm/virt.c +33 -0
@@ -436,6 +436,37 @@ static void fdt_add_gic_node(VirtBoardInfo *vbi, int type)qemu_fdt_setprop_cell (vbi->fdt,"/intc" ,"phandle" , vbi->gic_phandle); } +static void fdt_add_pmu_nodes (const VirtBoardInfo *vbi,int gictype) +{ +CPUState *cpu; +ARMCPU *armcpu; +uint32_t irqflags =GIC_FDT_IRQ_FLAGS_LEVEL_HI ; + +CPU_FOREACH (cpu) { + armcpu =ARM_CPU (cpu); +if (!armcpu->has_pmu || + !kvm_arm_pmu_create (cpu,PPI (VIRTUAL_PMU_IRQ ))) { +return ; + } + } + +if (gictype ==2 ) { + irqflags =deposit32 (irqflags,GIC_FDT_IRQ_PPI_CPU_START , +GIC_FDT_IRQ_PPI_CPU_WIDTH , + (1 << vbi->smp_cpus) -1 ); + } + + armcpu =ARM_CPU (qemu_get_cpu (0 )); +qemu_fdt_add_subnode (vbi->fdt,"/pmu" ); +if (arm_feature (&armcpu->env,ARM_FEATURE_V8 )) { +const char compat[] ="arm,armv8-pmuv3" ; +qemu_fdt_setprop (vbi->fdt,"/pmu" ,"compatible" , + compat,sizeof (compat)); +qemu_fdt_setprop_cells (vbi->fdt,"/pmu" ,"interrupts" , +GIC_FDT_IRQ_TYPE_PPI ,VIRTUAL_PMU_IRQ , irqflags); + } +} +static void create_v2m (VirtBoardInfo *vbi,qemu_irq *pic) {int i;
@@ -1254,6 +1285,8 @@ static void machvirt_init(MachineState *machine)create_gic (vbi, pic, gic_version, vms->secure); +fdt_add_pmu_nodes (vbi, gic_version); +create_uart (vbi, pic,VIRT_UART , sysmem);if (vms->secure) {
include/hw/arm/virt.h +4 -0
@@ -41,6 +41,10 @@#define ARCH_TIMER_NS_EL1_IRQ 14#define ARCH_TIMER_NS_EL2_IRQ 10 +#define VIRTUAL_PMU_IRQ 7 + +#define PPI (irq) ((irq) + 16) +enum {VIRT_FLASH ,VIRT_MEM ,
include/sysemu/kvm.h +1 -0
@@ -527,4 +527,5 @@ int kvm_set_one_reg(CPUState *cs, uint64_t id, void *source);* Returns: 0 on success, or a negative errno on failure. */ int kvm_get_one_reg (CPUState *cs,uint64_t id,void *target); +int kvm_arm_pmu_create (CPUState *cs,int irq);#endif
stubs/kvm.c +5 -0
@@ -6,3 +6,8 @@ int kvm_arch_irqchip_create(MachineState *ms, KVMState *s) {return 0 ; } + +int kvm_arm_pmu_create (CPUState *cs,int irq) +{ +return 0 ; +}
target-arm/kvm64.c +41 -0
47 lines not on this page · raw message
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 01/28] target-arm: Add the HSTR_EL2 register
In reply to Peter MaydellFrom: Alistair Francis <[email protected]>
Add the Hypervisor System Trap Register for EL2.
This register is used early in the Linux boot and without it the kernel aborts with a "Synchronous Abort" error.
Message-id: ea5aae4b10283de4705b864fe9d4bd2eaddaacae.1463174342.git.alistair.francis@xilinx.com
--- target-arm/cpu.h | 1 + target-arm/helper.c | 7 +++++++ 2 files changed, 8 insertions(+)
target-arm/cpu.h +1 -0
@@ -278,6 +278,7 @@ typedef struct CPUARMState {uint64_t far_el[4 ]; };uint64_t hpfar_el2; +uint64_t hstr_el2; union { /* Translation result. */ struct { uint64_t _unused_par_0;
target-arm/helper.c +7 -0
@@ -3471,6 +3471,9 @@ static const ARMCPRegInfo el3_no_el2_cp_reginfo[] = { .opc0 = 3, .opc1 = 4, .crn = 6, .crm = 0, .opc2 = 4, .access = PL2_RW, .accessfn = access_el3_aa32ns_aa64any, .type = ARM_CP_CONST, .resetvalue = 0 }, + { .name = "HSTR_EL2", .state = ARM_CP_STATE_BOTH, + .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 3, + .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, REGINFO_SENTINEL };
@@ -3706,6 +3709,10 @@ static const ARMCPRegInfo el2_cp_reginfo[] = { .opc0 = 3, .opc1 = 4, .crn = 6, .crm = 0, .opc2 = 4, .access = PL2_RW, .fieldoffset = offsetof(CPUARMState, cp15.hpfar_el2) }, + { .name = "HSTR_EL2", .state = ARM_CP_STATE_BOTH, + .cp = 15, .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 3, + .access = PL2_RW, + .fieldoffset = offsetof(CPUARMState, cp15.hstr_el2) }, REGINFO_SENTINEL };
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 27/28] target-arm: Fix TTBR selecting logic on AArch32 Stage 2 translation
In reply to Peter MaydellFrom: Sergey Sorokin <[email protected]>
Address size is 40-bit for the AArch32 stage 2 translation, and t0sz can be negative (from -8 to 7),
so we need to adjust it to use the existing TTBR selecting logic.
Message-id: [email protected]
--- target-arm/helper.c | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-)
target-arm/helper.c +22 -16
@@ -7279,7 +7279,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address,target_ulong page_size;uint32_t attrs;int32_t stride =9 ; -int32_t va_size; +int32_t addrsize;int inputsize;int32_t tbi =0 ;TCR *tcr =regime_tcr (env, mmu_idx);
@@ -7287,6 +7287,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address,uint32_t el =regime_el (env, mmu_idx);bool ttbr1_valid = true;uint64_t descaddrmask; +bool aarch64 =arm_el_is_aa64 (env, el);/* TODO: * This code does not handle the different format TCR for VTCR_EL2.
@@ -7294,9 +7295,9 @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address,* Attribute and permission bit handling should also be checked when adding * support for those page table walks. */ -if (arm_el_is_aa64 (env, el)) { +if (aarch64) { level =0 ; - va_size =64 ; + addrsize =64 ;if (el >1 ) {if (mmu_idx != ARMMMUIdx_S2NS) { tbi =extract64 (tcr->raw_tcr,20 ,1 );
@@ -7318,7 +7319,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address, } }else { level =1 ; - va_size =32 ; + addrsize =32 ;/* There is no TTBR1 for EL2 */ if (el ==2 ) { ttbr1_valid = false;
@@ -7330,7 +7331,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address,* This is a Non-secure PL0/1 stage 1 translation, so controlled by * TTBCR/TTBR0/TTBR1 in accordance with ARM ARM DDI0406C table B-32: */ -if (va_size ==64 ) { +if (aarch64) {/* AArch64 translation. */ t0sz =extract32 (tcr->raw_tcr,0 ,6 ); t0sz =MIN (t0sz,39 );
@@ -7342,7 +7343,12 @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address,/* AArch32 stage 2 translation. */ bool sext =extract32 (tcr->raw_tcr,4 ,1 );bool sign =extract32 (tcr->raw_tcr,3 ,1 ); - t0sz =sextract32 (tcr->raw_tcr,0 ,4 ); +/* Address size is 40-bit for a stage 2 translation, +* and t0sz can be negative (from -8 to 7), +* so we need to adjust it to use the TTBR selecting logic below. +*/ + addrsize =40 ; + t0sz =sextract32 (tcr->raw_tcr,0 ,4 ) +8 ;/* If the sign-extend bit is not the same as t0sz[3], the result * is unpredictable. Flag this as a guest error. */
@@ -7352,15 +7358,15 @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address, } } t1sz =extract32 (tcr->raw_tcr,16 ,6 ); -if (va_size ==64 ) { +if (aarch64) { t1sz =MIN (t1sz,39 ); t1sz =MAX (t1sz,16 ); } -if (t0sz && !extract64 (address, va_size - t0sz, t0sz - tbi)) { +if (t0sz && !extract64 (address, addrsize - t0sz, t0sz - tbi)) {/* there is a ttbr0 region and we are in it (high bits all zero) */ ttbr_select =0 ; }else if (ttbr1_valid && t1sz && - !extract64 (~address, va_size - t1sz, t1sz - tbi)) { + !extract64 (~address, addrsize - t1sz, t1sz - tbi)) {/* there is a ttbr1 region and we are in it (high bits all one) */ ttbr_select =1 ; }else if (!t0sz) {
@@ -7387,7 +7393,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address,if (el <2 ) { epd =extract32 (tcr->raw_tcr,7 ,1 ); } - inputsize = va_size - t0sz; + inputsize = addrsize - t0sz; tg =extract32 (tcr->raw_tcr,14 ,2 );if (tg ==1 ) {/* 64KB pages */
@@ -7402,7 +7408,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address, ttbr =regime_ttbr (env, mmu_idx,1 ); epd =extract32 (tcr->raw_tcr,23 ,1 ); - inputsize = va_size - t1sz; + inputsize = addrsize - t1sz; tg =extract32 (tcr->raw_tcr,30 ,2 );if (tg ==3 ) {/* 64KB pages */
@@ -7414,7 +7420,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address, }/* Here we should have set up all the parameters for the translation: -* va_size, inputsize, ttbr, epd, stride, tbi +* inputsize, ttbr, epd, stride, tbi */ if (epd) {
@@ -7445,7 +7451,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address,uint32_t startlevel;bool ok; -if (va_size ==32 || stride ==9 ) { +if (!aarch64 || stride ==9 ) {/* AArch32 or 4KB pages */ startlevel =2 - sl0; }else {
@@ -7454,7 +7460,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address, }/* Check that the starting level is valid. */ - ok =check_s2_mmu_setup (cpu, va_size ==64 , startlevel, + ok =check_s2_mmu_setup (cpu, aarch64, startlevel, inputsize, stride);if (!ok) { fault_type = translation_fault;
@@ -7475,7 +7481,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address,* up to bit 39 for AArch32, because we don't need other bits in that case * to construct next descriptor address (anyway they should be all zeroes). */ - descaddrmask = ((1ull << (va_size ==64 ?48 :40 )) -1 ) & + descaddrmask = ((1ull << (aarch64 ?48 :40 )) -1 ) & ~indexmask_grainsize;/* Secure accesses start with the page table in secure memory and
@@ -7558,7 +7564,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address, }else { ns =extract32 (attrs,3 ,1 ); pxn =extract32 (attrs,11 ,1 ); - *prot =get_S1prot (env, mmu_idx, va_size ==64 , ap, ns, xn, pxn); + *prot =get_S1prot (env, mmu_idx, aarch64, ap, ns, xn, pxn); } fault_type = permission_fault;
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 21/28] hw/char: QOM'ify pl011 model
In reply to Peter MaydellFrom: xiaoqiang zhao <[email protected]>
* drop qemu_char_get_next_serial and use chardev prop
* add pl011_create wrapper function to create pl011 uart device
* change affected board code to use the new way
Message-id: [email protected]
--- hw/arm/bcm2835_peripherals.c | 16 +++----------- hw/arm/highbank.c | 3 ++- hw/arm/integratorcp.c | 5 +++-- hw/arm/realview.c | 9 ++++---- hw/arm/stellaris.c | 6 +++-- hw/arm/versatilepb.c | 9 ++++---- hw/arm/vexpress.c | 9 ++++---- hw/arm/virt.c | 1 + hw/char/pl011.c | 11 +++++----- include/hw/char/pl011.h | 52 ++++++++++++++++++++++++++++++++++++++++++++ 10 files changed, 86 insertions(+), 35 deletions(-) create mode 100644 include/hw/char/pl011.h
hw/arm/bcm2835_peripherals.c +3 -13
@@ -14,6 +14,7 @@#include "hw/misc/bcm2835_mbox_defs.h" #include "hw/arm/raspi_platform.h" #include "sysemu/char.h" +#include "sysemu/sysemu.h" /* Peripheral base address on the VC (GPU) system bus */ #define BCM2835_VC_PERI_BASE 0x7e000000
@@ -106,7 +107,6 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)MemoryRegion *ram;Error *err =NULL ;uint32_t ram_size, vcram_size; -CharDriverState *chr;int n; obj =object_property_get_link (OBJECT (dev),"ram" , &err);
@@ -147,6 +147,7 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)sysbus_pass_irq (SYS_BUS_DEVICE (s),SYS_BUS_DEVICE (&s->ic));/* UART0 */ +qdev_prop_set_chr (DEVICE (s->uart0),"chardev" , serial_hds[0 ]);object_property_set_bool (OBJECT (s->uart0), true,"realized" , &err);if (err) {error_propagate (errp, err);
@@ -158,17 +159,8 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)sysbus_connect_irq (s->uart0,0 ,qdev_get_gpio_in_named (DEVICE (&s->ic),BCM2835_IC_GPU_IRQ ,INTERRUPT_UART )); -/* AUX / UART1 */ -/* TODO: don't call qemu_char_get_next_serial() here, instead set -* chardev properties for each uart at the board level, once pl011 -* (uart0) has been updated to avoid qemu_char_get_next_serial() -*/ - chr =qemu_char_get_next_serial (); -if (chr ==NULL ) { - chr =qemu_chr_new ("bcm2835.uart1" ,"null" ,NULL ); - } -qdev_prop_set_chr (DEVICE (&s->aux),"chardev" , chr); +qdev_prop_set_chr (DEVICE (&s->aux),"chardev" , serial_hds[1 ]);object_property_set_bool (OBJECT (&s->aux), true,"realized" , &err);if (err) {
@@ -292,8 +284,6 @@ static void bcm2835_peripherals_class_init(ObjectClass *oc, void *data)DeviceClass *dc =DEVICE_CLASS (oc); dc->realize = bcm2835_peripherals_realize; -/* Reason: realize() method uses qemu_char_get_next_serial() */ - dc->cannot_instantiate_with_device_add_yet = true; }static const TypeInfo bcm2835_peripherals_type_info = {
hw/arm/highbank.c +2 -1
@@ -30,6 +30,7 @@#include "sysemu/block-backend.h" #include "exec/address-spaces.h" #include "qemu/error-report.h" +#include "hw/char/pl011.h" #define SMP_BOOT_ADDR 0x100#define SMP_BOOT_REG 0x40
@@ -326,7 +327,7 @@ static void calxeda_init(MachineState *machine, enum cxmachines machine_id) busdev =SYS_BUS_DEVICE (dev);sysbus_mmio_map (busdev,0 ,0xfff34000 );sysbus_connect_irq (busdev,0 , pic[18 ]); -sysbus_create_simple ("pl011" ,0xfff36000 , pic[20 ]); +pl011_create (0xfff36000 , pic[20 ], serial_hds[0 ]); dev =qdev_create (NULL ,"highbank-regs" );qdev_init_nofail (dev);
hw/arm/integratorcp.c +3 -2
@@ -20,6 +20,7 @@#include "exec/address-spaces.h" #include "sysemu/sysemu.h" #include "qemu/error-report.h" +#include "hw/char/pl011.h" #define TYPE_INTEGRATOR_CM "integrator_core"#define INTEGRATOR_CM (obj) \
@@ -588,8 +589,8 @@ static void integratorcp_init(MachineState *machine)sysbus_create_varargs ("integrator_pit" ,0x13000000 , pic[5 ], pic[6 ], pic[7 ],NULL );sysbus_create_simple ("pl031" ,0x15000000 , pic[8 ]); -sysbus_create_simple ("pl011" ,0x16000000 , pic[1 ]); -sysbus_create_simple ("pl011" ,0x17000000 , pic[2 ]); +pl011_create (0x16000000 , pic[1 ], serial_hds[0 ]); +pl011_create (0x17000000 , pic[2 ], serial_hds[1 ]); icp =sysbus_create_simple (TYPE_ICP_CONTROL_REGS ,0xcb000000 ,qdev_get_gpio_in (sic,3 ));sysbus_create_simple ("pl050_keyboard" ,0x18000000 , pic[3 ]);
hw/arm/realview.c +5 -4
@@ -23,6 +23,7 @@#include "sysemu/block-backend.h" #include "exec/address-spaces.h" #include "qemu/error-report.h" +#include "hw/char/pl011.h" #define SMP_BOOT_ADDR 0xe0000000#define SMP_BOOTREG_ADDR 0x10000030
@@ -202,10 +203,10 @@ static void realview_init(MachineState *machine,sysbus_create_simple ("pl050_keyboard" ,0x10006000 , pic[20 ]);sysbus_create_simple ("pl050_mouse" ,0x10007000 , pic[21 ]); -sysbus_create_simple ("pl011" ,0x10009000 , pic[12 ]); -sysbus_create_simple ("pl011" ,0x1000a000 , pic[13 ]); -sysbus_create_simple ("pl011" ,0x1000b000 , pic[14 ]); -sysbus_create_simple ("pl011" ,0x1000c000 , pic[15 ]); +pl011_create (0x10009000 , pic[12 ], serial_hds[0 ]); +pl011_create (0x1000a000 , pic[13 ], serial_hds[1 ]); +pl011_create (0x1000b000 , pic[14 ], serial_hds[2 ]); +pl011_create (0x1000c000 , pic[15 ], serial_hds[3 ]);/* DMA controller is optional, apparently. */ sysbus_create_simple ("pl081" ,0x10030000 , pic[24 ]);
hw/arm/stellaris.c +4 -2
@@ -20,6 +20,7 @@#include "qemu/log.h" #include "exec/address-spaces.h" #include "sysemu/sysemu.h" +#include "hw/char/pl011.h" #define GPIO_A 0#define GPIO_B 1
@@ -1303,8 +1304,9 @@ static void stellaris_init(const char *kernel_filename, const char *cpu_model,for (i =0 ; i <4 ; i++) {if (board->dc2 & (1 << i)) { -sysbus_create_simple ("pl011_luminary" ,0x4000c000 + i *0x1000 , -qdev_get_gpio_in (nvic, uart_irq[i])); +pl011_luminary_create (0x4000c000 + i *0x1000 , +qdev_get_gpio_in (nvic, uart_irq[i]), + serial_hds[i]); } }if (board->dc2 & (1 <<4 )) {
hw/arm/versatilepb.c +5 -4
@@ -23,6 +23,7 @@#include "exec/address-spaces.h" #include "hw/block/flash.h" #include "qemu/error-report.h" +#include "hw/char/pl011.h" #define VERSATILE_FLASH_ADDR 0x34000000#define VERSATILE_FLASH_SIZE (64 * 1024 * 1024)
@@ -284,10 +285,10 @@ static void versatile_init(MachineState *machine, int board_id) n--; } -sysbus_create_simple ("pl011" ,0x101f1000 , pic[12 ]); -sysbus_create_simple ("pl011" ,0x101f2000 , pic[13 ]); -sysbus_create_simple ("pl011" ,0x101f3000 , pic[14 ]); -sysbus_create_simple ("pl011" ,0x10009000 , sic[6 ]); +pl011_create (0x101f1000 , pic[12 ], serial_hds[0 ]); +pl011_create (0x101f2000 , pic[13 ], serial_hds[1 ]); +pl011_create (0x101f3000 , pic[14 ], serial_hds[2 ]); +pl011_create (0x10009000 , sic[6 ], serial_hds[3 ]);sysbus_create_simple ("pl080" ,0x10130000 , pic[17 ]);sysbus_create_simple ("sp804" ,0x101e2000 , pic[4 ]);
hw/arm/vexpress.c +5 -4
@@ -39,6 +39,7 @@#include "sysemu/device_tree.h" #include "qemu/error-report.h" #include <libfdt.h> +#include "hw/char/pl011.h" #define VEXPRESS_BOARD_ID 0x8e0#define VEXPRESS_FLASH_SIZE (64 * 1024 * 1024)
@@ -631,10 +632,10 @@ static void vexpress_common_init(MachineState *machine)sysbus_create_simple ("pl050_keyboard" , map[VE_KMI0 ], pic[12 ]);sysbus_create_simple ("pl050_mouse" , map[VE_KMI1 ], pic[13 ]); -sysbus_create_simple ("pl011" , map[VE_UART0 ], pic[5 ]); -sysbus_create_simple ("pl011" , map[VE_UART1 ], pic[6 ]); -sysbus_create_simple ("pl011" , map[VE_UART2 ], pic[7 ]); -sysbus_create_simple ("pl011" , map[VE_UART3 ], pic[8 ]); +pl011_create (map[VE_UART0 ], pic[5 ], serial_hds[0 ]); +pl011_create (map[VE_UART1 ], pic[6 ], serial_hds[1 ]); +pl011_create (map[VE_UART2 ], pic[7 ], serial_hds[2 ]); +pl011_create (map[VE_UART3 ], pic[8 ], serial_hds[3 ]);sysbus_create_simple ("sp804" , map[VE_TIMER01 ], pic[2 ]);sysbus_create_simple ("sp804" , map[VE_TIMER23 ], pic[3 ]);
hw/arm/virt.c +1 -0
@@ -567,6 +567,7 @@ static void create_uart(const VirtBoardInfo *vbi, qemu_irq *pic, int uart,DeviceState *dev =qdev_create (NULL ,"pl011" );SysBusDevice *s =SYS_BUS_DEVICE (dev); +qdev_prop_set_chr (dev,"chardev" , serial_hds[0 ]);qdev_init_nofail (dev);memory_region_add_subregion (mem, base,sysbus_mmio_get_region (s,0 ));
hw/char/pl011.c +6 -5
@@ -274,6 +274,11 @@ static const VMStateDescription vmstate_pl011 = { } }; +static Property pl011_properties[] = { +DEFINE_PROP_CHR ("chardev" , PL011State, chr), +DEFINE_PROP_END_OF_LIST (), +}; +static void pl011_init (Object *obj) {SysBusDevice *sbd =SYS_BUS_DEVICE (obj);
@@ -295,9 +300,6 @@ static void pl011_realize(DeviceState *dev, Error **errp) {PL011State *s =PL011 (dev); -/* FIXME use a qdev chardev prop instead of qemu_char_get_next_serial() */ - s->chr =qemu_char_get_next_serial (); -if (s->chr) {qemu_chr_add_handlers (s->chr, pl011_can_receive, pl011_receive, pl011_event, s);
@@ -310,8 +312,7 @@ static void pl011_class_init(ObjectClass *oc, void *data) dc->realize = pl011_realize; dc->vmsd = &vmstate_pl011; -/* Reason: realize() method uses qemu_char_get_next_serial() */ - dc->cannot_instantiate_with_device_add_yet = true; + dc->props = pl011_properties; }static const TypeInfo pl011_arm_info = {
include/hw/char/pl011.h new file +52 -0
52 lines not on this page · raw message
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 22/28] hw/char: QOM'ify cadence_uart model
In reply to Peter MaydellFrom: xiaoqiang zhao <[email protected]>
* drop qemu_char_get_next_serial and use chardev prop
* create cadence_uart_create wrapper function to create cadence_uart_device
* change affected board code to use the new way
Message-id: [email protected]
--- hw/arm/xilinx_zynq.c | 5 +++-- hw/arm/xlnx-zynqmp.c | 1 + hw/char/cadence_uart.c | 13 +++++++------ include/hw/char/cadence_uart.h | 17 +++++++++++++++++ 4 files changed, 28 insertions(+), 8 deletions(-)
hw/arm/xilinx_zynq.c +3 -2
@@ -32,6 +32,7 @@#include "hw/ssi/ssi.h" #include "qemu/error-report.h" #include "hw/sd/sd.h" +#include "hw/char/cadence_uart.h" #define NUM_SPI_FLASHES 4#define NUM_QSPI_FLASHES 2
@@ -235,8 +236,8 @@ static void zynq_init(MachineState *machine)sysbus_create_simple ("xlnx,ps7-usb" ,0xE0002000 , pic[53 -IRQ_OFFSET ]);sysbus_create_simple ("xlnx,ps7-usb" ,0xE0003000 , pic[76 -IRQ_OFFSET ]); -sysbus_create_simple ("cadence_uart" ,0xE0000000 , pic[59 -IRQ_OFFSET ]); -sysbus_create_simple ("cadence_uart" ,0xE0001000 , pic[82 -IRQ_OFFSET ]); +cadence_uart_create (0xE0000000 , pic[59 -IRQ_OFFSET ], serial_hds[0 ]); +cadence_uart_create (0xE0001000 , pic[82 -IRQ_OFFSET ], serial_hds[1 ]);sysbus_create_varargs ("cadence_ttc" ,0xF8001000 , pic[42 -IRQ_OFFSET ], pic[43 -IRQ_OFFSET ], pic[44 -IRQ_OFFSET ],NULL );
hw/arm/xlnx-zynqmp.c +1 -0
@@ -331,6 +331,7 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp) }for (i =0 ; i <XLNX_ZYNQMP_NUM_UARTS ; i++) { +qdev_prop_set_chr (DEVICE (&s->uart[i]),"chardev" , serial_hds[i]);object_property_set_bool (OBJECT (&s->uart[i]), true,"realized" , &err);if (err) {error_propagate (errp, err);
hw/char/cadence_uart.c +7 -6
@@ -468,9 +468,6 @@ static void cadence_uart_realize(DeviceState *dev, Error **errp) s->fifo_trigger_handle =timer_new_ns (QEMU_CLOCK_VIRTUAL , fifo_trigger_update, s); -/* FIXME use a qdev chardev prop instead of qemu_char_get_next_serial() */ - s->chr =qemu_char_get_next_serial (); -if (s->chr) {qemu_chr_add_handlers (s->chr, uart_can_receive, uart_receive, uart_event, s);
@@ -517,6 +514,11 @@ static const VMStateDescription vmstate_cadence_uart = { } }; +static Property cadence_uart_properties[] = { +DEFINE_PROP_CHR ("chardev" , CadenceUARTState, chr), +DEFINE_PROP_END_OF_LIST (), +}; +static void cadence_uart_class_init (ObjectClass *klass,void *data) {DeviceClass *dc =DEVICE_CLASS (klass);
@@ -524,9 +526,8 @@ static void cadence_uart_class_init(ObjectClass *klass, void *data) dc->realize = cadence_uart_realize; dc->vmsd = &vmstate_cadence_uart; dc->reset = cadence_uart_reset; -/* Reason: realize() method uses qemu_char_get_next_serial() */ - dc->cannot_instantiate_with_device_add_yet = true; -} + dc->props = cadence_uart_properties; + }static const TypeInfo cadence_uart_info = { .name =TYPE_CADENCE_UART ,
include/hw/char/cadence_uart.h +17 -0
@@ -49,5 +49,22 @@ typedef struct { QEMUTimer *fifo_trigger_handle; } CadenceUARTState; +static inline DeviceState *cadence_uart_create (hwaddr addr, +qemu_irq irq, +CharDriverState *chr) +{ +DeviceState *dev; +SysBusDevice *s; + + dev =qdev_create (NULL ,TYPE_CADENCE_UART ); + s =SYS_BUS_DEVICE (dev); +qdev_prop_set_chr (dev,"chardev" , chr); +qdev_init_nofail (dev); +sysbus_mmio_map (s,0 , addr); +sysbus_connect_irq (s,0 , irq); + +return dev; +} +#define CADENCE_UART_H #endif
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 02/28] target-arm: A64: Create Instruction Syndromes for Data Aborts
In reply to Peter MaydellFrom: "Edgar E. Iglesias" <[email protected]>
Add support for generating the ISS (Instruction Specific Syndrome) for Data Abort exceptions taken from AArch64.
These syndromes are used by hypervisors for example to trap and emulate memory accesses.
We save the decoded data out-of-band with the TBs at translation time. When exceptions hit, the extra data attached to the TB is used to recreate the state needed to encode instruction syndromes. This avoids the need to emit moves with every load/store.
Based on a suggestion from Peter Maydell.
Message-id: [email protected]
--- target-arm/cpu.h | 14 ++++- target-arm/op_helper.c | 49 ++++++++++++++-- target-arm/translate-a64.c | 140 ++++++++++++++++++++++++++++++++++++++------- target-arm/translate.c | 5 +- target-arm/translate.h | 2 + 5 files changed, 180 insertions(+), 30 deletions(-)
target-arm/cpu.h +13 -1
@@ -93,7 +93,19 @@#define ARM_CPU_VFIQ 3#define NB_MMU_MODES 7 -#define TARGET_INSN_START_EXTRA_WORDS 1 +/* ARM-specific extra insn start words: +* 1: Conditional execution bits +* 2: Partial exception syndrome for data aborts +*/ +#define TARGET_INSN_START_EXTRA_WORDS 2 + +/* The 2nd extra word holding syndrome info for data aborts does not use +* the upper 6 bits nor the lower 14 bits. We mask and shift it down to +* help the sleb128 encoder do a better job. +* When restoring the CPU state, we shift it back up. +*/ +#define ARM_INSN_START_WORD2_MASK ((1 << 26) - 1) +#define ARM_INSN_START_WORD2_SHIFT 14/* We currently assume float and double are IEEE single and double precision respectively.
target-arm/op_helper.c +43 -6
73 lines not on this page · raw message
target-arm/translate-a64.c +118 -22
246 lines not on this page · raw message
target-arm/translate.c +4 -1
@@ -11732,7 +11732,8 @@ void gen_intermediate_code(CPUARMState *env, TranslationBlock *tb) } do { tcg_gen_insn_start(dc->pc, - (dc->condexec_cond << 4) | (dc->condexec_mask >> 1)); + (dc->condexec_cond << 4) | (dc->condexec_mask >> 1), + 0); num_insns++; #ifdef CONFIG_USER_ONLY
@@ -12049,8 +12050,10 @@ void restore_state_to_opc(CPUARMState *env, TranslationBlock *tb,if (is_a64 (env)) { env->pc = data[0 ]; env->condexec_bits =0 ; + env->exception.syndrome = data[2 ] <<ARM_INSN_START_WORD2_SHIFT ; }else { env->regs[15 ] = data[0 ]; env->condexec_bits = data[1 ]; + env->exception.syndrome = data[2 ] <<ARM_INSN_START_WORD2_SHIFT ; } }
target-arm/translate.h +2 -0
@@ -59,6 +59,8 @@ typedef struct DisasContext {bool ss_same_el;/* Bottom two bits of XScale c15_cpar coprocessor access control reg */ int c15_cpar; +/* TCG op index of the current insn_start. */ +int insn_start_idx;#define TMP_A64_MAX 16int tmp_a64_count;TCGv_i64 tmp_a64[TMP_A64_MAX ];
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 10/28] i2c: add aspeed i2c controller
In reply to Peter MaydellFrom: Cédric Le Goater <[email protected]>
The Aspeed AST2400 integrates a set of 14 I2C/SMBus bus controllers directly connected to the APB bus. They can be programmed as master or slave but the propopsed model only supports the master mode.
On the TODO list, we also have :
- improve and harden the state machine.
- bus recovery support (used by the Linux driver).
- transfer mode state machine bits. this is not strictly necessary as it is mostly used for debug. The bus busy bit is deducted from the I2C core engine of qemu.
- support of the pool buffer: 2048 bytes of internal SRAM (not used by the Linux driver).
Message-id: [email protected]
--- hw/arm/ast2400.c | 16 ++ hw/i2c/Makefile.objs | 1 + hw/i2c/aspeed_i2c.c | 450 ++++++++++++++++++++++++++++++++++++++++++++ include/hw/arm/ast2400.h | 2 + include/hw/i2c/aspeed_i2c.h | 62 ++++++ 5 files changed, 531 insertions(+) create mode 100644 hw/i2c/aspeed_i2c.c create mode 100644 include/hw/i2c/aspeed_i2c.h
hw/arm/ast2400.c +16 -0
@@ -18,12 +18,14 @@#include "hw/arm/ast2400.h" #include "hw/char/serial.h" #include "qemu/log.h" +#include "hw/i2c/aspeed_i2c.h" #define AST2400_UART_5_BASE 0x00184000#define AST2400_IOMEM_SIZE 0x00200000#define AST2400_IOMEM_BASE 0x1E600000#define AST2400_VIC_BASE 0x1E6C0000#define AST2400_TIMER_BASE 0x1E782000 +#define AST2400_I2C_BASE 0x1E78A000static const int uart_irqs[] = {9 ,32 ,33 ,34 ,10 };static const int timer_irqs[] = {16 ,17 ,18 ,35 ,36 ,37 ,38 ,39 , };
@@ -66,6 +68,10 @@ static void ast2400_init(Object *obj)object_initialize (&s->timerctrl,sizeof (s->timerctrl),TYPE_ASPEED_TIMER );object_property_add_child (obj,"timerctrl" ,OBJECT (&s->timerctrl),NULL );qdev_set_parent_bus (DEVICE (&s->timerctrl),sysbus_get_default ()); + +object_initialize (&s->i2c,sizeof (s->i2c),TYPE_ASPEED_I2C ); +object_property_add_child (obj,"i2c" ,OBJECT (&s->i2c),NULL ); +qdev_set_parent_bus (DEVICE (&s->i2c),sysbus_get_default ()); }static void ast2400_realize (DeviceState *dev,Error **errp)
@@ -110,6 +116,16 @@ static void ast2400_realize(DeviceState *dev, Error **errp)serial_mm_init (&s->iomem,AST2400_UART_5_BASE ,2 , uart5,38400 , serial_hds[0 ],DEVICE_LITTLE_ENDIAN ); } + +/* I2C */ +object_property_set_bool (OBJECT (&s->i2c), true,"realized" , &err); +if (err) { +error_propagate (errp, err); +return ; + } +sysbus_mmio_map (SYS_BUS_DEVICE (&s->i2c),0 ,AST2400_I2C_BASE ); +sysbus_connect_irq (SYS_BUS_DEVICE (&s->i2c),0 , +qdev_get_gpio_in (DEVICE (&s->vic),12 )); }static void ast2400_class_init (ObjectClass *oc,void *data)
hw/i2c/Makefile.objs +1 -0
@@ -5,4 +5,5 @@ common-obj-$(CONFIG_APM) += pm_smbus.o common-obj-$(CONFIG_BITBANG_I2C) += bitbang_i2c.o common-obj-$(CONFIG_EXYNOS4) += exynos4210_i2c.o common-obj-$(CONFIG_IMX_I2C) += imx_i2c.o +common-obj-$(CONFIG_ASPEED_SOC) += aspeed_i2c.o obj-$(CONFIG_OMAP) += omap_i2c.o
hw/i2c/aspeed_i2c.c new file +450 -0
450 lines not on this page · raw message
include/hw/arm/ast2400.h +2 -0
@@ -15,6 +15,7 @@#include "hw/arm/arm.h" #include "hw/intc/aspeed_vic.h" #include "hw/timer/aspeed_timer.h" +#include "hw/i2c/aspeed_i2c.h" typedef struct AST2400State { /*< private >*/
@@ -25,6 +26,7 @@ typedef struct AST2400State {MemoryRegion iomem;AspeedVICState vic;AspeedTimerCtrlState timerctrl; +AspeedI2CState i2c; } AST2400State;#define TYPE_AST2400 "ast2400"
include/hw/i2c/aspeed_i2c.h new file +62 -0
62 lines not on this page · raw message
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 25/28] hw/char: QOM'ify xilinx_uartlite model
In reply to Peter MaydellFrom: xiaoqiang zhao <[email protected]>
* drop qemu_char_get_next_serial and use chardev prop
* create xilinx_uartlite_create wrapper function to create xilinx_uartlite device
* change affected board code to use the new way
Message-id: [email protected]
--- hw/char/xilinx_uartlite.c | 10 +++++---- hw/microblaze/petalogix_s3adsp1800_mmu.c | 5 +++-- include/hw/char/xilinx_uartlite.h | 35 ++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 6 deletions(-) create mode 100644 include/hw/char/xilinx_uartlite.h
hw/char/xilinx_uartlite.c +6 -4
@@ -172,6 +172,11 @@ static const MemoryRegionOps uart_ops = { } }; +static Property xilinx_uartlite_properties[] = { +DEFINE_PROP_CHR ("chardev" , XilinxUARTLite, chr), +DEFINE_PROP_END_OF_LIST (), +}; +static void uart_rx (void *opaque,const uint8_t *buf,int size) {XilinxUARTLite *s = opaque;
@@ -206,8 +211,6 @@ static void xilinx_uartlite_realize(DeviceState *dev, Error **errp) {XilinxUARTLite *s =XILINX_UARTLITE (dev); -/* FIXME use a qdev chardev prop instead of qemu_char_get_next_serial() */ - s->chr =qemu_char_get_next_serial ();if (s->chr)qemu_chr_add_handlers (s->chr, uart_can_rx, uart_rx, uart_event, s); }
@@ -229,8 +232,7 @@ static void xilinx_uartlite_class_init(ObjectClass *klass, void *data) dc->reset = xilinx_uartlite_reset; dc->realize = xilinx_uartlite_realize; -/* Reason: realize() method uses qemu_char_get_next_serial() */ - dc->cannot_instantiate_with_device_add_yet = true; + dc->props = xilinx_uartlite_properties; }static const TypeInfo xilinx_uartlite_info = {
hw/microblaze/petalogix_s3adsp1800_mmu.c +3 -2
@@ -36,6 +36,7 @@#include "hw/boards.h" #include "sysemu/block-backend.h" #include "exec/address-spaces.h" +#include "hw/char/xilinx_uartlite.h" #include "boot.h"
@@ -103,8 +104,8 @@ petalogix_s3adsp1800_init(MachineState *machine) irq[i] =qdev_get_gpio_in (dev, i); } -sysbus_create_simple ("xlnx.xps-uartlite" ,UARTLITE_BASEADDR , - irq[UARTLITE_IRQ ]); +xilinx_uartlite_create (UARTLITE_BASEADDR , irq[UARTLITE_IRQ ], + serial_hds[0 ]);/* 2 timers at irq 2 @ 62 Mhz. */ dev =qdev_create (NULL ,"xlnx.xps-timer" );
include/hw/char/xilinx_uartlite.h new file +35 -0
@@ -0,0 +1,35 @@ +/* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2 or later, as published by the Free Software Foundation. +* +* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License along with +* this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef XILINX_UARTLITE_H +#define XILINX_UARTLITE_H + +static inline DeviceState *xilinx_uartlite_create (hwaddr addr, +qemu_irq irq, +CharDriverState *chr) +{ +DeviceState *dev; +SysBusDevice *s; + + dev =qdev_create (NULL ,"xlnx.xps-uartlite" ); + s =SYS_BUS_DEVICE (dev); +qdev_prop_set_chr (dev,"chardev" , chr); +qdev_init_nofail (dev); +sysbus_mmio_map (s,0 , addr); +sysbus_connect_irq (s,0 , irq); + +return dev; +} + +#endif
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 18/28] hw/ptimer: Update .delta on period/freq change
In reply to Peter MaydellFrom: Dmitry Osipenko <[email protected]>
Delta value must be updated on period/freq change, otherwise running timer would be restarted (counter reloaded with old delta). Only m68k/mcf520x and arm/arm_timer devices are currently doing freq change correctly, i.e. stopping the timer. Perform delta update to fix affected devices and eliminate potential further mistakes.
Message-id: 4987ef5fdc128bb9a744fd794d3f609135c6a39c.1464367869.git.digetx@gmail.com
--- hw/core/ptimer.c | 2 ++ 1 file changed, 2 insertions(+)
hw/core/ptimer.c +2 -0
@@ -190,6 +190,7 @@ void ptimer_stop(ptimer_state *s)/* Set counter increment interval in nanoseconds. */ void ptimer_set_period (ptimer_state *s,int64_t period) { + s->delta =ptimer_get_count (s); s->period = period; s->period_frac =0 ;if (s->enabled) {
@@ -201,6 +202,7 @@ void ptimer_set_period(ptimer_state *s, int64_t period)/* Set counter frequency in Hz. */ void ptimer_set_freq (ptimer_state *s,uint32_t freq) { + s->delta =ptimer_get_count (s); s->period =1000000000ll / freq; s->period_frac = (1000000000ll <<32 ) / freq;if (s->enabled) {
Signature · 1 line
1.9.1