target-arm queue
Subsystems (2)
target-arm queue: mostly smallish stuff. I expect to send out another pullreq at the end of this week, but since this is up to 32 patches already I'd rather send it out now than accumulate a monster sized patchset.
thanks
-- PMM
The following changes since commit 0ab4c574a55448a37b9f616259b82950742c9427:
Merge remote-tracking branch 'remotes/kraxel/tags/ui-20180626-pull-request' into staging (2018-06-26 16:44:57 +0100)
are available in the Git repository at:
git://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20180626
for you to fetch changes up to 9b945a9ee36a34eaeca412ef9ef35fbfe33c2c85:
aspeed/timer: use the APB frequency from the SCU (2018-06-26 17:50:42 +0100)
----------------------------------------------------------------
target-arm queue:
* aspeed: set APB clocks correctly (fixes slowdown on palmetto)
* smmuv3: cache config data and TLB entries
* v7m/v8m: support read/write from MPU regions smaller than 1K
* various: clean up logging/debug messages
* xilinx_spips: Make dma transactions as per dma_burst_size
----------------------------------------------------------------
Cédric Le Goater (6):
aspeed/smc: fix dummy cycles count when in dual IO mode aspeed/smc: fix HW strapping
aspeed/smc: rename aspeed_smc_flash_send_addr() to aspeed_smc_flash_setup() aspeed/scu: introduce clock frequencies
aspeed: initialize the SCU controller first
aspeed/timer: use the APB frequency from the SCU
Eric Auger (3):
hw/arm/smmuv3: Cache/invalidate config data hw/arm/smmuv3: IOTLB emulation hw/arm/smmuv3: Add notifications on invalidation
Jia He (1):
hw/arm/smmuv3: Fix translate error handling
Joel Stanley (1):
MAINTAINERS: Add ASPEED BMCs
Peter Maydell (3):
tcg: Support MMU protection regions smaller than TARGET_PAGE_SIZE target/arm: Set page (region) size in get_phys_addr_pmsav7() target/arm: Handle small regions in get_phys_addr_pmsav8()
Philippe Mathieu-Daudé (17):
MAINTAINERS: Adopt the Gumstix computers-on-module machines hw/input/pckbd: Use qemu_log_mask(GUEST_ERROR) instead of fprintf hw/input/tsc2005: Use qemu_log_mask(GUEST_ERROR) instead of fprintf hw/dma/omap_dma: Use qemu_log_mask(UNIMP) instead of printf hw/dma/omap_dma: Use qemu_log_mask(GUEST_ERROR) instead of fprintf hw/ssi/omap_spi: Use qemu_log_mask(GUEST_ERROR) instead of fprintf hw/sd/omap_mmc: Use qemu_log_mask(UNIMP) instead of printf hw/i2c/omap_i2c: Use qemu_log_mask(UNIMP) instead of fprintf hw/arm/omap1: Use qemu_log_mask(GUEST_ERROR) instead of fprintf hw/arm/omap: Use qemu_log_mask(GUEST_ERROR) instead of fprintf hw/arm/stellaris: Use qemu_log_mask(UNIMP) instead of fprintf hw/net/stellaris_enet: Fix a typo
hw/net/stellaris_enet: Use qemu_log_mask(GUEST_ERROR) instead of hw_error hw/net/smc91c111: Use qemu_log_mask(GUEST_ERROR) instead of hw_error hw/net/smc91c111: Use qemu_log_mask(UNIMP) instead of fprintf hw/arm/stellaris: Fix gptm_write() error message hw/arm/stellaris: Use HWADDR_PRIx to display register address
Sai Pavan Boddu (1):
xilinx_spips: Make dma transactions as per dma_burst_size
accel/tcg/softmmu_template.h | 24 ++- hw/arm/smmuv3-internal.h | 12 +- include/exec/cpu-all.h | 5 +- include/hw/arm/omap.h | 30 +-- include/hw/arm/smmu-common.h | 24 +++ include/hw/arm/smmuv3.h | 1 + include/hw/misc/aspeed_scu.h | 70 ++++++- include/hw/ssi/xilinx_spips.h | 5 +- include/hw/timer/aspeed_timer.h | 4 + accel/tcg/cputlb.c | 131 +++++++++++-- hw/arm/aspeed_soc.c | 42 ++-- hw/arm/omap1.c | 18 +- hw/arm/smmu-common.c | 118 ++++++++++- hw/arm/smmuv3.c | 420 ++++++++++++++++++++++++++++++++++++---- hw/arm/stellaris.c | 8 +- hw/dma/omap_dma.c | 70 ++++--- hw/i2c/omap_i2c.c | 20 +- hw/input/pckbd.c | 4 +- hw/input/tsc2005.c | 13 +- hw/misc/aspeed_scu.c | 106 ++++++++++ hw/net/smc91c111.c | 21 +- hw/net/stellaris_enet.c | 11 +- hw/sd/omap_mmc.c | 13 +- hw/ssi/aspeed_smc.c | 48 ++--- hw/ssi/omap_spi.c | 15 +- hw/ssi/xilinx_spips.c | 23 ++- hw/timer/aspeed_timer.c | 19 +- target/arm/helper.c | 115 +++++++---- MAINTAINERS | 14 +- hw/arm/trace-events | 27 ++- 30 files changed, 1176 insertions(+), 255 deletions(-)
[Qemu-devel] [PULL 10/32] hw/dma/omap_dma: Use qemu_log_mask(GUEST_ERROR) instead of fprintf
From: Philippe Mathieu-Daudé <[email protected]>
Message-id: [email protected]
--- hw/dma/omap_dma.c | 64 +++++++++++++++++++++++++++++------------------ 1 file changed, 40 insertions(+), 24 deletions(-)
hw/dma/omap_dma.c +40 -24
@@ -879,15 +879,18 @@ static int omap_dma_ch_reg_write(struct omap_dma_s *s, ch->burst[0 ] = (value &0x0180 ) >>7 ; ch->pack[0 ] = (value &0x0040 ) >>6 ; ch->port[0 ] = (enum omap_dma_port ) ((value &0x003c ) >>2 ); -if (ch->port[0 ] >= __omap_dma_port_last) -printf ("%s: invalid DMA port %i\n" , __func__, - ch->port[0 ]); -if (ch->port[1 ] >= __omap_dma_port_last) -printf ("%s: invalid DMA port %i\n" , __func__, - ch->port[1 ]); +if (ch->port[0 ] >= __omap_dma_port_last) { +qemu_log_mask (LOG_GUEST_ERROR ,"%s: invalid DMA port %i\n" , + __func__, ch->port[0 ]); + } +if (ch->port[1 ] >= __omap_dma_port_last) { +qemu_log_mask (LOG_GUEST_ERROR ,"%s: invalid DMA port %i\n" , + __func__, ch->port[1 ]); + } ch->data_type =1 << (value &3 );if ((value &3 ) ==3 ) { -printf ("%s: bad data_type for DMA channel\n" , __func__); +qemu_log_mask (LOG_GUEST_ERROR , +"%s: bad data_type for DMA channel\n" , __func__); ch->data_type >>=1 ; }break ;
@@ -1899,14 +1902,18 @@ static void omap_dma4_write(void *opaque, hwaddr addr,if (value &2 )/* SOFTRESET */ omap_dma_reset (s->dma); s->ocp = value &0x3321 ; -if (((s->ocp >>12 ) &3 ) ==3 )/* MIDLEMODE */ -fprintf (stderr,"%s: invalid DMA power mode\n" , __func__); +if (((s->ocp >>12 ) &3 ) ==3 ) {/* MIDLEMODE */ +qemu_log_mask (LOG_GUEST_ERROR ,"%s: invalid DMA power mode\n" , + __func__); + }return ;case 0x78 :/* DMA4_GCR */ s->gcr = value &0x00ff00ff ; -if ((value &0xff ) ==0x00 )/* MAX_CHANNEL_FIFO_DEPTH */ -fprintf (stderr,"%s: wrong FIFO depth in GCR\n" , __func__); +if ((value &0xff ) ==0x00 ) {/* MAX_CHANNEL_FIFO_DEPTH */ +qemu_log_mask (LOG_GUEST_ERROR ,"%s: wrong FIFO depth in GCR\n" , + __func__); + }return ; case 0x80 ... 0xfff:
@@ -1935,9 +1942,11 @@ static void omap_dma4_write(void *opaque, hwaddr addr,case 0x00 :/* DMA4_CCR */ ch->buf_disable = (value >>25 ) &1 ; ch->src_sync = (value >>24 ) &1 ;/* XXX For CamDMA must be 1 */ -if (ch->buf_disable && !ch->src_sync) -fprintf (stderr,"%s: Buffering disable is not allowed in " -"destination synchronised mode\n" , __func__); +if (ch->buf_disable && !ch->src_sync) { +qemu_log_mask (LOG_GUEST_ERROR , +"%s: Buffering disable is not allowed in " +"destination synchronised mode\n" , __func__); + } ch->prefetch = (value >>23 ) &1 ; ch->bs = (value >>18 ) &1 ; ch->transparent_copy = (value >>17 ) &1 ;
@@ -1947,9 +1956,11 @@ static void omap_dma4_write(void *opaque, hwaddr addr, ch->suspend = (value &0x0100 ) >>8 ; ch->priority = (value &0x0040 ) >>6 ; ch->fs = (value &0x0020 ) >>5 ; -if (ch->fs && ch->bs && ch->mode[0 ] && ch->mode[1 ]) -fprintf (stderr,"%s: For a packet transfer at least one port " -"must be constant-addressed\n" , __func__); +if (ch->fs && ch->bs && ch->mode[0 ] && ch->mode[1 ]) { +qemu_log_mask (LOG_GUEST_ERROR , +"%s: For a packet transfer at least one port " +"must be constant-addressed\n" , __func__); + } ch->sync = (value &0x001f ) | ((value >>14 ) &0x0060 );/* XXX must be 0x01 for CamDMA */
@@ -1978,9 +1989,11 @@ static void omap_dma4_write(void *opaque, hwaddr addr, ch->endian_lock[0 ] =(value >>20 ) &1 ; ch->endian[1 ] =(value >>19 ) &1 ; ch->endian_lock[1 ] =(value >>18 ) &1 ; -if (ch->endian[0 ] != ch->endian[1 ]) -fprintf (stderr,"%s: DMA endianness conversion enable attempt\n" , - __func__); +if (ch->endian[0 ] != ch->endian[1 ]) { +qemu_log_mask (LOG_GUEST_ERROR , +"%s: DMA endianness conversion enable attempt\n" , + __func__); + } ch->write_mode = (value >>16 ) &3 ; ch->burst[1 ] = (value &0xc000 ) >>14 ; ch->pack[1 ] = (value &0x2000 ) >>13 ;
@@ -1988,12 +2001,15 @@ static void omap_dma4_write(void *opaque, hwaddr addr, ch->burst[0 ] = (value &0x0180 ) >>7 ; ch->pack[0 ] = (value &0x0040 ) >>6 ; ch->translate[0 ] = (value &0x003c ) >>2 ; -if (ch->translate[0 ] | ch->translate[1 ]) -fprintf (stderr,"%s: bad MReqAddressTranslate sideband signal\n" , - __func__); +if (ch->translate[0 ] | ch->translate[1 ]) { +qemu_log_mask (LOG_GUEST_ERROR , +"%s: bad MReqAddressTranslate sideband signal\n" , + __func__); + } ch->data_type =1 << (value &3 );if ((value &3 ) ==3 ) { -printf ("%s: bad data_type for DMA channel\n" , __func__); +qemu_log_mask (LOG_GUEST_ERROR , +"%s: bad data_type for DMA channel\n" , __func__); ch->data_type >>=1 ; }break ;
Signature · 1 line
2.17.1
[Qemu-devel] [PULL 11/32] hw/ssi/omap_spi: Use qemu_log_mask(GUEST_ERROR) instead of fprintf
In reply to Peter MaydellFrom: Philippe Mathieu-Daudé <[email protected]>
Message-id: [email protected]
--- hw/ssi/omap_spi.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
hw/ssi/omap_spi.c +10 -5
@@ -20,6 +20,7 @@* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "qemu/osdep.h" +#include "qemu/log.h" #include "hw/hw.h" #include "hw/arm/omap.h"
@@ -294,11 +295,15 @@ static void omap_mcspi_write(void *opaque, hwaddr addr,case 0x2c :/* MCSPI_CHCONF */ if ((value ^ s->ch[ch].config) & (3 <<14 ))/* DMAR | DMAW */ omap_mcspi_dmarequest_update (s->ch + ch); -if (((value >>12 ) &3 ) ==3 )/* TRM */ -fprintf (stderr,"%s: invalid TRM value (3)\n" , __func__); -if (((value >>7 ) &0x1f ) <3 )/* WL */ -fprintf (stderr,"%s: invalid WL value (%" PRIx64")\n" , - __func__, (value >>7 ) &0x1f ); +if (((value >>12 ) &3 ) ==3 ) {/* TRM */ +qemu_log_mask (LOG_GUEST_ERROR ,"%s: invalid TRM value (3)\n" , + __func__); + } +if (((value >>7 ) &0x1f ) <3 ) {/* WL */ +qemu_log_mask (LOG_GUEST_ERROR , +"%s: invalid WL value (%" PRIx64")\n" , + __func__, (value >>7 ) &0x1f ); + } s->ch[ch].config = value &0x7fffff ;break ;
Signature · 1 line
2.17.1
[Qemu-devel] [PULL 09/32] hw/dma/omap_dma: Use qemu_log_mask(UNIMP) instead of printf
In reply to Peter MaydellFrom: Philippe Mathieu-Daudé <[email protected]>
Message-id: [email protected]
--- hw/dma/omap_dma.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
hw/dma/omap_dma.c +4 -2
@@ -18,6 +18,7 @@* with this program; if not, see <http://www.gnu.org/licenses/>. */ #include "qemu/osdep.h" +#include "qemu/log.h" #include "qemu-common.h" #include "qemu/timer.h" #include "hw/arm/omap.h"
@@ -1439,8 +1440,9 @@ static int omap_dma_sys_read(struct omap_dma_s *s, int offset,case 0x480 :/* DMA_PCh0_SR */ case 0x482 :/* DMA_PCh1_SR */ case 0x4c0 :/* DMA_PChD_SR_0 */ -printf ("%s: Physical Channel Status Registers not implemented.\n" , - __func__); +qemu_log_mask (LOG_UNIMP , +"%s: Physical Channel Status Registers not implemented\n" , + __func__); *ret =0xff ;break ;
Signature · 1 line
2.17.1
[Qemu-devel] [PULL 12/32] hw/sd/omap_mmc: Use qemu_log_mask(UNIMP) instead of printf
In reply to Peter MaydellFrom: Philippe Mathieu-Daudé <[email protected]>
Message-id: [email protected]
--- hw/sd/omap_mmc.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
hw/sd/omap_mmc.c +9 -4
@@ -17,6 +17,7 @@* with this program; if not, see <http://www.gnu.org/licenses/>. */ #include "qemu/osdep.h" +#include "qemu/log.h" #include "hw/hw.h" #include "hw/arm/omap.h" #include "hw/sd/sd.h"
@@ -449,10 +450,14 @@ static void omap_mmc_write(void *opaque, hwaddr offset, s->enable = (value >>11 ) &1 ; s->be = (value >>10 ) &1 ; s->clkdiv = (value >>0 ) & (s->rev >=2 ?0x3ff :0xff ); -if (s->mode !=0 ) -printf ("SD mode %i unimplemented!\n" , s->mode); -if (s->be !=0 ) -printf ("SD FIFO byte sex unimplemented!\n" ); +if (s->mode !=0 ) { +qemu_log_mask (LOG_UNIMP , +"omap_mmc_wr: mode #%i unimplemented\n" , s->mode); + } +if (s->be !=0 ) { +qemu_log_mask (LOG_UNIMP , +"omap_mmc_wr: Big Endian not implemented\n" ); + }if (s->dw !=0 && s->lines <4 )printf ("4-bit SD bus enabled\n" );if (!s->enable)
Signature · 1 line
2.17.1
[Qemu-devel] [PULL 13/32] hw/i2c/omap_i2c: Use qemu_log_mask(UNIMP) instead of fprintf
In reply to Peter MaydellFrom: Philippe Mathieu-Daudé <[email protected]>
Message-id: [email protected]
--- hw/i2c/omap_i2c.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-)
hw/i2c/omap_i2c.c +12 -8
@@ -17,6 +17,7 @@* with this program; if not, see <http://www.gnu.org/licenses/>. */ #include "qemu/osdep.h" +#include "qemu/log.h" #include "hw/hw.h" #include "hw/i2c/i2c.h" #include "hw/arm/omap.h"
@@ -339,14 +340,15 @@ static void omap_i2c_write(void *opaque, hwaddr addr, }break ; } -if ((value & (1 <<15 )) && !(value & (1 <<10 ))) {/* MST */ -fprintf (stderr,"%s: I^2C slave mode not supported\n" , - __func__); +if ((value & (1 <<15 )) && !(value & (1 <<10 ))) {/* MST */ +qemu_log_mask (LOG_UNIMP ,"%s: I^2C slave mode not supported\n" , + __func__);break ; } -if ((value & (1 <<15 )) && value & (1 <<8 )) {/* XA */ -fprintf (stderr,"%s: 10-bit addressing mode not supported\n" , - __func__); +if ((value & (1 <<15 )) && value & (1 <<8 )) {/* XA */ +qemu_log_mask (LOG_UNIMP , +"%s: 10-bit addressing mode not supported\n" , + __func__);break ; }if ((value & (1 <<15 )) && value & (1 <<0 )) {/* STT */
@@ -392,8 +394,10 @@ static void omap_i2c_write(void *opaque, hwaddr addr, s->stat |=0x3f ;omap_i2c_interrupts_update (s); } -if (value & (1 <<15 ))/* ST_EN */ -fprintf (stderr,"%s: System Test not supported\n" , __func__); +if (value & (1 <<15 )) {/* ST_EN */ +qemu_log_mask (LOG_UNIMP , +"%s: System Test not supported\n" , __func__); + }break ;default :
Signature · 1 line
2.17.1
[Qemu-devel] [PULL 07/32] hw/input/pckbd: Use qemu_log_mask(GUEST_ERROR) instead of fprintf
In reply to Peter MaydellFrom: Philippe Mathieu-Daudé <[email protected]>
Message-id: [email protected]
--- hw/input/pckbd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
hw/input/pckbd.c +3 -1
@@ -22,6 +22,7 @@* THE SOFTWARE. */ #include "qemu/osdep.h" +#include "qemu/log.h" #include "hw/hw.h" #include "hw/isa/isa.h" #include "hw/i386/pc.h"
@@ -308,7 +309,8 @@ static void kbd_write_command(void *opaque, hwaddr addr,/* ignore that */ break ;default : -fprintf (stderr,"qemu: unsupported keyboard cmd=0x%02x\n" , (int )val); +qemu_log_mask (LOG_GUEST_ERROR , +"unsupported keyboard cmd=0x%02" PRIx64"\n" , val);break ; } }
Signature · 1 line
2.17.1
[Qemu-devel] [PULL 14/32] hw/arm/omap1: Use qemu_log_mask(GUEST_ERROR) instead of fprintf
In reply to Peter MaydellFrom: Philippe Mathieu-Daudé <[email protected]>
TCMI_VERBOSE is no more used, drop the OMAP_8/16/32B_REG macros.
Message-id: [email protected]
--- include/hw/arm/omap.h | 18 ------------------ hw/arm/omap1.c | 18 ++++++++++++------ 2 files changed, 12 insertions(+), 24 deletions(-)
include/hw/arm/omap.h +0 -18
@@ -993,24 +993,6 @@ enum {#define OMAP_GPIOSW_INVERTED 0x0001#define OMAP_GPIOSW_OUTPUT 0x0002 -# define TCMI_VERBOSE 1 - -# ifdef TCMI_VERBOSE -# define OMAP_8B_REG (paddr) \ - fprintf(stderr, "%s: 8-bit register " OMAP_FMT_plx "\n", \ - __func__, paddr) -# define OMAP_16B_REG (paddr) \ - fprintf(stderr, "%s: 16-bit register " OMAP_FMT_plx "\n", \ - __func__, paddr) -# define OMAP_32B_REG (paddr) \ - fprintf(stderr, "%s: 32-bit register " OMAP_FMT_plx "\n", \ - __func__, paddr) -# else -# define OMAP_8B_REG (paddr) -# define OMAP_16B_REG (paddr) -# define OMAP_32B_REG (paddr) -# endif -# define OMAP_MPUI_REG_MASK 0x000007ff#endif /* hw_omap_h */
hw/arm/omap1.c +12 -6
@@ -34,12 +34,18 @@#include "qemu/cutils.h" #include "qemu/bcd.h" +static inline void omap_log_badwidth (const char *funcname,hwaddr addr,int sz) +{ +qemu_log_mask (LOG_GUEST_ERROR ,"%s: %d-bit register %#08" HWADDR_PRIx"\n" , + funcname,8 * sz, addr); +} +/* Should signal the TCMI/GPMC */ uint32_t omap_badwidth_read8 (void *opaque,hwaddr addr) {uint8_t ret; -OMAP_8B_REG (addr); +omap_log_badwidth (__func__, addr,1 );cpu_physical_memory_read (addr, &ret,1 );return ret; }
@@ -49,7 +55,7 @@ void omap_badwidth_write8(void *opaque, hwaddr addr, {uint8_t val8 = value; -OMAP_8B_REG (addr); +omap_log_badwidth (__func__, addr,1 );cpu_physical_memory_write (addr, &val8,1 ); }
@@ -57,7 +63,7 @@ uint32_t omap_badwidth_read16(void *opaque, hwaddr addr) {uint16_t ret; -OMAP_16B_REG (addr); +omap_log_badwidth (__func__, addr,2 );cpu_physical_memory_read (addr, &ret,2 );return ret; }
@@ -67,7 +73,7 @@ void omap_badwidth_write16(void *opaque, hwaddr addr, {uint16_t val16 = value; -OMAP_16B_REG (addr); +omap_log_badwidth (__func__, addr,2 );cpu_physical_memory_write (addr, &val16,2 ); }
@@ -75,7 +81,7 @@ uint32_t omap_badwidth_read32(void *opaque, hwaddr addr) {uint32_t ret; -OMAP_32B_REG (addr); +omap_log_badwidth (__func__, addr,4 );cpu_physical_memory_read (addr, &ret,4 );return ret; }
@@ -83,7 +89,7 @@ uint32_t omap_badwidth_read32(void *opaque, hwaddr addr)void omap_badwidth_write32 (void *opaque,hwaddr addr,uint32_t value) { -OMAP_32B_REG (addr); +omap_log_badwidth (__func__, addr,4 );cpu_physical_memory_write (addr, &value,4 ); }
Signature · 1 line
2.17.1
[Qemu-devel] [PULL 06/32] MAINTAINERS: Add ASPEED BMCs
In reply to Peter MaydellFrom: Joel Stanley <[email protected]>
This adds Cedric as the maintainer, with Andrew and I as reviewers, for the ASPEED boards and the peripherals we have developed.
Message-id: [email protected]
--- MAINTAINERS | 11 +++++++++++ 1 file changed, 11 insertions(+)
MAINTAINERS +11 -0
@@ -645,6 +645,17 @@ M: Subbaraya Sundeep <[email protected]> S: Maintained F: hw/arm/msf2-som.c +ASPEED BMCs +M: Cédric Le Goater <[email protected]> +R: Andrew Jeffery <[email protected]> +R: Joel Stanley <[email protected]> +L: [email protected] +S: Maintained +F: hw/*/*aspeed* +F: include/hw/*/*aspeed* +F: hw/net/ftgmac100.c +F: include/hw/net/ftgmac100.h + CRIS Machines ------------- Axis Dev88
Signature · 1 line
2.17.1
[Qemu-devel] [PULL 08/32] hw/input/tsc2005: Use qemu_log_mask(GUEST_ERROR) instead of fprintf
In reply to Peter MaydellFrom: Philippe Mathieu-Daudé <[email protected]>
Message-id: [email protected]
--- hw/input/tsc2005.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
hw/input/tsc2005.c +8 -5
@@ -19,6 +19,7 @@*/ #include "qemu/osdep.h" +#include "qemu/log.h" #include "hw/hw.h" #include "qemu/timer.h" #include "ui/console.h"
@@ -208,9 +209,10 @@ static void tsc2005_write(TSC2005State *s, int reg, uint16_t data) } s->nextprecision = (data >>13 ) &1 ; s->timing[0 ] = data &0x1fff ; -if ((s->timing[0 ] >>11 ) ==3 ) -fprintf (stderr,"%s: illegal conversion clock setting\n" , - __func__); +if ((s->timing[0 ] >>11 ) ==3 ) { +qemu_log_mask (LOG_GUEST_ERROR , +"tsc2005_write: illegal conversion clock setting\n" ); + }break ;case 0xd :/* CFR1 */ s->timing[1 ] = data &0xf07 ;
@@ -221,8 +223,9 @@ static void tsc2005_write(TSC2005State *s, int reg, uint16_t data)break ;default : -fprintf (stderr,"%s: write into read-only register %x\n" , - __func__, reg); +qemu_log_mask (LOG_GUEST_ERROR , +"%s: write into read-only register 0x%x\n" , + __func__, reg); } }
Signature · 1 line
2.17.1
[Qemu-devel] [PULL 15/32] hw/arm/omap: Use qemu_log_mask(GUEST_ERROR) instead of fprintf
In reply to Peter MaydellFrom: Philippe Mathieu-Daudé <[email protected]>
Message-id: [email protected]
--- include/hw/arm/omap.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
include/hw/arm/omap.h +6 -6
@@ -21,6 +21,7 @@# define hw_omap_h "omap.h"#include "hw/irq.h" #include "target/arm/cpu-qom.h" +#include "qemu/log.h" # define OMAP_EMIFS_BASE 0x00000000# define OMAP2_Q0_BASE 0x00000000
@@ -944,8 +945,6 @@ struct omap_mpu_state_s *omap2420_mpu_init(MemoryRegion *sysmem,unsigned long sdram_size, const char *core); -#define OMAP_FMT_plx "%#08" HWADDR_PRIx -uint32_t omap_badwidth_read8 (void *opaque,hwaddr addr);void omap_badwidth_write8 (void *opaque,hwaddr addr,uint32_t value);
@@ -959,11 +958,12 @@ void omap_badwidth_write32(void *opaque, hwaddr addr,void omap_mpu_wakeup (void *opaque,int irq,int req);# define OMAP_BAD_REG (paddr) \ - fprintf(stderr, "%s: Bad register " OMAP_FMT_plx "\n", \ - __func__, paddr) + qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad register %#08"HWADDR_PRIx"\n", \ + __func__, paddr)# define OMAP_RO_REG (paddr) \ - fprintf(stderr, "%s: Read-only register " OMAP_FMT_plx "\n", \ - __func__, paddr) + qemu_log_mask(LOG_GUEST_ERROR, "%s: Read-only register %#08" \ + HWADDR_PRIx "\n", \ + __func__, paddr)/* OMAP-specific Linux bootloader tags for the ATAG_BOARD area (Board-specifc tags are not here) */
Signature · 1 line
2.17.1
[Qemu-devel] [PULL 16/32] hw/arm/stellaris: Use qemu_log_mask(UNIMP) instead of fprintf
In reply to Peter MaydellFrom: Philippe Mathieu-Daudé <[email protected]>
Message-id: [email protected]
--- hw/arm/stellaris.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/arm/stellaris.c +1 -1
@@ -560,7 +560,7 @@ static void ssys_write(void *opaque, hwaddr offset,case 0x040 :/* SRCR0 */ case 0x044 :/* SRCR1 */ case 0x048 :/* SRCR2 */ -fprintf (stderr,"Peripheral reset not implemented\n" ); +qemu_log_mask (LOG_UNIMP ,"Peripheral reset not implemented\n" );break ;case 0x054 :/* IMC */ s->int_mask = value &0x7f ;
Signature · 1 line
2.17.1
[Qemu-devel] [PULL 04/32] MAINTAINERS: Adopt the Gumstix computers-on-module machines
In reply to Peter MaydellFrom: Philippe Mathieu-Daudé <[email protected]>
These COMs are hard to find, and the companie dropped the support few years ago.
Per the "Gumstix Product Changes, Known Issues, and EOL" pdf:
- Phasing out: PXA270-based Verdex product line
September 2012
- Phasing out: PXA255-based Basix & Connex
September 2009
However there are still booting SD card image availables, very convenient to stress test the QEMU SD card implementation. Therefore I volunteer to keep an eye on this file, while it is useful for testing.
Message-id: [email protected]
--- MAINTAINERS | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
MAINTAINERS +2 -1
@@ -501,9 +501,10 @@ F: include/hw/arm/digic.h F: hw/*/digic* Gumstix +M: Philippe Mathieu-Daudé <[email protected]> L: [email protected] L: [email protected] -S: Orphan +S: Odd Fixes F: hw/arm/gumstix.c i.MX31
Signature · 1 line
2.17.1
[Qemu-devel] [PULL 05/32] xilinx_spips: Make dma transactions as per dma_burst_size
In reply to Peter MaydellFrom: Sai Pavan Boddu <[email protected]>
Qspi dma has a burst length of 64 bytes, So limit the transactions w.r.t dma-burst-size property.
Message-id: [email protected]
--- include/hw/ssi/xilinx_spips.h | 5 ++++- hw/ssi/xilinx_spips.c | 23 ++++++++++++++++++++--- 2 files changed, 24 insertions(+), 4 deletions(-)
include/hw/ssi/xilinx_spips.h +4 -1
@@ -37,6 +37,8 @@ typedef struct XilinxSPIPS XilinxSPIPS;/* Bite off 4k chunks at a time */ #define LQSPI_CACHE_SIZE 1024 +#define QSPI_DMA_MAX_BURST_SIZE 2048 + typedef enum { READ = 0x3, READ_4 = 0x13, FAST_READ = 0xb, FAST_READ_4 = 0x0c,
@@ -95,7 +97,6 @@ typedef struct {XilinxQSPIPS parent_obj;StreamSlave *dma; -uint8_t dma_buf[4 ];int gqspi_irqline;uint32_t regs[XLNX_ZYNQMP_SPIPS_R_MAX ];
@@ -113,6 +114,8 @@ typedef struct {uint8_t rx_fifo_g_align;uint8_t tx_fifo_g_align;bool man_start_com_g; +uint32_t dma_burst_size; +uint8_t dma_buf[QSPI_DMA_MAX_BURST_SIZE ]; } XlnxZynqMPQSPIPS; typedef struct XilinxSPIPSClass {
hw/ssi/xilinx_spips.c +20 -3
@@ -851,12 +851,17 @@ static void xlnx_zynqmp_qspips_notify(void *opaque) {size_t ret;uint32_t num; -const void *rxd =pop_buf (recv_fifo,4 , &num); +const void *rxd; +int len; + + len = recv_fifo->num >= rq->dma_burst_size ? rq->dma_burst_size : + recv_fifo->num; + rxd =pop_buf (recv_fifo, len, &num);memcpy (rq->dma_buf, rxd, num); - ret =stream_push (rq->dma, rq->dma_buf,4 ); -assert (ret ==4 ); + ret =stream_push (rq->dma, rq->dma_buf, num); +assert (ret == num);xlnx_zynqmp_qspips_check_flush (rq); } }
@@ -1333,6 +1338,12 @@ static void xlnx_zynqmp_qspips_realize(DeviceState *dev, Error **errp)XlnxZynqMPQSPIPS *s =XLNX_ZYNQMP_QSPIPS (dev);XilinxSPIPSClass *xsc =XILINX_SPIPS_GET_CLASS (s); +if (s->dma_burst_size >QSPI_DMA_MAX_BURST_SIZE ) { +error_setg (errp, +"qspi dma burst size %u exceeds maximum limit %d" , + s->dma_burst_size,QSPI_DMA_MAX_BURST_SIZE ); +return ; + }xilinx_qspips_realize (dev, errp);fifo8_create (&s->rx_fifo_g, xsc->rx_fifo_size);fifo8_create (&s->tx_fifo_g, xsc->tx_fifo_size);
@@ -1411,6 +1422,11 @@ static const VMStateDescription vmstate_xlnx_zynqmp_qspips = { } }; +static Property xilinx_zynqmp_qspips_properties[] = { +DEFINE_PROP_UINT32 ("dma-burst-size" , XlnxZynqMPQSPIPS, dma_burst_size,64 ), +DEFINE_PROP_END_OF_LIST (), +}; +static Property xilinx_qspips_properties[] = {/* We had to turn this off for 2.10 as it is not compatible with migration. * It can be enabled but will prevent the device to be migrated.
@@ -1463,6 +1479,7 @@ static void xlnx_zynqmp_qspips_class_init(ObjectClass *klass, void * data) dc->realize = xlnx_zynqmp_qspips_realize; dc->reset = xlnx_zynqmp_qspips_reset; dc->vmsd = &vmstate_xlnx_zynqmp_qspips; + dc->props = xilinx_zynqmp_qspips_properties; xsc->reg_ops = &xlnx_zynqmp_qspips_ops; xsc->rx_fifo_size =RXFF_A_Q ; xsc->tx_fifo_size =TXFF_A_Q ;
Signature · 1 line
2.17.1
[Qemu-devel] [PULL 17/32] hw/net/stellaris_enet: Fix a typo
In reply to Peter MaydellFrom: Philippe Mathieu-Daudé <[email protected]>
Message-id: [email protected]
--- hw/net/stellaris_enet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/net/stellaris_enet.c +1 -1
@@ -340,7 +340,7 @@ static uint64_t stellaris_enet_read(void *opaque, hwaddr offset,return s->np;case 0x38 :/* TR */ return 0 ; -case 0x3c :/* Undocuented: Timestamp? */ +case 0x3c :/* Undocumented: Timestamp? */ return 0 ;default :hw_error ("stellaris_enet_read: Bad offset %x\n" , (int )offset);
Signature · 1 line
2.17.1
[Qemu-devel] [PULL 01/32] aspeed/smc: fix dummy cycles count when in dual IO mode
In reply to Peter MaydellFrom: Cédric Le Goater <[email protected]>
When configured in dual I/O mode, address and data are sent in dual mode, including the dummy byte cycles in between. Adapt the count to the IO setting.
Message-id: [email protected]
--- hw/ssi/aspeed_smc.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
hw/ssi/aspeed_smc.c +8 -1
@@ -66,6 +66,8 @@/* CEx Control Register */ #define R_CTRL0 (0x10 / 4) +#define CTRL_IO_DUAL_DATA (1 << 29) +#define CTRL_IO_DUAL_ADDR_DATA (1 << 28)/* Includes dummies */ #define CTRL_CMD_SHIFT 16#define CTRL_CMD_MASK 0xff#define CTRL_DUMMY_HIGH_SHIFT 14
@@ -492,8 +494,13 @@ static int aspeed_smc_flash_dummies(const AspeedSMCFlash *fl)uint32_t r_ctrl0 = s->regs[s->r_ctrl0 + fl->id];uint32_t dummy_high = (r_ctrl0 >>CTRL_DUMMY_HIGH_SHIFT ) &0x1 ;uint32_t dummy_low = (r_ctrl0 >>CTRL_DUMMY_LOW_SHIFT ) &0x3 ; +uint32_t dummies = ((dummy_high <<2 ) | dummy_low) *8 ; -return ((dummy_high <<2 ) | dummy_low) *8 ; +if (r_ctrl0 &CTRL_IO_DUAL_ADDR_DATA ) { + dummies /=2 ; + } + +return dummies; }static void aspeed_smc_flash_send_addr (AspeedSMCFlash *fl,uint32_t addr)
Signature · 1 line
2.17.1
[Qemu-devel] [PULL 02/32] aspeed/smc: fix HW strapping
In reply to Peter MaydellFrom: Cédric Le Goater <[email protected]>
Only the flash type is strapped by HW. The 4BYTE mode is set by firmware when the flash device is detected.
Message-id: [email protected]
--- hw/ssi/aspeed_smc.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
hw/ssi/aspeed_smc.c +1 -7
@@ -639,23 +639,17 @@ static void aspeed_smc_reset(DeviceState *d)aspeed_smc_segment_to_reg (&s->ctrl->segments[i]); } -/* HW strapping for AST2500 FMC controllers */ +/* HW strapping flash type for FMC controllers */ if (s->ctrl->segments == aspeed_segments_ast2500_fmc) {/* flash type is fixed to SPI for CE0 and CE1 */ s->regs[s->r_conf] |= (CONF_FLASH_TYPE_SPI <<CONF_FLASH_TYPE0 ); s->regs[s->r_conf] |= (CONF_FLASH_TYPE_SPI <<CONF_FLASH_TYPE1 ); - -/* 4BYTE mode is autodetected for CE0. Let's force it to 1 for -* now */ - s->regs[s->r_ce_ctrl] |= (1 << (CTRL_EXTENDED0 )); }/* HW strapping for AST2400 FMC controllers (SCU70). Let's use the * configuration of the palmetto-bmc machine */ if (s->ctrl->segments == aspeed_segments_fmc) { s->regs[s->r_conf] |= (CONF_FLASH_TYPE_SPI <<CONF_FLASH_TYPE0 ); - - s->regs[s->r_ce_ctrl] |= (1 << (CTRL_EXTENDED0 )); } }
Signature · 1 line
2.17.1
[Qemu-devel] [PULL 03/32] aspeed/smc: rename aspeed_smc_flash_send_addr() to aspeed_smc_flash_setup()
In reply to Peter MaydellFrom: Cédric Le Goater <[email protected]>
Also handle the fake transfers for dummy bytes in this setup routine. It will be useful when we activate MMIO execution.
Message-id: [email protected]
--- hw/ssi/aspeed_smc.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-)
hw/ssi/aspeed_smc.c +16 -15
@@ -503,10 +503,11 @@ static int aspeed_smc_flash_dummies(const AspeedSMCFlash *fl)return dummies; } -static void aspeed_smc_flash_send_addr (AspeedSMCFlash *fl,uint32_t addr) +static void aspeed_smc_flash_setup (AspeedSMCFlash *fl,uint32_t addr) {const AspeedSMCState *s = fl->controller;uint8_t cmd =aspeed_smc_flash_cmd (fl); +int i;/* Flash access can not exceed CS segment */ addr =aspeed_smc_check_segment_addr (fl, addr);
@@ -519,6 +520,18 @@ static void aspeed_smc_flash_send_addr(AspeedSMCFlash *fl, uint32_t addr)ssi_transfer (s->spi, (addr >>16 ) &0xff );ssi_transfer (s->spi, (addr >>8 ) &0xff );ssi_transfer (s->spi, (addr &0xff )); + +/* +* Use fake transfers to model dummy bytes. The value should +* be configured to some non-zero value in fast read mode and +* zero in read mode. But, as the HW allows inconsistent +* settings, let's check for fast read mode. +*/ +if (aspeed_smc_flash_mode (fl) ==CTRL_FREADMODE ) { +for (i =0 ; i <aspeed_smc_flash_dummies (fl); i++) { +ssi_transfer (fl->controller->spi,0xFF ); + } + } }static uint64_t aspeed_smc_flash_read (void *opaque,hwaddr addr,unsigned size)
@@ -537,19 +550,7 @@ static uint64_t aspeed_smc_flash_read(void *opaque, hwaddr addr, unsigned size)case CTRL_READMODE :case CTRL_FREADMODE :aspeed_smc_flash_select (fl); -aspeed_smc_flash_send_addr (fl, addr); - -/* -* Use fake transfers to model dummy bytes. The value should -* be configured to some non-zero value in fast read mode and -* zero in read mode. But, as the HW allows inconsistent -* settings, let's check for fast read mode. -*/ -if (aspeed_smc_flash_mode (fl) ==CTRL_FREADMODE ) { -for (i =0 ; i <aspeed_smc_flash_dummies (fl); i++) { -ssi_transfer (fl->controller->spi,0xFF ); - } - } +aspeed_smc_flash_setup (fl, addr);for (i =0 ; i < size; i++) { ret |=ssi_transfer (s->spi,0x0 ) << (8 * i);
@@ -586,7 +587,7 @@ static void aspeed_smc_flash_write(void *opaque, hwaddr addr, uint64_t data,break ;case CTRL_WRITEMODE :aspeed_smc_flash_select (fl); -aspeed_smc_flash_send_addr (fl, addr); +aspeed_smc_flash_setup (fl, addr);for (i =0 ; i < size; i++) {ssi_transfer (s->spi, (data >> (8 * i)) &0xff );
Signature · 1 line
2.17.1
[Qemu-devel] [PULL 18/32] hw/net/stellaris_enet: Use qemu_log_mask(GUEST_ERROR) instead of hw_error
In reply to Peter MaydellFrom: Philippe Mathieu-Daudé <[email protected]>
hw_error() finally calls abort(), but there is no need to abort here.
Message-id: [email protected]
--- hw/net/stellaris_enet.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
hw/net/stellaris_enet.c +7 -2
@@ -9,6 +9,7 @@#include "qemu/osdep.h" #include "hw/sysbus.h" #include "net/net.h" +#include "qemu/log.h" #include <zlib.h> //#define DEBUG_STELLARIS_ENET 1
@@ -343,7 +344,9 @@ static uint64_t stellaris_enet_read(void *opaque, hwaddr offset,case 0x3c :/* Undocumented: Timestamp? */ return 0 ;default : -hw_error ("stellaris_enet_read: Bad offset %x\n" , (int )offset); +qemu_log_mask (LOG_GUEST_ERROR ,"stellaris_enet_rd%d: Illegal register" +" 0x02%" HWADDR_PRIx"\n" , + size *8 , offset);return 0 ; } }
@@ -442,7 +445,9 @@ static void stellaris_enet_write(void *opaque, hwaddr offset,/* Ignored. */ break ;default : -hw_error ("stellaris_enet_write: Bad offset %x\n" , (int )offset); +qemu_log_mask (LOG_GUEST_ERROR ,"stellaris_enet_wr%d: Illegal register " +"0x02%" HWADDR_PRIx" = 0x%" PRIx64"\n" , + size *8 , offset, value); } }
Signature · 1 line
2.17.1
[Qemu-devel] [PULL 19/32] hw/net/smc91c111: Use qemu_log_mask(GUEST_ERROR) instead of hw_error
In reply to Peter MaydellFrom: Philippe Mathieu-Daudé <[email protected]>
hw_error() finally calls abort(), but there is no need to abort here.
Message-id: [email protected]
--- hw/net/smc91c111.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
hw/net/smc91c111.c +7 -2
@@ -11,6 +11,7 @@#include "hw/sysbus.h" #include "net/net.h" #include "hw/devices.h" +#include "qemu/log.h" /* For crc32 */ #include <zlib.h>
@@ -478,7 +479,9 @@ static void smc91c111_writeb(void *opaque, hwaddr offset, }break ; } -hw_error ("smc91c111_write: Bad reg %d:%x\n" , s->bank, (int )offset); +qemu_log_mask (LOG_GUEST_ERROR ,"smc91c111_write(bank:%d) Illegal register" +" 0x%" HWADDR_PRIx" = 0x%x\n" , + s->bank, offset, value); }static uint32_t smc91c111_readb (void *opaque,hwaddr offset)
@@ -621,7 +624,9 @@ static uint32_t smc91c111_readb(void *opaque, hwaddr offset) }break ; } -hw_error ("smc91c111_read: Bad reg %d:%x\n" , s->bank, (int )offset); +qemu_log_mask (LOG_GUEST_ERROR ,"smc91c111_read(bank:%d) Illegal register" +" 0x%" HWADDR_PRIx"\n" , + s->bank, offset);return 0 ; }
Signature · 1 line
2.17.1
[Qemu-devel] [PULL 20/32] hw/net/smc91c111: Use qemu_log_mask(UNIMP) instead of fprintf
In reply to Peter MaydellFrom: Philippe Mathieu-Daudé <[email protected]>
Message-id: [email protected]
--- hw/net/smc91c111.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
hw/net/smc91c111.c +8 -4
@@ -362,10 +362,14 @@ static void smc91c111_writeb(void *opaque, hwaddr offset,SET_HIGH (gpr, value);return ;case 12 :/* Control */ -if (value &1 ) -fprintf (stderr,"smc91c111:EEPROM store not implemented\n" ); -if (value &2 ) -fprintf (stderr,"smc91c111:EEPROM reload not implemented\n" ); +if (value &1 ) { +qemu_log_mask (LOG_UNIMP , +"smc91c111: EEPROM store not implemented\n" ); + } +if (value &2 ) { +qemu_log_mask (LOG_UNIMP , +"smc91c111: EEPROM reload not implemented\n" ); + } value &= ~3 ;SET_LOW (ctr, value);return ;
Signature · 1 line
2.17.1
[Qemu-devel] [PULL 21/32] hw/arm/stellaris: Fix gptm_write() error message
In reply to Peter MaydellFrom: Philippe Mathieu-Daudé <[email protected]>
Missed in df3692e04b2.
Message-id: [email protected]
--- hw/arm/stellaris.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/arm/stellaris.c +1 -1
@@ -294,7 +294,7 @@ static void gptm_write(void *opaque, hwaddr offset,break ;default :qemu_log_mask (LOG_GUEST_ERROR , -"GPTM: read at bad offset 0x%x\n" , (int )offset); +"GPTM: write at bad offset 0x%x\n" , (int )offset); }gptm_update_irq (s); }
Signature · 1 line
2.17.1
[Qemu-devel] [PULL 22/32] hw/arm/stellaris: Use HWADDR_PRIx to display register address
In reply to Peter MaydellFrom: Philippe Mathieu-Daudé <[email protected]>
Message-id: [email protected]
--- hw/arm/stellaris.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
hw/arm/stellaris.c +4 -2
@@ -212,7 +212,8 @@ static uint64_t gptm_read(void *opaque, hwaddr offset,return 0 ;default :qemu_log_mask (LOG_GUEST_ERROR , -"GPTM: read at bad offset 0x%x\n" , (int )offset); +"GPTM: read at bad offset 0x02%" HWADDR_PRIx"\n" , + offset);return 0 ; } }
@@ -294,7 +295,8 @@ static void gptm_write(void *opaque, hwaddr offset,break ;default :qemu_log_mask (LOG_GUEST_ERROR , -"GPTM: write at bad offset 0x%x\n" , (int )offset); +"GPTM: write at bad offset 0x02%" HWADDR_PRIx"\n" , + offset); }gptm_update_irq (s); }
Signature · 1 line
2.17.1
[Qemu-devel] [PULL 23/32] tcg: Support MMU protection regions smaller than TARGET_PAGE_SIZE
In reply to Peter MaydellAdd support for MMU protection regions that are smaller than TARGET_PAGE_SIZE. We do this by marking the TLB entry for those pages with a flag TLB_RECHECK. This flag causes us to always take the slow-path for accesses. In the slow path we can then special case them to always call tlb_fill() again, so we have the correct information for the exact address being accessed.
This change allows us to handle reading and writing from small regions; we cannot deal with execution from the small region.
Message-id: [email protected]
--- accel/tcg/softmmu_template.h | 24 ++++--- include/exec/cpu-all.h | 5 +- accel/tcg/cputlb.c | 131 +++++++++++++++++++++++++++++------ 3 files changed, 130 insertions(+), 30 deletions(-)
accel/tcg/softmmu_template.h +16 -8
@@ -98,10 +98,12 @@static inline DATA_TYPE glue (io_read ,SUFFIX )(CPUArchState *env,size_t mmu_idx,size_t index,target_ulong addr, -uintptr_t retaddr) +uintptr_t retaddr, +bool recheck) {CPUIOTLBEntry *iotlbentry = &env->iotlb[mmu_idx][index]; -return io_readx (env, iotlbentry, mmu_idx, addr, retaddr,DATA_SIZE ); +return io_readx (env, iotlbentry, mmu_idx, addr, retaddr, recheck, +DATA_SIZE ); }#endif
@@ -138,7 +140,8 @@ WORD_TYPE helper_le_ld_name(CPUArchState *env, target_ulong addr,/* ??? Note that the io helpers always read data in the target byte ordering. We should push the LE/BE request down into io. */ - res =glue (io_read,SUFFIX )(env, mmu_idx, index, addr, retaddr); + res =glue (io_read,SUFFIX )(env, mmu_idx, index, addr, retaddr, + tlb_addr &TLB_RECHECK ); res =TGT_LE (res);return res; }
@@ -205,7 +208,8 @@ WORD_TYPE helper_be_ld_name(CPUArchState *env, target_ulong addr,/* ??? Note that the io helpers always read data in the target byte ordering. We should push the LE/BE request down into io. */ - res =glue (io_read,SUFFIX )(env, mmu_idx, index, addr, retaddr); + res =glue (io_read,SUFFIX )(env, mmu_idx, index, addr, retaddr, + tlb_addr &TLB_RECHECK ); res =TGT_BE (res);return res; }
@@ -259,10 +263,12 @@ static inline void glue(io_write, SUFFIX)(CPUArchState *env, size_t mmu_idx, size_t index, DATA_TYPE val, target_ulong addr, - uintptr_t retaddr) + uintptr_t retaddr, + bool recheck) { CPUIOTLBEntry *iotlbentry = &env->iotlb[mmu_idx][index]; -return io_writex (env, iotlbentry, mmu_idx, val, addr, retaddr,DATA_SIZE ); +return io_writex (env, iotlbentry, mmu_idx, val, addr, retaddr, + recheck,DATA_SIZE ); } void helper_le_st_name(CPUArchState *env, target_ulong addr, DATA_TYPE val,
@@ -298,7 +304,8 @@ void helper_le_st_name(CPUArchState *env, target_ulong addr, DATA_TYPE val,/* ??? Note that the io helpers always read data in the target byte ordering. We should push the LE/BE request down into io. */ val =TGT_LE (val); -glue (io_write,SUFFIX )(env, mmu_idx, index, val, addr, retaddr); +glue (io_write,SUFFIX )(env, mmu_idx, index, val, addr, + retaddr, tlb_addr &TLB_RECHECK );return ; }
@@ -375,7 +382,8 @@ void helper_be_st_name(CPUArchState *env, target_ulong addr, DATA_TYPE val,/* ??? Note that the io helpers always read data in the target byte ordering. We should push the LE/BE request down into io. */ val =TGT_BE (val); -glue (io_write,SUFFIX )(env, mmu_idx, index, val, addr, retaddr); +glue (io_write,SUFFIX )(env, mmu_idx, index, val, addr, retaddr, + tlb_addr &TLB_RECHECK );return ; }
include/exec/cpu-all.h +4 -1
@@ -330,11 +330,14 @@ CPUArchState *cpu_copy(CPUArchState *env);#define TLB_NOTDIRTY (1 << (TARGET_PAGE_BITS - 2))/* Set if TLB entry is an IO callback. */ #define TLB_MMIO (1 << (TARGET_PAGE_BITS - 3)) +/* Set if TLB entry must have MMU lookup repeated for every access */ +#define TLB_RECHECK (1 << (TARGET_PAGE_BITS - 4))/* Use this mask to check interception with an alignment mask * in a TCG backend. */ -#define TLB_FLAGS_MASK (TLB_INVALID_MASK | TLB_NOTDIRTY | TLB_MMIO) +#define TLB_FLAGS_MASK (TLB_INVALID_MASK | TLB_NOTDIRTY | TLB_MMIO \ + | TLB_RECHECK)void dump_exec_info (FILE *f,fprintf_function cpu_fprintf);void dump_opcount_info (FILE *f,fprintf_function cpu_fprintf);
accel/tcg/cputlb.c +110 -21
212 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [Qemu-devel] [PULL 23/32] tcg: Support MMU protection regions smaller than TARGET_PAGE_SIZE
Le 26/06/2018 à 18:56, Peter Maydell a écrit :
Quoted 10 lines
Add support for MMU protection regions that are smaller than
TARGET_PAGE_SIZE. We do this by marking the TLB entry for those pages with a flagTLB_RECHECK. This flag causes us to always take the slow-path for accesses. In the slow path we can then special case them to always calltlb_fill()again, so we have the correct information for the exact address being accessed.This change allows us to handle reading and writing from small regions; we cannot deal with execution from the small region.
Quoted 8 lines
Signed-off-by Peter Maydell <[email protected]>Reviewed-by Richard Henderson <[email protected]>Message-id: [email protected]
--- accel/tcg/softmmu_template.h | 24 ++++--- include/exec/cpu-all.h | 5 +- accel/tcg/cputlb.c | 131 +++++++++++++++++++++++++++++------ 3 files changed, 130 insertions(+), 30 deletions(-)
This patch breaks Quadra 800 emulation, any idea why?
ABCFGHIJK
qemu: fatal: Unable to handle guest executing from RAM within a small MPU region at 0x0014cb5a
D0 = 0000006a A0 = 002d8a19 F0 = 7fff ffffffffffffffff ( nan) D1 = 00000010 A1 = 002d8a19 F1 = 7fff ffffffffffffffff ( nan) D2 = 000003e0 A2 = 00332310 F2 = 7fff ffffffffffffffff ( nan) D3 = 00000000 A3 = 00331f98 F3 = 7fff ffffffffffffffff ( nan) D4 = 0036da87 A4 = 0036daa3 F4 = 7fff ffffffffffffffff ( nan) D5 = 000003e0 A5 = 0036de67 F5 = 7fff ffffffffffffffff ( nan) D6 = 002d8a18 A6 = 002d8a1a F6 = 7fff ffffffffffffffff ( nan) D7 = 0014ac46 A7 = 00331ed8 F7 = 7fff ffffffffffffffff ( nan) PC = 0014cb5a SR = 2700 T:0 I:7 SI -----
FPSR = 00000000 ---- -------- ----- FPCR = 0000 X RN --------
A7(MSP) = 00000000 A7(USP) = 00000000 ->A7(ISP) = 00331f38
VBR = 0x00364528
SFC = 0 DFC 0
SSW 00000000 TCR 00008000 URP 00000000 SRP 00001000 DTTR0/1: 00000000/f807a040 ITTR0/1: 00000000/f807a040 MMUSR 00000000, fault at 00000000
Aborted (core dumped)
Laurent
Re: [Qemu-devel] [PULL 23/32] tcg: Support MMU protection regions smaller than TARGET_PAGE_SIZE
Quoted 20 lines · Laurent Vivier
Quoted 10 lines · Peter Maydell
Add support for MMU protection regions that are smaller than
TARGET_PAGE_SIZE. We do this by marking the TLB entry for those pages with a flagTLB_RECHECK. This flag causes us to always take the slow-path for accesses. In the slow path we can then special case them to always calltlb_fill()again, so we have the correct information for the exact address being accessed.This change allows us to handle reading and writing from small regions; we cannot deal with execution from the small region.
Quoted 8 lines
Signed-off-by Peter Maydell <[email protected]>Reviewed-by Richard Henderson <[email protected]>Message-id: [email protected]
--- accel/tcg/softmmu_template.h | 24 ++++--- include/exec/cpu-all.h | 5 +- accel/tcg/cputlb.c | 131 +++++++++++++++++++++++++++++------ 3 files changed, 130 insertions(+), 30 deletions(-)
Quoted 5 lines
This patch breaks Quadra 800 emulation, any idea why?
ABCFGHIJK
qemu: fatal: Unable to handle guest executing from RAM within a small MPU region at0x0014cb5a
Hmm, that shouldn't happen unless your target code was incorrectly returning a too-small page size. (I say "incorrectly" because before this patchseries that was unsupported and would have had weird effects depending on exactly what the order of guest accesses to the page was.)
You could look at whether the m68k code is calling tlb_set_page() with a wrong page_size value and why that happens. You can get back the old behaviour by having your code do
if (page_size < TARGET_PAGE_SIZE) {
page_size = TARGET_PAGE_SIZE;}
but that is definitely a bit of a hack.
Does the m68k MMU let you specify permissions and mappings for sub-page sizes ?
I do notice an oddity:
in m68k_cpu_handle_mmu_fault() we call get_physical_address() but then ignore the page_size it returns when we call tlb_set_page() and instead use TARGET_PAGE_SIZE. But in the ptest helper function we use the page_size from get_physical_address() directly. Are these bits of code deliberately different?
In fact it's not clear to me at all that PTEST should be updating the QEMU TLB: it only needs to update the MMU status registers. (The 68030 manual I have says that in hardware PTEST doesn't update the ATC, which is the h/w equivalent to doing a TLB update.)
thanks
-- PMM
Re: [Qemu-devel] [PULL 23/32] tcg: Support MMU protection regions smaller than TARGET_PAGE_SIZE
Le 28/06/2018 à 15:23, Peter Maydell a écrit :
Quoted 33 lines · Laurent Vivier
Quoted 20 lines · Peter Maydell
Quoted 10 lines
Add support for MMU protection regions that are smaller than
TARGET_PAGE_SIZE. We do this by marking the TLB entry for those pages with a flagTLB_RECHECK. This flag causes us to always take the slow-path for accesses. In the slow path we can then special case them to always calltlb_fill()again, so we have the correct information for the exact address being accessed.This change allows us to handle reading and writing from small regions; we cannot deal with execution from the small region.
Quoted 8 lines
Signed-off-by Peter Maydell <[email protected]>Reviewed-by Richard Henderson <[email protected]>Message-id: [email protected]
--- accel/tcg/softmmu_template.h | 24 ++++--- include/exec/cpu-all.h | 5 +- accel/tcg/cputlb.c | 131 +++++++++++++++++++++++++++++------ 3 files changed, 130 insertions(+), 30 deletions(-)Quoted 5 lines
This patch breaks Quadra 800 emulation, any idea why?
ABCFGHIJK
qemu: fatal: Unable to handle guest executing from RAM within a small MPU region at0x0014cb5aHmm, that shouldn't happen unless your target code was incorrectly returning a too-small page size. (I say "incorrectly" because before this patchseries that was unsupported and would have had weird effects depending on exactly what the order of guest accesses to the page was.)
Quoted 8 lines
You could look at whether the m68k code is calling
tlb_set_page()with a wrongpage_sizevalue and why that happens. You can get back the old behaviour by having your code doif (page_size < TARGET_PAGE_SIZE) { page_size = TARGET_PAGE_SIZE;}
but that is definitely a bit of a hack.
Thank you to have had a look at this.
I've added traces and tlb_set_page() is always called with page_size == TARGET_PAGE_SIZE.
m68k linux kernel always use 4 kB page that is the value of TARGET_PAGE_SIZE.
68040 MMU can also use 8 kB page, but in our case it doesn't (and of course 8 kB > TARGET_PAGE_SIZE).
Quoted 2 lines
Does the m68k MMU let you specify permissions and mappings for sub-page sizes ?
I'm not aware of subpage in m68k MMU. but we have TLB entries that are separated between code and data: does it change something in your code? Accessing an address as a data access and then as an instruction access could appear like a TLB_RECHECK?
Quoted 6 lines
I do notice an oddity:
inm68k_cpu_handle_mmu_fault()we callget_physical_address()but then ignore thepage_sizeit returns when we calltlb_set_page()and instead useTARGET_PAGE_SIZE. But in the ptest helper function we use thepage_sizefromget_physical_address()directly. Are these bits of code deliberately different?
I remember I had problem to make this to work. But I think you're right, it should be page_size everywhere. But I guess it's not the cause of my problem (I tried :) )...
Quoted 5 lines
In fact it's not clear to me at all that PTEST should be updating the QEMU TLB: it only needs to update the MMU status registers. (The 68030 manual I have says that in hardware PTEST doesn't update the ATC, which is the h/w equivalent to doing a TLB update.)
In QEMU, we emulate for the moment the 68040 MMU, and PTEST for 68040 is not defined as the one for 68030.
For 68040, we have:
"A matching entry in the address translation cache (data or instruction) specified by the function code will be flushed by PTEST. Completion of PTEST results in the creation of a new address translation cache entry"
Thanks,
Laurent
Re: [Qemu-devel] [PULL 23/32] tcg: Support MMU protection regions smaller than TARGET_PAGE_SIZE
Quoted 53 lines · Laurent Vivier
Quoted 33 lines · Peter Maydell
Quoted 20 lines · Laurent Vivier
Quoted 10 lines · Peter Maydell
Add support for MMU protection regions that are smaller than
TARGET_PAGE_SIZE. We do this by marking the TLB entry for those pages with a flagTLB_RECHECK. This flag causes us to always take the slow-path for accesses. In the slow path we can then special case them to always calltlb_fill()again, so we have the correct information for the exact address being accessed.This change allows us to handle reading and writing from small regions; we cannot deal with execution from the small region.
Quoted 8 lines
Signed-off-by Peter Maydell <[email protected]>Reviewed-by Richard Henderson <[email protected]>Message-id: [email protected]
--- accel/tcg/softmmu_template.h | 24 ++++--- include/exec/cpu-all.h | 5 +- accel/tcg/cputlb.c | 131 +++++++++++++++++++++++++++++------ 3 files changed, 130 insertions(+), 30 deletions(-)Quoted 5 lines
This patch breaks Quadra 800 emulation, any idea why?
ABCFGHIJK
qemu: fatal: Unable to handle guest executing from RAM within a small MPU region at0x0014cb5aHmm, that shouldn't happen unless your target code was incorrectly returning a too-small page size. (I say "incorrectly" because before this patchseries that was unsupported and would have had weird effects depending on exactly what the order of guest accesses to the page was.)
Quoted 8 lines
You could look at whether the m68k code is calling
tlb_set_page()with a wrongpage_sizevalue and why that happens. You can get back the old behaviour by having your code doif (page_size < TARGET_PAGE_SIZE) { page_size = TARGET_PAGE_SIZE;}
but that is definitely a bit of a hack.
Thank you to have had a look at this.
I've added traces and
tlb_set_page()is always called withpage_size==TARGET_PAGE_SIZE.m68k linux kernel always use 4 kB page that is the value of
TARGET_PAGE_SIZE.
68040 MMU can also use 8 kB page, but in our case it doesn't (and of course 8 kB >TARGET_PAGE_SIZE).
Quoted 4 lines
I'm not aware of subpage in m68k MMU. but we have TLB entries that are separated between code and data: does it change something in your code? Accessing an address as a data access and then as an instruction access could appear like a
TLB_RECHECK?
If you never pass a page_size < TARGET_PAGE_SIZE to tlb_set_page() then we should never mark anything as TLB_RECHECK:
the theory was no behaviour change for the currently-being-used case.
Do you have a repro case (images, command line) that I can use to investigate ?
Quoted 6 lines
Quoted 5 lines
In fact it's not clear to me at all that PTEST should be updating the QEMU TLB: it only needs to update the MMU status registers. (The 68030 manual I have says that in hardware PTEST doesn't update the ATC, which is the h/w equivalent to doing a TLB update.)
Quoted 8 lines
In QEMU, we emulate for the moment the 68040 MMU, and PTEST for 68040 is not defined as the one for 68030.
For 68040, we have:
"A matching entry in the address translation cache (data or instruction) specified by the function code will be flushed by PTEST. Completion of PTEST results in the creation of a new address translation cache entry"
Oh, OK. Since the QEMU TLB isn't really the same as the hardware TLB then it isn't strictly required to update our TLB here, but if the hardware does that then it doesn't hurt.
thanks
-- PMM
Re: [Qemu-devel] [PULL 23/32] tcg: Support MMU protection regions smaller than TARGET_PAGE_SIZE
Le 28/06/2018 à 22:05, Peter Maydell a écrit :
Quoted 59 lines · Laurent Vivier
Quoted 53 lines · Peter Maydell
Quoted 33 lines · Laurent Vivier
Quoted 20 lines · Peter Maydell
Quoted 10 lines
Add support for MMU protection regions that are smaller than
TARGET_PAGE_SIZE. We do this by marking the TLB entry for those pages with a flagTLB_RECHECK. This flag causes us to always take the slow-path for accesses. In the slow path we can then special case them to always calltlb_fill()again, so we have the correct information for the exact address being accessed.This change allows us to handle reading and writing from small regions; we cannot deal with execution from the small region.
Quoted 8 lines
Signed-off-by Peter Maydell <[email protected]>Reviewed-by Richard Henderson <[email protected]>Message-id: [email protected]
--- accel/tcg/softmmu_template.h | 24 ++++--- include/exec/cpu-all.h | 5 +- accel/tcg/cputlb.c | 131 +++++++++++++++++++++++++++++------ 3 files changed, 130 insertions(+), 30 deletions(-)Quoted 5 lines
This patch breaks Quadra 800 emulation, any idea why?
ABCFGHIJK
qemu: fatal: Unable to handle guest executing from RAM within a small MPU region at0x0014cb5aHmm, that shouldn't happen unless your target code was incorrectly returning a too-small page size. (I say "incorrectly" because before this patchseries that was unsupported and would have had weird effects depending on exactly what the order of guest accesses to the page was.)
Quoted 8 lines
You could look at whether the m68k code is calling
tlb_set_page()with a wrongpage_sizevalue and why that happens. You can get back the old behaviour by having your code doif (page_size < TARGET_PAGE_SIZE) { page_size = TARGET_PAGE_SIZE;}
but that is definitely a bit of a hack.
Thank you to have had a look at this.
I've added traces and
tlb_set_page()is always called withpage_size==TARGET_PAGE_SIZE.m68k linux kernel always use 4 kB page that is the value of
TARGET_PAGE_SIZE.
68040 MMU can also use 8 kB page, but in our case it doesn't (and of course 8 kB >TARGET_PAGE_SIZE).Quoted 4 lines
I'm not aware of subpage in m68k MMU. but we have TLB entries that are separated between code and data: does it change something in your code? Accessing an address as a data access and then as an instruction access could appear like a
TLB_RECHECK?
Quoted 6 lines
If you never pass a
page_size<TARGET_PAGE_SIZEtotlb_set_page()then we should never mark anything asTLB_RECHECK:
the theory was no behaviour change for the currently-being-used case.Do you have a repro case (images, command line) that I can use to investigate ?
- checkout the branch q800-dev-part1 from
git://github.com/vivier/qemu-m68k.git
- configure and build
'./configure' '--target-list=m68k-softmmu' '--enable-debug' \
'--enable-debug-tcg' '--enable-debug-info'my gcc is from Fedora 27, version 7.3.1 20180303 (Red Hat 7.3.1-5)
- get the kernel from the debian installer:
wget
https://cdimage.debian.org/mirror/cdimage/ports/9.0/m68k/iso-cd/debian-9.0-m68k-NETINST-1.iso
guestfish --add debian-9.0-m68k-NETINST-1.iso --ro \
--mount /dev/sda:/ <<_EOF_copy-out /install/kernels/vmlinux-4.15.0-2-m68k .
_EOF_
- and run
./m68k-softmmu/qemu-system-m68k -M q800 \
-serial none -serial mon:stdio \
-kernel vmlinux-4.15.0-2-m68k \
-nographicABCFGHIJK
qemu: fatal: Unable to handle guest executing from RAM within a small MPU region at 0x0029bb2c
D0 = 003ca111 A0 = 003ca111 F0 = 7fff ffffffffffffffff ( nan) D1 = 00000000 A1 = 0000000a F1 = 7fff ffffffffffffffff ( nan) D2 = 00000000 A2 = 00395314 F2 = 7fff ffffffffffffffff ( nan) D3 = 00000001 A3 = 003ca110 F3 = 7fff ffffffffffffffff ( nan) D4 = 000003e0 A4 = 003ca4e8 F4 = 7fff ffffffffffffffff ( nan) D5 = 00393fc8 A5 = 0033d77b F5 = 7fff ffffffffffffffff ( nan) D6 = 003ca108 A6 = 00393fc4 F6 = 7fff ffffffffffffffff ( nan) D7 = 00000002 A7 = 00393ef8 F7 = 7fff ffffffffffffffff ( nan) PC = 0029bb2c SR = 2700 T:0 I:7 SI -----
FPSR = 00000000 ---- -------- ----- FPCR = 0000 X RN --------
A7(MSP) = 00000000 A7(USP) = 00000000 ->A7(ISP) = 00393f68
VBR = 0x003bfce8
SFC = 5 DFC 5
SSW 00000000 TCR 00008000 URP 00000000 SRP 00001000 DTTR0/1: 00000000/f807a040 ITTR0/1: 00000000/f807a040 MMUSR 00000000, fault at 00000000
Aborted (core dumped)
Thanks,
Laurent
Re: [Qemu-devel] [PULL 23/32] tcg: Support MMU protection regions smaller than TARGET_PAGE_SIZE
Quoted 4 lines · Laurent Vivier
./m68k-softmmu/qemu-system-m68k -M q800 \
-serial none -serial mon:stdio \
-kernel vmlinux-4.15.0-2-m68k \
-nographicThanks for the test case. I'm still investigating, but there are a couple of things happening here.
First, there's a bug in get_page_addr_code()'s "is this a TLB miss?" condition which was introduced in commit 71b9a45330fe22:
if (unlikely(env->tlb_table[mmu_idx][index].addr_code !=
(addr & (TARGET_PAGE_MASK | TLB_INVALID_MASK)))) {takes a (not necessarily page aligned) address, and masks out everything but the page-aligned top half (good) and the TLB_INVALID bit (not good, because that could be either 0 or 1 depending on the address). This means sometimes we'll incorrectly decide we got a miss in the TLB and do an unnecessary refill.
The second thing that's going on here is that the m68k target code writes TLB entries for the same address with different prot bits without doing a flush in between:
tlb_set_page_with_attrs: vaddr=0029b000 paddr=0x000000000029b000 prot=3 idx=0tlb_set_page_with_attrs: vaddr=0029b000 paddr=0x000000000029b000 prot=7 idx=0
The tlb_set_page_with_attrs() code isn't expecting this, so we end up with two TLB entries for the same address, one in the main TLB and one in the victim cache TLB. The bug above means that we get this sequence of events:
* fill main TLB entry with prot=3 entry
* later, fill main TLB with prot=7 entry, and evict prot=3 entry to victim cache
* hit on the prot=7 entry in the main TLB
* refill condition incorrectly fails, but we hit in the victim cache
* so we pull the prot=3 entry from victim to main TLB
* prot=3 means "addr_code == -1", so the check of the TLB_RECHECK bit succeeds
* in the TLB_RECHECK code we do a tlb_fill()
* that fills in the main TLB with a prot=7 entry again, bouncing the prot=3 entry back out to the victim cache
* prot=7 means the addr_code is correct, so we find ourselves in the "TLB_RECHECK but this is RAM" abort code path
I'm not sure whether it's supposed to be the responsibility of the target code or the common accel/tcg code to ensure that we don't have multiple TLB entries for the same address.
thanks
-- PMM
Re: [Qemu-devel] [PULL 23/32] tcg: Support MMU protection regions smaller than TARGET_PAGE_SIZE
Quoted 46 lines · Peter Maydell
Quoted 4 lines · Laurent Vivier
./m68k-softmmu/qemu-system-m68k -M q800 \ -serial none -serial mon:stdio \ -kernel vmlinux-4.15.0-2-m68k \ -nographicThanks for the test case. I'm still investigating, but there are a couple of things happening here.
First, there's a bug in get_page_addr_code()'s "is this a TLB miss?" condition which was introduced in commit
71b9a45330fe22:if (unlikely(env->tlb_table[mmu_idx][index].addr_code != (addr & (TARGET_PAGE_MASK | TLB_INVALID_MASK)))) {takes a (not necessarily page aligned) address, and masks out everything but the page-aligned top half (good) and the
TLB_INVALIDbit (not good, because that could be either 0 or 1 depending on the address). This means sometimes we'll incorrectly decide we got a miss in the TLB and do an unnecessary refill.The second thing that's going on here is that the m68k target code writes TLB entries for the same address with different prot bits without doing a flush in between:
tlb_set_page_with_attrs: vaddr=0029b000 paddr=0x000000000029b000 prot=3 idx=0tlb_set_page_with_attrs: vaddr=0029b000 paddr=0x000000000029b000 prot=7 idx=0The
tlb_set_page_with_attrs()code isn't expecting this, so we end up with two TLB entries for the same address, one in the main TLB and one in the victim cache TLB. The bug above means that we get this sequence of events:
* fill main TLB entry with prot=3 entry
* later, fill main TLB with prot=7 entry, and evict prot=3 entry to victim cache
* hit on the prot=7 entry in the main TLB
* refill condition incorrectly fails, but we hit in the victim cache
* so we pull the prot=3 entry from victim to main TLB
* prot=3 means "addr_code== -1", so the check of theTLB_RECHECKbit succeeds
* in theTLB_RECHECKcode we do atlb_fill()
* that fills in the main TLB with a prot=7 entry again, bouncing the prot=3 entry back out to the victim cache
* prot=7 means theaddr_codeis correct, so we find ourselves in the "TLB_RECHECKbut this is RAM" abort code path
Quoted 3 lines
I'm not sure whether it's supposed to be the responsibility of the target code or the common accel/tcg code to ensure that we don't have multiple TLB entries for the same address.
My gut feeling is we should fail safely in the case of the guest writing two mostly identical page entries in a row. We can check for aliasing when we update and either evict to the victim cache or reset the vtlb entry.
Quoted 3 lines
thanks
-- PMM
--
Alex Bennée
Re: [Qemu-devel] [PULL 23/32] tcg: Support MMU protection regions smaller than TARGET_PAGE_SIZE
In reply to Laurent VivierQuoted 23 lines · Laurent Vivier
Quoted 2 lines · Peter Maydell
Do you have a repro case (images, command line) that I can use to investigate ?
- checkout the branch q800-dev-part1 from
git://github.com/vivier/qemu-m68k.git- configure and build
'./configure' '--target-list=m68k-softmmu' '--enable-debug' \ '--enable-debug-tcg' '--enable-debug-info'my gcc is from Fedora 27, version 7.3.1 20180303 (Red Hat 7.3.1-5)
- get the kernel from the debian installer:
wget
https://cdimage.debian.org/mirror/cdimage/ports/9.0/m68k/iso-cd/debian-9.0-m68k-NETINST-1.isoguestfish --add debian-9.0-m68k-NETINST-1.iso --ro \ --mount /dev/sda:/ <<_EOF_copy-out /install/kernels/vmlinux-4.15.0-2-m68k .
_EOF_
Quoted 6 lines
- and run
./m68k-softmmu/qemu-system-m68k -M q800 \ -serial none -serial mon:stdio \ -kernel vmlinux-4.15.0-2-m68k \ -nographic
What is this testcase supposed to print when it works? I tried reverting 55df6fcf5476b44bc1b9, but that just prints "ABCFGHIJK" and then nothing else.
thanks
-- PMM
Re: [Qemu-devel] [PULL 23/32] tcg: Support MMU protection regions smaller than TARGET_PAGE_SIZE
Le 29/06/2018 à 17:28, Peter Maydell a écrit :
Quoted 26 lines · Laurent Vivier
Quoted 25 lines · Peter Maydell
Quoted 2 lines
Do you have a repro case (images, command line) that I can use to investigate ?
- checkout the branch q800-dev-part1 from
git://github.com/vivier/qemu-m68k.git- configure and build
'./configure' '--target-list=m68k-softmmu' '--enable-debug' \ '--enable-debug-tcg' '--enable-debug-info'my gcc is from Fedora 27, version 7.3.1 20180303 (Red Hat 7.3.1-5)
- get the kernel from the debian installer:
wget
https://cdimage.debian.org/mirror/cdimage/ports/9.0/m68k/iso-cd/debian-9.0-m68k-NETINST-1.isoguestfish --add debian-9.0-m68k-NETINST-1.iso --ro \ --mount /dev/sda:/ <<_EOF_copy-out /install/kernels/vmlinux-4.15.0-2-m68k .
_EOF_- and run
Quoted 8 lines
Quoted 4 lines
./m68k-softmmu/qemu-system-m68k -M q800 \ -serial none -serial mon:stdio \ -kernel vmlinux-4.15.0-2-m68k \ -nographicWhat is this testcase supposed to print when it works? I tried reverting
55df6fcf5476b44bc1b9, but that just prints "ABCFGHIJK" and then nothing else.
At this point, you can either remove the -nographic or add -append "console=ttyS0 vga=off" to have the kernel boot logs.
If you want to have started an userspace command, add the initrd from the CD:
guestfish --add debian-9.0-m68k-NETINST-1.iso --ro \
--mount /dev/sda:/ <<_EOF_copy-out /install/cdrom/initrd.gz .
_EOF_
Thanks,
Laurent
[Qemu-devel] [PULL 24/32] target/arm: Set page (region) size in get_phys_addr_pmsav7()
In reply to Peter MaydellWe want to handle small MPU region sizes for ARMv7M. To do this, make get_phys_addr_pmsav7() set the page size to the region size if it is less that TARGET_PAGE_SIZE, rather than working only in TARGET_PAGE_SIZE chunks.
Since the core TCG code con't handle execution from small MPU regions, we strip the exec permission from them so that any execution attempts will cause an MPU exception, rather than allowing it to end up with a cpu_abort() in get_page_addr_code().
(The previous code's intention was to make any small page be treated as having no permissions, but unfortunately errors in the implementation meant that it didn't behave that way. It's possible that some binaries using small regions were accidentally working with our old behaviour and won't now.)
Message-id: [email protected]
--- target/arm/helper.c | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-)
target/arm/helper.c +26 -11
@@ -9596,6 +9596,7 @@ static inline bool m_is_system_region(CPUARMState *env, uint32_t address)static bool get_phys_addr_pmsav7 (CPUARMState *env,uint32_t address,MMUAccessType access_type,ARMMMUIdx mmu_idx,hwaddr *phys_ptr,int *prot, +target_ulong *page_size,ARMMMUFaultInfo *fi) {ARMCPU *cpu =arm_env_get_cpu (env);
@@ -9603,6 +9604,7 @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address,bool is_user =regime_is_user (env, mmu_idx); *phys_ptr = address; + *page_size =TARGET_PAGE_SIZE ; *prot =0 ; if (regime_translation_disabled(env, mmu_idx) ||
@@ -9675,16 +9677,12 @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address, rsize++; } } -if (rsize <TARGET_PAGE_BITS ) { -qemu_log_mask (LOG_UNIMP , -"DRSR[%d]: No support for MPU (sub)region size of" -" %" PRIu32" bytes. Minimum is %d.\n" , - n, (1 << rsize),TARGET_PAGE_SIZE ); -continue ; - }if (srdis) {continue ; } +if (rsize <TARGET_PAGE_BITS ) { + *page_size =1 << rsize; + }break ; }
@@ -9765,6 +9763,17 @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address, fi->type = ARMFault_Permission; fi->level =1 ; +/* +* Core QEMU code can't handle execution from small pages yet, so +* don't try it. This way we'll get an MPU exception, rather than +* eventually causing QEMU to exit in get_page_addr_code(). +*/ +if (*page_size <TARGET_PAGE_SIZE && (*prot &PAGE_EXEC )) { +qemu_log_mask (LOG_UNIMP , +"MPU: No support for execution from regions " +"smaller than 1K\n" ); + *prot &= ~PAGE_EXEC ; + }return !(*prot & (1 << access_type)); }
@@ -10334,7 +10343,7 @@ static bool get_phys_addr(CPUARMState *env, target_ulong address, }else if (arm_feature (env,ARM_FEATURE_V7 )) {/* PMSAv7 */ ret =get_phys_addr_pmsav7 (env, address, access_type, mmu_idx, - phys_ptr, prot, fi); + phys_ptr, prot, page_size, fi); }else {/* Pre-v7 MPU */ ret = get_phys_addr_pmsav5(env, address, access_type, mmu_idx,
@@ -10396,9 +10405,15 @@ bool arm_tlb_fill(CPUState *cs, vaddr address,core_to_arm_mmu_idx (env, mmu_idx), &phys_addr, &attrs, &prot, &page_size, fi, NULL);if (!ret) { -/* Map a single [sub]page. */ - phys_addr &=TARGET_PAGE_MASK ; - address &=TARGET_PAGE_MASK ; +/* +* Map a single [sub]page. Regions smaller than our declared +* target page size are handled specially, so for those we +* pass in the exact addresses. +*/ +if (page_size >=TARGET_PAGE_SIZE ) { + phys_addr &=TARGET_PAGE_MASK ; + address &=TARGET_PAGE_MASK ; + }tlb_set_page_with_attrs (cs, address, phys_addr, attrs, prot, mmu_idx, page_size);return 0 ;
Signature · 1 line
2.17.1
[Qemu-devel] [PULL 25/32] target/arm: Handle small regions in get_phys_addr_pmsav8()
In reply to Peter MaydellAllow ARMv8M to handle small MPU and SAU region sizes, by making get_phys_add_pmsav8() set the page size to the 1 if the MPU or SAU region covers less than a TARGET_PAGE_SIZE.
We choose to use a size of 1 because it makes no difference to the core code, and avoids having to track both the base and limit for SAU and MPU and then convert into an artificially restricted "page size" that the core code will then ignore.
Since the core TCG code can't handle execution from small MPU regions, we strip the exec permission from them so that any execution attempts will cause an MPU exception, rather than allowing it to end up with a cpu_abort() in get_page_addr_code().
(The previous code's intention was to make any small page be treated as having no permissions, but unfortunately errors in the implementation meant that it didn't behave that way. It's possible that some binaries using small regions were accidentally working with our old behaviour and won't now.)
We also retain an existing bug, where we ignored the possibility that the SAU region might not cover the entire page, in the case of executable regions. This is necessary because some currently-working guest code images rely on being able to execute from addresses which are covered by a page-sized MPU region but a smaller SAU region. We can remove this workaround if we ever support execution from small regions.
Message-id: [email protected]
--- target/arm/helper.c | 78 ++++++++++++++++++++++++++++++++------------- 1 file changed, 55 insertions(+), 23 deletions(-)
target/arm/helper.c +55 -23
@@ -41,6 +41,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address,/* Security attributes for an address, as returned by v8m_security_lookup. */ typedef struct V8M_SAttributes { + bool subpage; /* true if these attrs don't cover the whole TARGET_PAGE */ bool ns; bool nsc; uint8_t sregion;
@@ -9804,6 +9805,8 @@ static void v8m_security_lookup(CPUARMState *env, uint32_t address,int r;bool idau_exempt = false, idau_ns = true, idau_nsc = true;int idau_region =IREGION_NOTVALID ; +uint32_t addr_page_base = address &TARGET_PAGE_MASK ; +uint32_t addr_page_limit = addr_page_base + (TARGET_PAGE_SIZE -1 );if (cpu->idau) {IDAUInterfaceClass *iic =IDAU_INTERFACE_GET_CLASS (cpu->idau);
@@ -9841,6 +9844,9 @@ static void v8m_security_lookup(CPUARMState *env, uint32_t address,uint32_t limit = env->sau.rlar[r] |0x1f ;if (base <= address && limit >= address) { +if (base > addr_page_base || limit < addr_page_limit) { + sattrs->subpage = true; + }if (sattrs->srvalid) {/* If we hit in more than one region then we must report * as Secure, not NS-Callable, with no valid region
@@ -9880,13 +9886,16 @@ static void v8m_security_lookup(CPUARMState *env, uint32_t address,static bool pmsav8_mpu_lookup (CPUARMState *env,uint32_t address,MMUAccessType access_type,ARMMMUIdx mmu_idx,hwaddr *phys_ptr,MemTxAttrs *txattrs, -int *prot,ARMMMUFaultInfo *fi,uint32_t *mregion) +int *prot,bool *is_subpage, +ARMMMUFaultInfo *fi,uint32_t *mregion) {/* Perform a PMSAv8 MPU lookup (without also doing the SAU check * that a full phys-to-virt translation does). * mregion is (if not NULL) set to the region number which matched, * or -1 if no region number is returned (MPU off, address did not * hit a region, address hit in multiple regions). +* We set is_subpage to true if the region hit doesn't cover the +* entire TARGET_PAGE the address is within. */ ARMCPU *cpu =arm_env_get_cpu (env);bool is_user =regime_is_user (env, mmu_idx);
@@ -9894,7 +9903,10 @@ static bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,int n;int matchregion =-1 ;bool hit = false; +uint32_t addr_page_base = address &TARGET_PAGE_MASK ; +uint32_t addr_page_limit = addr_page_base + (TARGET_PAGE_SIZE -1 ); + *is_subpage = false; *phys_ptr = address; *prot =0 ;if (mregion) {
@@ -9932,6 +9944,10 @@ static bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,continue ; } +if (base > addr_page_base || limit < addr_page_limit) { + *is_subpage = true; + } +if (hit) {/* Multiple regions match -- always a failure (unlike * PMSAv7 where highest-numbered-region wins)
@@ -9943,23 +9959,6 @@ static bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, matchregion = n; hit = true; - -if (base & ~TARGET_PAGE_MASK ) { -qemu_log_mask (LOG_UNIMP , -"MPU_RBAR[%d]: No support for MPU region base" -"address of 0x%" PRIx32". Minimum alignment is " -"%d\n" , - n, base,TARGET_PAGE_BITS ); -continue ; - } -if ((limit +1 ) & ~TARGET_PAGE_MASK ) { -qemu_log_mask (LOG_UNIMP , -"MPU_RBAR[%d]: No support for MPU region limit" -"address of 0x%" PRIx32". Minimum alignment is " -"%d\n" , - n, limit,TARGET_PAGE_BITS ); -continue ; - } } }
@@ -9995,6 +9994,18 @@ static bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, fi->type = ARMFault_Permission; fi->level =1 ; +/* +* Core QEMU code can't handle execution from small pages yet, so +* don't try it. This means any attempted execution will generate +* an MPU exception, rather than eventually causing QEMU to exit in +* get_page_addr_code(). +*/ +if (*is_subpage && (*prot &PAGE_EXEC )) { +qemu_log_mask (LOG_UNIMP , +"MPU: No support for execution from regions " +"smaller than 1K\n" ); + *prot &= ~PAGE_EXEC ; + }return !(*prot & (1 << access_type)); }
@@ -10002,10 +10013,13 @@ static bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,static bool get_phys_addr_pmsav8 (CPUARMState *env,uint32_t address,MMUAccessType access_type,ARMMMUIdx mmu_idx,hwaddr *phys_ptr,MemTxAttrs *txattrs, -int *prot,ARMMMUFaultInfo *fi) +int *prot,target_ulong *page_size, +ARMMMUFaultInfo *fi) {uint32_t secure =regime_is_secure (env, mmu_idx);V8M_SAttributes sattrs = {}; +bool ret; +bool mpu_is_subpage;if (arm_feature (env,ARM_FEATURE_M_SECURITY )) {v8m_security_lookup (env, address, access_type, mmu_idx, &sattrs);
@@ -10033,6 +10047,7 @@ static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address, }else { fi->type = ARMFault_QEMU_SFault; } + *page_size = sattrs.subpage ?1 :TARGET_PAGE_SIZE ; *phys_ptr = address; *prot =0 ;return true;
@@ -10055,6 +10070,7 @@ static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address,* for M_FAKE_FSR_SFAULT in arm_v7m_cpu_do_interrupt(). */ fi->type = ARMFault_QEMU_SFault; + *page_size = sattrs.subpage ?1 :TARGET_PAGE_SIZE ; *phys_ptr = address; *prot =0 ;return true;
@@ -10062,8 +10078,22 @@ static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address, } } -return pmsav8_mpu_lookup (env, address, access_type, mmu_idx, phys_ptr, - txattrs, prot, fi,NULL ); + ret =pmsav8_mpu_lookup (env, address, access_type, mmu_idx, phys_ptr, + txattrs, prot, &mpu_is_subpage, fi,NULL ); +/* +* TODO: this is a temporary hack to ignore the fact that the SAU region +* is smaller than a page if this is an executable region. We never +* supported small MPU regions, but we did (accidentally) allow small +* SAU regions, and if we now made small SAU regions not be executable +* then this would break previously working guest code. We can't +* remove this until/unless we implement support for execution from +* small regions. +*/ +if (*prot &PAGE_EXEC ) { + sattrs.subpage = false; + } + *page_size = sattrs.subpage || mpu_is_subpage ?1 :TARGET_PAGE_SIZE ; +return ret; } static bool get_phys_addr_pmsav5(CPUARMState *env, uint32_t address,
@@ -10339,7 +10369,7 @@ static bool get_phys_addr(CPUARMState *env, target_ulong address,if (arm_feature (env,ARM_FEATURE_V8 )) {/* PMSAv8 */ ret =get_phys_addr_pmsav8 (env, address, access_type, mmu_idx, - phys_ptr, attrs, prot, fi); + phys_ptr, attrs, prot, page_size, fi); }else if (arm_feature (env,ARM_FEATURE_V7 )) {/* PMSAv7 */ ret = get_phys_addr_pmsav7(env, address, access_type, mmu_idx,
@@ -10757,6 +10787,7 @@ uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op)uint32_t mregion;bool targetpriv;bool targetsec = env->v7m.secure; +bool is_subpage;/* Work out what the security state and privilege level we're * interested in is...
@@ -10786,7 +10817,8 @@ uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op)if (arm_current_el (env) !=0 || alt) {/* We can ignore the return value as prot is always set */ pmsav8_mpu_lookup (env, addr,MMU_DATA_LOAD , mmu_idx, - &phys_addr, &attrs, &prot, &fi, &mregion); + &phys_addr, &attrs, &prot, &is_subpage, + &fi, &mregion);if (mregion ==-1 ) { mrvalid = false; mregion =0 ;
Signature · 1 line
2.17.1
[Qemu-devel] [PULL 26/32] hw/arm/smmuv3: Fix translate error handling
In reply to Peter MaydellFrom: Jia He <[email protected]>
In case the STE's config is "Bypass" we currently don't set the IOMMUTLBEntry perm flags and the access does not succeed. Also if the config is 0b0xx (Aborted/Reserved), decode_ste and smmuv3_decode_config currently returns -EINVAL and we don't enter the expected code path: we record an event whereas we should not.
This patch fixes those bugs and simplifies the error handling. decode_ste and smmuv3_decode_config now return 0 if aborted or bypassed config was found. Only bad config info produces negative error values. In smmuv3_translate we more clearly differentiate errors, bypass/smmu disabled, aborted and success cases. Also trace points are differentiated.
Message-id: [email protected]
--- hw/arm/smmuv3-internal.h | 12 ++++- hw/arm/smmuv3.c | 96 +++++++++++++++++++++++++++------------- hw/arm/trace-events | 7 +-- 3 files changed, 80 insertions(+), 35 deletions(-)
hw/arm/smmuv3-internal.h +10 -2
@@ -23,6 +23,14 @@#include "hw/arm/smmu-common.h" +typedef enum SMMUTranslationStatus { +SMMU_TRANS_DISABLE , +SMMU_TRANS_ABORT , +SMMU_TRANS_BYPASS , +SMMU_TRANS_ERROR , +SMMU_TRANS_SUCCESS , +}SMMUTranslationStatus ; +/* MMIO Registers */ REG32 (IDR0 ,0x0 )
@@ -315,7 +323,7 @@ enum { /* Command completion notification *//* Events */ typedef enum SMMUEventType { - SMMU_EVT_OK = 0x00, + SMMU_EVT_NONE = 0x00, SMMU_EVT_F_UUT , SMMU_EVT_C_BAD_STREAMID , SMMU_EVT_F_STE_FETCH ,
@@ -337,7 +345,7 @@ typedef enum SMMUEventType { } SMMUEventType;static const char *event_stringify[] = { - [SMMU_EVT_OK ] ="SMMU_EVT_OK" , + [SMMU_EVT_NONE ] ="no recorded event" , [SMMU_EVT_F_UUT ] ="SMMU_EVT_F_UUT" , [SMMU_EVT_C_BAD_STREAMID ] ="SMMU_EVT_C_BAD_STREAMID" , [SMMU_EVT_F_STE_FETCH ] ="SMMU_EVT_F_STE_FETCH" ,
hw/arm/smmuv3.c +66 -30
179 lines not on this page · raw message
hw/arm/trace-events +4 -3
@@ -33,9 +33,10 @@ smmuv3_record_event(const char *type, uint32_t sid) "%s sid=%d" smmuv3_find_ste(uint16_t sid, uint32_t features, uint16_t sid_split) "SID:0x%x features:0x%x, sid_split:0x%x" smmuv3_find_ste_2lvl(uint64_t strtab_base, uint64_t l1ptr, int l1_ste_offset, uint64_t l2ptr, int l2_ste_offset, int max_l2_ste) "strtab_base:0x%"PRIx64" l1ptr:0x%"PRIx64" l1_off:0x%x, l2ptr:0x%"PRIx64" l2_off:0x%x max_l2_ste:%d" smmuv3_get_ste(uint64_t addr) "STE addr: 0x%"PRIx64 -smmuv3_translate_bypass(const char *n, uint16_t sid, uint64_t addr, bool is_write) "%s sid=%d bypass iova:0x%"PRIx64" is_write=%d" -smmuv3_translate_in(uint16_t sid, int pci_bus_num, uint64_t strtab_base) "SID:0x%x bus:%d strtab_base:0x%"PRIx64 +smmuv3_translate_disable(const char *n, uint16_t sid, uint64_t addr, bool is_write) "%s sid=%d bypass (smmu disabled) iova:0x%"PRIx64" is_write=%d" +smmuv3_translate_bypass(const char *n, uint16_t sid, uint64_t addr, bool is_write) "%s sid=%d STE bypass iova:0x%"PRIx64" is_write=%d" +smmuv3_translate_abort(const char *n, uint16_t sid, uint64_t addr, bool is_write) "%s sid=%d abort on iova:0x%"PRIx64" is_write=%d" +smmuv3_translate_success(const char *n, uint16_t sid, uint64_t iova, uint64_t translated, int perm) "%s sid=%d iova=0x%"PRIx64" translated=0x%"PRIx64" perm=0x%x" smmuv3_get_cd(uint64_t addr) "CD addr: 0x%"PRIx64 -smmuv3_translate(const char *n, uint16_t sid, uint64_t iova, uint64_t translated, int perm) "%s sid=%d iova=0x%"PRIx64" translated=0x%"PRIx64" perm=0x%x" smmuv3_decode_cd(uint32_t oas) "oas=%d" smmuv3_decode_cd_tt(int i, uint32_t tsz, uint64_t ttb, uint32_t granule_sz) "TT[%d]:tsz:%d ttb:0x%"PRIx64" granule_sz:%d"
Signature · 1 line
2.17.1
[Qemu-devel] [PULL 27/32] hw/arm/smmuv3: Cache/invalidate config data
In reply to Peter MaydellFrom: Eric Auger <[email protected]>
Let's cache config data to avoid fetching and parsing STE/CD structures on each translation. We invalidate them on data structure invalidation commands.
We put in place a per-smmu mutex to protect the config cache. This will be useful too to protect the IOTLB cache. The caches can be accessed without BQL, ie. in IO dataplane. The same kind of mutex was put in place in the intel viommu.
Message-id: [email protected]
--- include/hw/arm/smmu-common.h | 5 ++ include/hw/arm/smmuv3.h | 1 + hw/arm/smmu-common.c | 24 ++++++- hw/arm/smmuv3.c | 135 +++++++++++++++++++++++++++++++++-- hw/arm/trace-events | 6 ++ 5 files changed, 164 insertions(+), 7 deletions(-)
include/hw/arm/smmu-common.h +5 -0
@@ -75,6 +75,8 @@ typedef struct SMMUDevice {int devfn;IOMMUMemoryRegion iommu;AddressSpace as; +uint32_t cfg_cache_hits; +uint32_t cfg_cache_misses; } SMMUDevice; typedef struct SMMUNotifierNode {
@@ -142,4 +144,7 @@ int smmu_ptw(SMMUTransCfg *cfg, dma_addr_t iova, IOMMUAccessFlags perm,*/ SMMUTransTableInfo *select_tt (SMMUTransCfg *cfg,dma_addr_t iova); +/* Return the iommu mr associated to @sid, or NULL if none */ +IOMMUMemoryRegion *smmu_iommu_mr (SMMUState *s,uint32_t sid); +#endif /* HW_ARM_SMMU_COMMON */
include/hw/arm/smmuv3.h +1 -0
@@ -59,6 +59,7 @@ typedef struct SMMUv3State {SMMUQueue eventq, cmdq;qemu_irq irq[4 ]; +QemuMutex mutex; } SMMUv3State; typedef enum {
hw/arm/smmu-common.c +22 -2
@@ -310,6 +310,24 @@ static AddressSpace *smmu_find_add_as(PCIBus *bus, void *opaque, int devfn)return &sdev->as; } +IOMMUMemoryRegion *smmu_iommu_mr (SMMUState *s,uint32_t sid) +{ +uint8_t bus_n, devfn; +SMMUPciBus *smmu_bus; +SMMUDevice *smmu; + + bus_n =PCI_BUS_NUM (sid); + smmu_bus =smmu_find_smmu_pcibus (s, bus_n); +if (smmu_bus) { + devfn = sid &0x7 ; + smmu = smmu_bus->pbdev[devfn]; +if (smmu) { +return &smmu->iommu; + } + } +return NULL ; +} +static void smmu_base_realize (DeviceState *dev,Error **errp) {SMMUState *s =ARM_SMMU (dev);
@@ -321,7 +339,7 @@ static void smmu_base_realize(DeviceState *dev, Error **errp)error_propagate (errp, local_err);return ; } - + s->configs =g_hash_table_new_full (NULL ,NULL ,NULL , g_free); s->smmu_pcibus_by_busptr =g_hash_table_new (NULL ,NULL );if (s->primary_bus) {
@@ -333,7 +351,9 @@ static void smmu_base_realize(DeviceState *dev, Error **errp)static void smmu_base_reset (DeviceState *dev) { -/* will be filled later on */ +SMMUState *s =ARM_SMMU (dev); + +g_hash_table_remove_all (s->configs); }static Property smmu_dev_properties[] = {
hw/arm/smmuv3.c +130 -5
210 lines not on this page · raw message
hw/arm/trace-events +6 -0
@@ -40,3 +40,9 @@ smmuv3_translate_success(const char *n, uint16_t sid, uint64_t iova, uint64_t tr smmuv3_get_cd(uint64_t addr) "CD addr: 0x%"PRIx64 smmuv3_decode_cd(uint32_t oas) "oas=%d" smmuv3_decode_cd_tt(int i, uint32_t tsz, uint64_t ttb, uint32_t granule_sz) "TT[%d]:tsz:%d ttb:0x%"PRIx64" granule_sz:%d" +smmuv3_cmdq_cfgi_ste(int streamid) "streamid =%d" +smmuv3_cmdq_cfgi_ste_range(int start, int end) "start=0x%d - end=0x%d" +smmuv3_cmdq_cfgi_cd(uint32_t sid) "streamid = %d" +smmuv3_config_cache_hit(uint32_t sid, uint32_t hits, uint32_t misses, uint32_t perc) "Config cache HIT for sid %d (hits=%d, misses=%d, hit rate=%d)" +smmuv3_config_cache_miss(uint32_t sid, uint32_t hits, uint32_t misses, uint32_t perc) "Config cache MISS for sid %d (hits=%d, misses=%d, hit rate=%d)" +smmuv3_config_cache_inv(uint32_t sid) "Config cache INV for sid %d"
Signature · 1 line
2.17.1
[Qemu-devel] [PULL 29/32] hw/arm/smmuv3: Add notifications on invalidation
In reply to Peter MaydellFrom: Eric Auger <[email protected]>
On TLB invalidation commands, let's call registered IOMMU notifiers. Those can only be UNMAP notifiers. SMMUv3 does not support notification on MAP (VFIO).
This patch allows vhost use case where IOTLB API is notified on each guest IOTLB invalidation.
Message-id: [email protected]
--- include/hw/arm/smmu-common.h | 6 +++ hw/arm/smmu-common.c | 34 +++++++++++++ hw/arm/smmuv3.c | 99 +++++++++++++++++++++++++++++++++++- hw/arm/trace-events | 5 ++ 4 files changed, 142 insertions(+), 2 deletions(-)
include/hw/arm/smmu-common.h +6 -0
@@ -160,4 +160,10 @@ void smmu_iotlb_inv_all(SMMUState *s);void smmu_iotlb_inv_asid (SMMUState *s,uint16_t asid);void smmu_iotlb_inv_iova (SMMUState *s,uint16_t asid,dma_addr_t iova); +/* Unmap the range of all the notifiers registered to any IOMMU mr */ +void smmu_inv_notifiers_all (SMMUState *s); + +/* Unmap the range of all the notifiers registered to @mr */ +void smmu_inv_notifiers_mr (IOMMUMemoryRegion *mr); +#endif /* HW_ARM_SMMU_COMMON */
hw/arm/smmu-common.c +34 -0
@@ -385,6 +385,40 @@ static gboolean smmu_iotlb_key_equal(gconstpointer v1, gconstpointer v2)return (k1->asid == k2->asid) && (k1->iova == k2->iova); } +/* Unmap the whole notifier's range */ +static void smmu_unmap_notifier_range (IOMMUNotifier *n) +{ +IOMMUTLBEntry entry; + + entry.target_as = &address_space_memory; + entry.iova = n->start; + entry.perm =IOMMU_NONE ; + entry.addr_mask = n->end - n->start; + +memory_region_notify_one (n, &entry); +} + +/* Unmap all notifiers attached to @mr */ +inline void smmu_inv_notifiers_mr (IOMMUMemoryRegion *mr) +{ +IOMMUNotifier *n; + +trace_smmu_inv_notifiers_mr (mr->parent_obj.name); + IOMMU_NOTIFIER_FOREACH(n, mr) { +smmu_unmap_notifier_range (n); + } +} + +/* Unmap all notifiers of all mr's */ +void smmu_inv_notifiers_all (SMMUState *s) +{ +SMMUNotifierNode *node; + + QLIST_FOREACH(node, &s->notifiers_list, next) { +smmu_inv_notifiers_mr (&node->sdev->iommu); + } +} +static void smmu_base_realize (DeviceState *dev,Error **errp) {SMMUState *s =ARM_SMMU (dev);
hw/arm/smmuv3.c +97 -2
136 lines not on this page · raw message
hw/arm/trace-events +5 -0
@@ -17,6 +17,7 @@ smmu_iotlb_cache_miss(uint16_t asid, uint64_t addr, uint32_t hit, uint32_t miss, smmu_iotlb_inv_all(void) "IOTLB invalidate all" smmu_iotlb_inv_asid(uint16_t asid) "IOTLB invalidate asid=%d" smmu_iotlb_inv_iova(uint16_t asid, uint64_t addr) "IOTLB invalidate asid=%d addr=0x%"PRIx64 +smmu_inv_notifiers_mr(const char *name) "iommu mr=%s" #hw/arm/smmuv3.c smmuv3_read_mmio(uint64_t addr, uint64_t val, unsigned size, uint32_t r) "addr: 0x%"PRIx64" val:0x%"PRIx64" size: 0x%x(%d)"
@@ -55,3 +56,7 @@ smmuv3_cmdq_tlbi_nh_vaa(int vmid, uint64_t addr) "vmid =%d addr=0x%"PRIx64 smmuv3_cmdq_tlbi_nh(void) "" smmuv3_cmdq_tlbi_nh_asid(uint16_t asid) "asid=%d" smmuv3_config_cache_inv(uint32_t sid) "Config cache INV for sid %d" +smmuv3_notify_flag_add(const char *iommu) "ADD SMMUNotifier node for iommu mr=%s" +smmuv3_notify_flag_del(const char *iommu) "DEL SMMUNotifier node for iommu mr=%s" +smmuv3_inv_notifiers_iova(const char *name, uint16_t asid, uint64_t iova) "iommu mr=%s asid=%d iova=0x%"PRIx64 +
Signature · 1 line
2.17.1
[Qemu-devel] [PULL 28/32] hw/arm/smmuv3: IOTLB emulation
In reply to Peter MaydellFrom: Eric Auger <[email protected]>
We emulate a TLB cache of size SMMU_IOTLB_MAX_SIZE=256. It is implemented as a hash table whose key is a combination of the 16b asid and 48b IOVA (Jenkins hash).
Entries are invalidated on TLB invalidation commands, either globally, or per asid, or per asid/iova.
Message-id: [email protected]
--- include/hw/arm/smmu-common.h | 13 +++++ hw/arm/smmu-common.c | 60 ++++++++++++++++++++++ hw/arm/smmuv3.c | 98 ++++++++++++++++++++++++++++++++++-- hw/arm/trace-events | 9 ++++ 4 files changed, 176 insertions(+), 4 deletions(-)
include/hw/arm/smmu-common.h +13 -0
@@ -67,6 +67,8 @@ typedef struct SMMUTransCfg {uint8_t tbi;/* Top Byte Ignore */ uint16_t asid;SMMUTransTableInfo tt[2 ]; +uint32_t iotlb_hits;/* counts IOTLB hits for this asid */ +uint32_t iotlb_misses;/* counts IOTLB misses for this asid */ } SMMUTransCfg; typedef struct SMMUDevice {
@@ -89,6 +91,11 @@ typedef struct SMMUPciBus {SMMUDevice *pbdev[0 ];/* Parent array is sparse, so dynamically alloc */ } SMMUPciBus; +typedef struct SMMUIOTLBKey { +uint64_t iova; +uint16_t asid; +}SMMUIOTLBKey ; + typedef struct SMMUState { /* <private> */ SysBusDevice dev;
@@ -147,4 +154,10 @@ SMMUTransTableInfo *select_tt(SMMUTransCfg *cfg, dma_addr_t iova);/* Return the iommu mr associated to @sid, or NULL if none */ IOMMUMemoryRegion *smmu_iommu_mr (SMMUState *s,uint32_t sid); +#define SMMU_IOTLB_MAX_SIZE 256 + +void smmu_iotlb_inv_all (SMMUState *s); +void smmu_iotlb_inv_asid (SMMUState *s,uint16_t asid); +void smmu_iotlb_inv_iova (SMMUState *s,uint16_t asid,dma_addr_t iova); +#endif /* HW_ARM_SMMU_COMMON */
hw/arm/smmu-common.c +60 -0
89 lines not on this page · raw message
hw/arm/smmuv3.c +94 -4
142 lines not on this page · raw message
hw/arm/trace-events +9 -0
@@ -12,6 +12,11 @@ smmu_ptw_invalid_pte(int stage, int level, uint64_t baseaddr, uint64_t pteaddr, smmu_ptw_page_pte(int stage, int level, uint64_t iova, uint64_t baseaddr, uint64_t pteaddr, uint64_t pte, uint64_t address) "stage=%d level=%d iova=0x%"PRIx64" base@=0x%"PRIx64" pte@=0x%"PRIx64" pte=0x%"PRIx64" page address = 0x%"PRIx64 smmu_ptw_block_pte(int stage, int level, uint64_t baseaddr, uint64_t pteaddr, uint64_t pte, uint64_t iova, uint64_t gpa, int bsize_mb) "stage=%d level=%d base@=0x%"PRIx64" pte@=0x%"PRIx64" pte=0x%"PRIx64" iova=0x%"PRIx64" block address = 0x%"PRIx64" block size = %d MiB" smmu_get_pte(uint64_t baseaddr, int index, uint64_t pteaddr, uint64_t pte) "baseaddr=0x%"PRIx64" index=0x%x, pteaddr=0x%"PRIx64", pte=0x%"PRIx64 +smmu_iotlb_cache_hit(uint16_t asid, uint64_t addr, uint32_t hit, uint32_t miss, uint32_t p) "IOTLB cache HIT asid=%d addr=0x%"PRIx64" hit=%d miss=%d hit rate=%d" +smmu_iotlb_cache_miss(uint16_t asid, uint64_t addr, uint32_t hit, uint32_t miss, uint32_t p) "IOTLB cache MISS asid=%d addr=0x%"PRIx64" hit=%d miss=%d hit rate=%d" +smmu_iotlb_inv_all(void) "IOTLB invalidate all" +smmu_iotlb_inv_asid(uint16_t asid) "IOTLB invalidate asid=%d" +smmu_iotlb_inv_iova(uint16_t asid, uint64_t addr) "IOTLB invalidate asid=%d addr=0x%"PRIx64 #hw/arm/smmuv3.c smmuv3_read_mmio(uint64_t addr, uint64_t val, unsigned size, uint32_t r) "addr: 0x%"PRIx64" val:0x%"PRIx64" size: 0x%x(%d)"
@@ -45,4 +50,8 @@ smmuv3_cmdq_cfgi_ste_range(int start, int end) "start=0x%d - end=0x%d" smmuv3_cmdq_cfgi_cd(uint32_t sid) "streamid = %d" smmuv3_config_cache_hit(uint32_t sid, uint32_t hits, uint32_t misses, uint32_t perc) "Config cache HIT for sid %d (hits=%d, misses=%d, hit rate=%d)" smmuv3_config_cache_miss(uint32_t sid, uint32_t hits, uint32_t misses, uint32_t perc) "Config cache MISS for sid %d (hits=%d, misses=%d, hit rate=%d)" +smmuv3_cmdq_tlbi_nh_va(int vmid, int asid, uint64_t addr, bool leaf) "vmid =%d asid =%d addr=0x%"PRIx64" leaf=%d" +smmuv3_cmdq_tlbi_nh_vaa(int vmid, uint64_t addr) "vmid =%d addr=0x%"PRIx64 +smmuv3_cmdq_tlbi_nh(void) "" +smmuv3_cmdq_tlbi_nh_asid(uint16_t asid) "asid=%d" smmuv3_config_cache_inv(uint32_t sid) "Config cache INV for sid %d"
Signature · 1 line
2.17.1
[Qemu-devel] [PULL 30/32] aspeed/scu: introduce clock frequencies
In reply to Peter MaydellFrom: Cédric Le Goater <[email protected]>
All Aspeed SoC clocks are driven by an input source clock which can have different frequencies : 24MHz or 25MHz, and also, on the Aspeed AST2400 SoC, 48MHz. The H-PLL (CPU) clock is defined from a calculation using parameters in the H-PLL Parameter register or from a predefined set of frequencies if the setting is strapped by hardware (Aspeed AST2400 SoC). The other clocks of the SoC are then defined from the H-PLL using dividers.
We introduce first the APB clock because it should be used to drive the Aspeed timer model.
Message-id: [email protected]
--- include/hw/misc/aspeed_scu.h | 70 +++++++++++++++++++++-- hw/misc/aspeed_scu.c | 106 +++++++++++++++++++++++++++++++++++ 2 files changed, 172 insertions(+), 4 deletions(-)
include/hw/misc/aspeed_scu.h +66 -4
@@ -30,6 +30,10 @@ typedef struct AspeedSCUState {uint32_t hw_strap1;uint32_t hw_strap2;uint32_t hw_prot_key; + +uint32_t clkin; +uint32_t hpll; +uint32_t apb_freq; } AspeedSCUState;#define AST2400_A0_SILICON_REV 0x02000303U
@@ -58,7 +62,64 @@ extern bool is_supported_silicon_rev(uint32_t silicon_rev);* 1. 2012/12/29 Ryan Chen Create */ -/* Hardware Strapping Register definition (for Aspeed AST2400 SOC) +/* SCU08 Clock Selection Register +* +* 31 Enable Video Engine clock dynamic slow down +* 30:28 Video Engine clock slow down setting +* 27 2D Engine GCLK clock source selection +* 26 2D Engine GCLK clock throttling enable +* 25:23 APB PCLK divider selection +* 22:20 LPC Host LHCLK divider selection +* 19 LPC Host LHCLK clock generation/output enable control +* 18:16 MAC AHB bus clock divider selection +* 15 SD/SDIO clock running enable +* 14:12 SD/SDIO divider selection +* 11 Reserved +* 10:8 Video port output clock delay control bit +* 7 ARM CPU/AHB clock slow down enable +* 6:4 ARM CPU/AHB clock slow down setting +* 3:2 ECLK clock source selection +* 1 CPU/AHB clock slow down idle timer +* 0 CPU/AHB clock dynamic slow down enable (defined in bit[6:4]) +*/ +#define SCU_CLK_GET_PCLK_DIV (x) (((x) >> 23) & 0x7) + +/* SCU24 H-PLL Parameter Register (for Aspeed AST2400 SOC) +* +* 18 H-PLL parameter selection +* 0: Select H-PLL by strapping resistors +* 1: Select H-PLL by the programmed registers (SCU24[17:0]) +* 17 Enable H-PLL bypass mode +* 16 Turn off H-PLL +* 10:5 H-PLL Numerator +* 4 H-PLL Output Divider +* 3:0 H-PLL Denumerator +* +* (Output frequency) = 24MHz * (2-OD) * [(Numerator+2) / (Denumerator+1)] +*/ + +#define SCU_AST2400_H_PLL_PROGRAMMED (0x1 << 18) +#define SCU_AST2400_H_PLL_BYPASS_EN (0x1 << 17) +#define SCU_AST2400_H_PLL_OFF (0x1 << 16) + +/* SCU24 H-PLL Parameter Register (for Aspeed AST2500 SOC) +* +* 21 Enable H-PLL reset +* 20 Enable H-PLL bypass mode +* 19 Turn off H-PLL +* 18:13 H-PLL Post Divider +* 12:5 H-PLL Numerator (M) +* 4:0 H-PLL Denumerator (N) +* +* (Output frequency) = CLKIN(24MHz) * [(M+1) / (N+1)] / (P+1) +* +* The default frequency is 792Mhz when CLKIN = 24MHz +*/ + +#define SCU_H_PLL_BYPASS_EN (0x1 << 20) +#define SCU_H_PLL_OFF (0x1 << 19) + +/* SCU70 Hardware Strapping Register definition (for Aspeed AST2400 SOC) * * 31:29 Software defined strapping registers * 28:27 DRAM size setting (for VGA driver use)
@@ -107,12 +168,13 @@ extern bool is_supported_silicon_rev(uint32_t silicon_rev);#define SCU_AST2400_HW_STRAP_GET_CLK_SOURCE (x) (((((x) >> 23) & 0x1) << 1) \ | (((x) >> 18) & 0x1))#define SCU_AST2400_HW_STRAP_CLK_SOURCE_MASK ((0x1 << 23) | (0x1 << 18)) -#define AST2400_CLK_25M_IN (0x1 << 23) +#define SCU_HW_STRAP_CLK_25M_IN (0x1 << 23)#define AST2400_CLK_24M_IN 0#define AST2400_CLK_48M_IN 1#define AST2400_CLK_25M_IN_24M_USB_CKI 2#define AST2400_CLK_25M_IN_48M_USB_CKI 3 +#define SCU_HW_STRAP_CLK_48M_IN (0x1 << 18)#define SCU_HW_STRAP_2ND_BOOT_WDT (0x1 << 17)#define SCU_HW_STRAP_SUPER_IO_CONFIG (0x1 << 16)#define SCU_HW_STRAP_VGA_CLASS_CODE (0x1 << 15)
@@ -160,8 +222,8 @@ extern bool is_supported_silicon_rev(uint32_t silicon_rev);#define AST2400_DIS_BOOT 3/* -* Hardware strapping register definition (for Aspeed AST2500 SoC and -* higher) +* SCU70 Hardware strapping register definition (for Aspeed AST2500 +* SoC and higher) * * 31 Enable SPI Flash Strap Auto Fetch Mode * 30 Enable GPIO Strap Mode
hw/misc/aspeed_scu.c +106 -0
143 lines not on this page · raw message
Signature · 1 line
2.17.1
[Qemu-devel] [PULL 31/32] aspeed: initialize the SCU controller first
In reply to Peter MaydellFrom: Cédric Le Goater <[email protected]>
The System Control Unit should be initialized first as it drives all the configuration of the SoC and other device models.
Message-id: [email protected]
--- hw/arm/aspeed_soc.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-)
hw/arm/aspeed_soc.c +20 -20
@@ -109,18 +109,6 @@ static void aspeed_soc_init(Object *obj)object_initialize (&s->cpu,sizeof (s->cpu), sc->info->cpu_type);object_property_add_child (obj,"cpu" ,OBJECT (&s->cpu),NULL ); -object_initialize (&s->vic,sizeof (s->vic),TYPE_ASPEED_VIC ); -object_property_add_child (obj,"vic" ,OBJECT (&s->vic),NULL ); -qdev_set_parent_bus (DEVICE (&s->vic),sysbus_get_default ()); - -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 ()); -object_initialize (&s->scu,sizeof (s->scu),TYPE_ASPEED_SCU );object_property_add_child (obj,"scu" ,OBJECT (&s->scu),NULL );qdev_set_parent_bus (DEVICE (&s->scu),sysbus_get_default ());
@@ -133,6 +121,18 @@ static void aspeed_soc_init(Object *obj)object_property_add_alias (obj,"hw-prot-key" ,OBJECT (&s->scu),"hw-prot-key" , &error_abort); +object_initialize (&s->vic,sizeof (s->vic),TYPE_ASPEED_VIC ); +object_property_add_child (obj,"vic" ,OBJECT (&s->vic),NULL ); +qdev_set_parent_bus (DEVICE (&s->vic),sysbus_get_default ()); + +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 ()); +object_initialize (&s->fmc,sizeof (s->fmc), sc->info->fmc_typename);object_property_add_child (obj,"fmc" ,OBJECT (&s->fmc),NULL );qdev_set_parent_bus (DEVICE (&s->fmc),sysbus_get_default ());
@@ -195,6 +195,14 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)memory_region_add_subregion (get_system_memory (),ASPEED_SOC_SRAM_BASE , &s->sram); +/* SCU */ +object_property_set_bool (OBJECT (&s->scu), true,"realized" , &err); +if (err) { +error_propagate (errp, err); +return ; + } +sysbus_mmio_map (SYS_BUS_DEVICE (&s->scu),0 ,ASPEED_SOC_SCU_BASE ); +/* VIC */ object_property_set_bool (OBJECT (&s->vic), true,"realized" , &err);if (err) {
@@ -219,14 +227,6 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)sysbus_connect_irq (SYS_BUS_DEVICE (&s->timerctrl), i, irq); } -/* SCU */ -object_property_set_bool (OBJECT (&s->scu), true,"realized" , &err); -if (err) { -error_propagate (errp, err); -return ; - } -sysbus_mmio_map (SYS_BUS_DEVICE (&s->scu),0 ,ASPEED_SOC_SCU_BASE ); -/* UART - attach an 8250 to the IO space as our UART5 */ if (serial_hd (0 )) {qemu_irq uart5 =qdev_get_gpio_in (DEVICE (&s->vic), uart_irqs[4 ]);
Signature · 1 line
2.17.1
[Qemu-devel] [PULL 32/32] aspeed/timer: use the APB frequency from the SCU
In reply to Peter MaydellFrom: Cédric Le Goater <[email protected]>
The timer controller can be driven by either an external 1MHz clock or by the APB clock. Today, the model makes the assumption that the APB frequency is always set to 24MHz but this is incorrect.
The AST2400 SoC on the palmetto machines uses a 48MHz input clock source and the APB can be set to 48MHz. The consequence is a general system slowdown. The QEMU machines using the AST2500 SoC do not seem impacted today because the APB frequency is still set to 24MHz.
We fix the timer frequency for all SoCs by linking the Timer model to the SCU model. The APB frequency driving the timers is now the one configured for the SoC.
Message-id: [email protected]
--- include/hw/timer/aspeed_timer.h | 4 ++++ hw/arm/aspeed_soc.c | 2 ++ hw/timer/aspeed_timer.c | 19 +++++++++++++++---- 3 files changed, 21 insertions(+), 4 deletions(-)
include/hw/timer/aspeed_timer.h +4 -0
@@ -24,6 +24,8 @@#include "qemu/timer.h" +typedef struct AspeedSCUState AspeedSCUState ; +#define ASPEED_TIMER (obj) \ OBJECT_CHECK(AspeedTimerCtrlState, (obj), TYPE_ASPEED_TIMER);#define TYPE_ASPEED_TIMER "aspeed.timer"
@@ -55,6 +57,8 @@ typedef struct AspeedTimerCtrlState {uint32_t ctrl;uint32_t ctrl2;AspeedTimer timers[ASPEED_TIMER_NR_TIMERS ]; + + AspeedSCUState *scu; } AspeedTimerCtrlState;#endif /* ASPEED_TIMER_H */
hw/arm/aspeed_soc.c +2 -0
@@ -127,6 +127,8 @@ static void aspeed_soc_init(Object *obj)object_initialize (&s->timerctrl,sizeof (s->timerctrl),TYPE_ASPEED_TIMER );object_property_add_child (obj,"timerctrl" ,OBJECT (&s->timerctrl),NULL ); +object_property_add_const_link (OBJECT (&s->timerctrl),"scu" , +OBJECT (&s->scu), &error_abort);qdev_set_parent_bus (DEVICE (&s->timerctrl),sysbus_get_default ());object_initialize (&s->i2c,sizeof (s->i2c),TYPE_ASPEED_I2C );
hw/timer/aspeed_timer.c +15 -4
@@ -10,8 +10,10 @@*/ #include "qemu/osdep.h" +#include "qapi/error.h" #include "hw/sysbus.h" #include "hw/timer/aspeed_timer.h" +#include "hw/misc/aspeed_scu.h" #include "qemu-common.h" #include "qemu/bitops.h" #include "qemu/timer.h"
@@ -26,7 +28,6 @@#define TIMER_CLOCK_USE_EXT true#define TIMER_CLOCK_EXT_HZ 1000000#define TIMER_CLOCK_USE_APB false -#define TIMER_CLOCK_APB_HZ 24000000#define TIMER_REG_STATUS 0#define TIMER_REG_RELOAD 1
@@ -80,11 +81,11 @@ static inline bool timer_external_clock(AspeedTimer *t)return timer_ctrl_status (t, op_external_clock); } -static uint32_t clock_rates[] = {TIMER_CLOCK_APB_HZ ,TIMER_CLOCK_EXT_HZ }; -static inline uint32_t calculate_rate (struct AspeedTimer *t) { -return clock_rates[timer_external_clock (t)]; +AspeedTimerCtrlState *s =timer_to_ctrl (t); + +return timer_external_clock (t) ?TIMER_CLOCK_EXT_HZ : s->scu->apb_freq; }static inline uint32_t calculate_ticks (struct AspeedTimer *t,uint64_t now_ns)
@@ -449,6 +450,16 @@ static void aspeed_timer_realize(DeviceState *dev, Error **errp)int i;SysBusDevice *sbd =SYS_BUS_DEVICE (dev);AspeedTimerCtrlState *s =ASPEED_TIMER (dev); +Object *obj; +Error *err =NULL ; + + obj =object_property_get_link (OBJECT (dev),"scu" , &err); +if (!obj) { +error_propagate (errp, err); +error_prepend (errp,"required link 'scu' not found: " ); +return ; + } + s->scu =ASPEED_SCU (obj);for (i =0 ; i <ASPEED_TIMER_NR_TIMERS ; i++) {aspeed_init_one_timer (s, i);
Signature · 1 line
2.17.1
Peter Maydell
AppliedQuoted 29 lines · Peter Maydell
target-arm queue: mostly smallish stuff. I expect to send out another pullreq at the end of this week, but since this is up to 32 patches already I'd rather send it out now than accumulate a monster sized patchset.
thanks
-- PMMThe following changes since commit
0ab4c574a55448a37b9f616259b82950742c9427:Merge remote-tracking branch 'remotes/kraxel/tags/ui-20180626-pull-request' into staging (2018-06-26 16:44:57 +0100)
are available in the Git repository at:
git://git.linaro.org/people/pmaydell/qemu-arm.gittags/pull-target-arm-20180626for you to fetch changes up to
9b945a9ee36a34eaeca412ef9ef35fbfe33c2c85:aspeed/timer: use the APB frequency from the SCU (2018-06-26 17:50:42 +0100)
----------------------------------------------------------------
target-arm queue:
* aspeed: set APB clocks correctly (fixes slowdown on palmetto)
* smmuv3: cache config data and TLB entries
* v7m/v8m: support read/write from MPU regions smaller than 1K
* various: clean up logging/debug messages
*xilinx_spips: Make dma transactions as perdma_burst_size
Quoted 1 line
----------------------------------------------------------------
Applied, thanks.
-- PMM