Skip to content

Commit 81d3864

Browse files
committed
Merge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20180615' into staging
target-arm and miscellaneous queue: * fix KVM state save/restore for GICv3 priority registers for high IRQ numbers * hw/arm/mps2-tz: Put ethernet controller behind PPC * hw/sh/sh7750: Convert away from old_mmio * hw/m68k/mcf5206: Convert away from old_mmio * hw/block/pflash_cfi02: Convert away from old_mmio * hw/watchdog/wdt_i6300esb: Convert away from old_mmio * hw/input/pckbd: Convert away from old_mmio * hw/char/parallel: Convert away from old_mmio * armv7m: refactor to get rid of armv7m_init() function * arm: Don't crash if user tries to use a Cortex-M CPU without an NVIC * hw/core/or-irq: Support more than 16 inputs to an OR gate * cpu-defs.h: Document CPUIOTLBEntry 'addr' field * cputlb: Pass cpu_transaction_failed() the correct physaddr * CODING_STYLE: Define our preferred form for multiline comments * Add and use new stn_*_p() and ldn_*_p() memory access functions * target/arm: More parts of the upcoming SVE support * aspeed_scu: Implement RNG register * m25p80: add support for two bytes WRSR for Macronix chips * exec.c: Handle IOMMUs being in the path of TCG CPU memory accesses * target/arm: Allow ARMv6-M Thumb2 instructions # gpg: Signature made Fri 15 Jun 2018 15:24:03 BST # gpg: using RSA key 3C2525ED14360CDE # gpg: Good signature from "Peter Maydell <peter.maydell@linaro.org>" # gpg: aka "Peter Maydell <pmaydell@gmail.com>" # gpg: aka "Peter Maydell <pmaydell@chiark.greenend.org.uk>" # Primary key fingerprint: E1A5 C593 CD41 9DE2 8E83 15CF 3C25 25ED 1436 0CDE * remotes/pmaydell/tags/pull-target-arm-20180615: (43 commits) target/arm: Allow ARMv6-M Thumb2 instructions exec.c: Handle IOMMUs in address_space_translate_for_iotlb() iommu: Add IOMMU index argument to translate method iommu: Add IOMMU index argument to notifier APIs iommu: Add IOMMU index concept to IOMMU API m25p80: add support for two bytes WRSR for Macronix chips aspeed_scu: Implement RNG register target/arm: Implement SVE Floating Point Arithmetic - Unpredicated Group target/arm: Implement SVE Integer Wide Immediate - Unpredicated Group target/arm: Implement FDUP/DUP target/arm: Implement SVE Integer Compare - Scalars Group target/arm: Implement SVE Predicate Count Group target/arm: Implement SVE Partition Break Group target/arm: Implement SVE Integer Compare - Immediate Group target/arm: Implement SVE Integer Compare - Vectors Group target/arm: Implement SVE Select Vectors Group target/arm: Implement SVE vector splice (predicated) target/arm: Implement SVE reverse within elements target/arm: Implement SVE copy to vector (predicated) target/arm: Implement SVE conditionally broadcast/extract element ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2 parents 2702c2d + 1412010 commit 81d3864

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+4114
-363
lines changed

CODING_STYLE

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,23 @@ We use traditional C-style /* */ comments and avoid // comments.
124124
Rationale: The // form is valid in C99, so this is purely a matter of
125125
consistency of style. The checkpatch script will warn you about this.
126126

127+
Multiline comment blocks should have a row of stars on the left,
128+
and the initial /* and terminating */ both on their own lines:
129+
/*
130+
* like
131+
* this
132+
*/
133+
This is the same format required by the Linux kernel coding style.
134+
135+
(Some of the existing comments in the codebase use the GNU Coding
136+
Standards form which does not have stars on the left, or other
137+
variations; avoid these when writing new comments, but don't worry
138+
about converting to the preferred form unless you're editing that
139+
comment anyway.)
140+
141+
Rationale: Consistency, and ease of visually picking out a multiline
142+
comment from the surrounding code.
143+
127144
8. trace-events style
128145

129146
8.1 0x prefix

accel/tcg/cputlb.c

Lines changed: 45 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,8 @@ void tlb_set_page_with_attrs(CPUState *cpu, target_ulong vaddr,
632632
}
633633

634634
sz = size;
635-
section = address_space_translate_for_iotlb(cpu, asidx, paddr, &xlat, &sz);
635+
section = address_space_translate_for_iotlb(cpu, asidx, paddr, &xlat, &sz,
636+
attrs, &prot);
636637
assert(sz >= TARGET_PAGE_SIZE);
637638

638639
tlb_debug("vaddr=" TARGET_FMT_lx " paddr=0x" TARGET_FMT_plx
@@ -664,6 +665,18 @@ void tlb_set_page_with_attrs(CPUState *cpu, target_ulong vaddr,
664665
env->iotlb_v[mmu_idx][vidx] = env->iotlb[mmu_idx][index];
665666

666667
/* refill the tlb */
668+
/*
669+
* At this point iotlb contains a physical section number in the lower
670+
* TARGET_PAGE_BITS, and either
671+
* + the ram_addr_t of the page base of the target RAM (if NOTDIRTY or ROM)
672+
* + the offset within section->mr of the page base (otherwise)
673+
* We subtract the vaddr (which is page aligned and thus won't
674+
* disturb the low bits) to give an offset which can be added to the
675+
* (non-page-aligned) vaddr of the eventual memory access to get
676+
* the MemoryRegion offset for the access. Note that the vaddr we
677+
* subtract here is that of the page base, and not the same as the
678+
* vaddr we add back in io_readx()/io_writex()/get_page_addr_code().
679+
*/
667680
env->iotlb[mmu_idx][index].addr = iotlb - vaddr;
668681
env->iotlb[mmu_idx][index].attrs = attrs;
669682

@@ -765,13 +778,16 @@ static uint64_t io_readx(CPUArchState *env, CPUIOTLBEntry *iotlbentry,
765778
target_ulong addr, uintptr_t retaddr, int size)
766779
{
767780
CPUState *cpu = ENV_GET_CPU(env);
768-
hwaddr physaddr = iotlbentry->addr;
769-
MemoryRegion *mr = iotlb_to_region(cpu, physaddr, iotlbentry->attrs);
781+
hwaddr mr_offset;
782+
MemoryRegionSection *section;
783+
MemoryRegion *mr;
770784
uint64_t val;
771785
bool locked = false;
772786
MemTxResult r;
773787

774-
physaddr = (physaddr & TARGET_PAGE_MASK) + addr;
788+
section = iotlb_to_section(cpu, iotlbentry->addr, iotlbentry->attrs);
789+
mr = section->mr;
790+
mr_offset = (iotlbentry->addr & TARGET_PAGE_MASK) + addr;
775791
cpu->mem_io_pc = retaddr;
776792
if (mr != &io_mem_rom && mr != &io_mem_notdirty && !cpu->can_do_io) {
777793
cpu_io_recompile(cpu, retaddr);
@@ -783,9 +799,13 @@ static uint64_t io_readx(CPUArchState *env, CPUIOTLBEntry *iotlbentry,
783799
qemu_mutex_lock_iothread();
784800
locked = true;
785801
}
786-
r = memory_region_dispatch_read(mr, physaddr,
802+
r = memory_region_dispatch_read(mr, mr_offset,
787803
&val, size, iotlbentry->attrs);
788804
if (r != MEMTX_OK) {
805+
hwaddr physaddr = mr_offset +
806+
section->offset_within_address_space -
807+
section->offset_within_region;
808+
789809
cpu_transaction_failed(cpu, physaddr, addr, size, MMU_DATA_LOAD,
790810
mmu_idx, iotlbentry->attrs, r, retaddr);
791811
}
@@ -802,12 +822,15 @@ static void io_writex(CPUArchState *env, CPUIOTLBEntry *iotlbentry,
802822
uintptr_t retaddr, int size)
803823
{
804824
CPUState *cpu = ENV_GET_CPU(env);
805-
hwaddr physaddr = iotlbentry->addr;
806-
MemoryRegion *mr = iotlb_to_region(cpu, physaddr, iotlbentry->attrs);
825+
hwaddr mr_offset;
826+
MemoryRegionSection *section;
827+
MemoryRegion *mr;
807828
bool locked = false;
808829
MemTxResult r;
809830

810-
physaddr = (physaddr & TARGET_PAGE_MASK) + addr;
831+
section = iotlb_to_section(cpu, iotlbentry->addr, iotlbentry->attrs);
832+
mr = section->mr;
833+
mr_offset = (iotlbentry->addr & TARGET_PAGE_MASK) + addr;
811834
if (mr != &io_mem_rom && mr != &io_mem_notdirty && !cpu->can_do_io) {
812835
cpu_io_recompile(cpu, retaddr);
813836
}
@@ -818,9 +841,13 @@ static void io_writex(CPUArchState *env, CPUIOTLBEntry *iotlbentry,
818841
qemu_mutex_lock_iothread();
819842
locked = true;
820843
}
821-
r = memory_region_dispatch_write(mr, physaddr,
844+
r = memory_region_dispatch_write(mr, mr_offset,
822845
val, size, iotlbentry->attrs);
823846
if (r != MEMTX_OK) {
847+
hwaddr physaddr = mr_offset +
848+
section->offset_within_address_space -
849+
section->offset_within_region;
850+
824851
cpu_transaction_failed(cpu, physaddr, addr, size, MMU_DATA_STORE,
825852
mmu_idx, iotlbentry->attrs, r, retaddr);
826853
}
@@ -868,12 +895,13 @@ static bool victim_tlb_hit(CPUArchState *env, size_t mmu_idx, size_t index,
868895
*/
869896
tb_page_addr_t get_page_addr_code(CPUArchState *env, target_ulong addr)
870897
{
871-
int mmu_idx, index, pd;
898+
int mmu_idx, index;
872899
void *p;
873900
MemoryRegion *mr;
901+
MemoryRegionSection *section;
874902
CPUState *cpu = ENV_GET_CPU(env);
875903
CPUIOTLBEntry *iotlbentry;
876-
hwaddr physaddr;
904+
hwaddr physaddr, mr_offset;
877905

878906
index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1);
879907
mmu_idx = cpu_mmu_index(env, true);
@@ -884,8 +912,8 @@ tb_page_addr_t get_page_addr_code(CPUArchState *env, target_ulong addr)
884912
}
885913
}
886914
iotlbentry = &env->iotlb[mmu_idx][index];
887-
pd = iotlbentry->addr & ~TARGET_PAGE_MASK;
888-
mr = iotlb_to_region(cpu, pd, iotlbentry->attrs);
915+
section = iotlb_to_section(cpu, iotlbentry->addr, iotlbentry->attrs);
916+
mr = section->mr;
889917
if (memory_region_is_unassigned(mr)) {
890918
qemu_mutex_lock_iothread();
891919
if (memory_region_request_mmio_ptr(mr, addr)) {
@@ -906,7 +934,10 @@ tb_page_addr_t get_page_addr_code(CPUArchState *env, target_ulong addr)
906934
* and use the MemTXResult it produced). However it is the
907935
* simplest place we have currently available for the check.
908936
*/
909-
physaddr = (iotlbentry->addr & TARGET_PAGE_MASK) + addr;
937+
mr_offset = (iotlbentry->addr & TARGET_PAGE_MASK) + addr;
938+
physaddr = mr_offset +
939+
section->offset_within_address_space -
940+
section->offset_within_region;
910941
cpu_transaction_failed(cpu, physaddr, addr, 0, MMU_INST_FETCH, mmu_idx,
911942
iotlbentry->attrs, MEMTX_DECODE_ERROR, 0);
912943

docs/devel/loads-stores.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,24 @@ The ``_{endian}`` infix is omitted for target-endian accesses.
5353
The target endian accessors are only available to source
5454
files which are built per-target.
5555

56+
There are also functions which take the size as an argument:
57+
58+
load: ``ldn{endian}_p(ptr, sz)``
59+
60+
which performs an unsigned load of ``sz`` bytes from ``ptr``
61+
as an ``{endian}`` order value and returns it in a uint64_t.
62+
63+
store: ``stn{endian}_p(ptr, sz, val)``
64+
65+
which stores ``val`` to ``ptr`` as an ``{endian}`` order value
66+
of size ``sz`` bytes.
67+
68+
5669
Regexes for git grep
5770
- ``\<ldf\?[us]\?[bwlq]\(_[hbl]e\)\?_p\>``
5871
- ``\<stf\?[bwlq]\(_[hbl]e\)\?_p\>``
72+
- ``\<ldn_\([hbl]e\)?_p\>``
73+
- ``\<stn_\([hbl]e\)?_p\>``
5974

6075
``cpu_{ld,st}_*``
6176
~~~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)