system: Move cpu_physical_memory_*() declarations to 'system/physmem.h'
The following cpu_physical_memory_*() methods do not involve any vCPU but only access physical memory: - cpu_physical_memory_read() - cpu_physical_memory_write() - cpu_physical_memory_map() - cpu_physical_memory_unmap() Rename them removing the 'cpu_' prefix, and move then to the "system/physmem.h" header with the other methods involved in global physical address space. Mechanical change using sed, then adding missing headers manually. No logical change intended. Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20260616020839.19104-7-philmd@oss.qualcomm.com>
Philippe Mathieu-Daudé committed
Jun 9, 2026 at 17:07 UTC
cb30b8758d4214c87729da4855518289509675e5
54 files changed
+270
-230
docs/devel/loads-stores.rst
+4
-4
@@ -439,7 +439,7 @@ Regexes for git grep:
439
- ``\<ldu\?[bwlq]\(_[bl]e\)\?_phys\>``
440
- ``\<st[bwlq]\(_[bl]e\)\?_phys\>``
441
442
-``cpu_physical_memory_*``
442
+``physical_memory_*``
443
~~~~~~~~~~~~~~~~~~~~~~~~~
444
445
These are convenience functions which are identical to
@@ -455,12 +455,12 @@ users are hardware device models. For new code they are better avoided:
455
rather than using the system address space
456
* some machines do not use this global address space at all
457
458
-``cpu_physical_memory_read``
458
+``physical_memory_read``
459
460
-``cpu_physical_memory_write``
460
+``physical_memory_write``
461
462
Regexes for git grep:
463
- - ``\<cpu_physical_memory_\(read\|write\)\>``
463
+ - ``\<physical_memory_\(read\|write\)\>``
464
465
``cpu_memory_rw_debug``
466
~~~~~~~~~~~~~~~~~~~~~~~
dump/dump.c
+2
-1
@@ -21,6 +21,7 @@
21
#include "system/dump.h"
22
#include "system/runstate.h"
23
#include "system/cpus.h"
24
+#include "system/physmem.h"
25
#include "qapi/error.h"
26
#include "qapi/qapi-commands-dump.h"
27
#include "qapi/qapi-events-dump.h"
@@ -1892,7 +1893,7 @@ static void dump_init(DumpState *s, int fd, bool has_format,
1893
warn_report("guest note format is unsupported: %" PRIu16, guest_format);
1894
} else {
1895
s->guest_note = g_malloc(size + 1); /* +1 for adding \0 */
1895
- cpu_physical_memory_read(addr, s->guest_note, size);
1896
+ physical_memory_read(addr, s->guest_note, size);
1897
1898
get_note_sizes(s, s->guest_note, NULL, &name_size, &desc_size);
1899
s->guest_note_size = ELF_NOTE_SIZE(note_head_size, name_size,
dump/win_dump-x86.c
+3
-2
@@ -10,6 +10,7 @@
10
11
#include "qemu/osdep.h"
12
#include "system/dump.h"
13
+#include "system/physmem.h"
14
#include "qapi/error.h"
15
#include "qemu/error-report.h"
16
#include "exec/cpu-defs.h"
@@ -55,7 +56,7 @@ static size_t write_run(uint64_t base_page, uint64_t page_count,
56
while (size) {
57
len = size;
58
58
- buf = cpu_physical_memory_map(addr, &len, false);
59
+ buf = physical_memory_map(addr, &len, false);
60
if (!buf) {
61
error_setg(errp, "win-dump: failed to map physical range"
62
" 0x%016" PRIx64 "-0x%016" PRIx64, addr, addr + size - 1);
@@ -64,7 +65,7 @@ static size_t write_run(uint64_t base_page, uint64_t page_count,
65
66
l = qemu_write_full(fd, buf, len);
67
eno = errno;
67
- cpu_physical_memory_unmap(buf, addr, false, len);
68
+ physical_memory_unmap(buf, addr, false, len);
69
if (l != len) {
70
error_setg_errno(errp, eno, "win-dump: failed to save memory");
71
return 0;
hw/acpi/ghes.c
+11
-13
@@ -28,6 +28,7 @@
28
#include "hw/nvram/fw_cfg.h"
29
#include "qemu/uuid.h"
30
#include "exec/cpu-common.h"
31
+#include "system/physmem.h"
32
33
#define ACPI_HW_ERROR_FW_CFG_FILE "etc/hardware_errors"
34
#define ACPI_HW_ERROR_ADDR_FW_CFG_FILE "etc/hardware_errors_addr"
@@ -432,9 +433,7 @@ static void get_hw_error_offsets(uint64_t ghes_addr,
433
* the source ID, as it is stored inside the HEST table.
434
*/
435
435
- cpu_physical_memory_read(ghes_addr, cper_addr,
436
- sizeof(*cper_addr));
437
-
436
+ physical_memory_read(ghes_addr, cper_addr, sizeof(*cper_addr));
437
*cper_addr = le64_to_cpu(*cper_addr);
438
439
/*
@@ -456,8 +455,7 @@ static bool get_ghes_source_offsets(uint16_t source_id,
455
456
hest_addr += ACPI_DESC_HEADER_OFFSET;
457
459
- cpu_physical_memory_read(hest_addr, &num_sources,
460
- sizeof(num_sources));
458
+ physical_memory_read(hest_addr, &num_sources, sizeof(num_sources));
459
num_sources = le32_to_cpu(num_sources);
460
461
err_source_entry = hest_addr + sizeof(num_sources);
@@ -469,7 +467,7 @@ static bool get_ghes_source_offsets(uint16_t source_id,
467
uint64_t addr = err_source_entry;
468
uint16_t type, src_id;
469
472
- cpu_physical_memory_read(addr, &type, sizeof(type));
470
+ physical_memory_read(addr, &type, sizeof(type));
471
type = le16_to_cpu(type);
472
473
/* For now, we only know the size of GHESv2 table */
@@ -480,7 +478,7 @@ static bool get_ghes_source_offsets(uint16_t source_id,
478
479
/* Compare CPER source ID at the GHESv2 structure */
480
addr += sizeof(type);
483
- cpu_physical_memory_read(addr, &src_id, sizeof(src_id));
481
+ physical_memory_read(addr, &src_id, sizeof(src_id));
482
if (le16_to_cpu(src_id) == source_id) {
483
break;
484
}
@@ -496,17 +494,17 @@ static bool get_ghes_source_offsets(uint16_t source_id,
494
hest_err_block_addr = err_source_entry + GHES_ERR_STATUS_ADDR_OFF +
495
GAS_ADDR_OFFSET;
496
499
- cpu_physical_memory_read(hest_err_block_addr, &error_block_addr,
497
+ physical_memory_read(hest_err_block_addr, &error_block_addr,
498
sizeof(error_block_addr));
499
error_block_addr = le64_to_cpu(error_block_addr);
500
503
- cpu_physical_memory_read(error_block_addr, cper_addr,
501
+ physical_memory_read(error_block_addr, cper_addr,
502
sizeof(*cper_addr));
503
*cper_addr = le64_to_cpu(*cper_addr);
504
505
hest_read_ack_addr = err_source_entry + GHES_READ_ACK_ADDR_OFF +
506
GAS_ADDR_OFFSET;
509
- cpu_physical_memory_read(hest_read_ack_addr, read_ack_start_addr,
507
+ physical_memory_read(hest_read_ack_addr, read_ack_start_addr,
508
sizeof(*read_ack_start_addr));
509
*read_ack_start_addr = le64_to_cpu(*read_ack_start_addr);
510
@@ -535,7 +533,7 @@ bool ghes_record_cper_errors(AcpiGhesState *ags, const void *cper, size_t len,
533
return false;
534
}
535
538
- cpu_physical_memory_read(read_ack_register_addr,
536
+ physical_memory_read(read_ack_register_addr,
537
&read_ack_register, sizeof(read_ack_register));
538
539
/* zero means OSPM does not acknowledge the error */
@@ -551,11 +549,11 @@ bool ghes_record_cper_errors(AcpiGhesState *ags, const void *cper, size_t len,
549
* Clear the Read Ack Register, OSPM will write 1 to this register when
550
* it acknowledges the error.
551
*/
554
- cpu_physical_memory_write(read_ack_register_addr,
552
+ physical_memory_write(read_ack_register_addr,
553
&read_ack_register, sizeof(uint64_t));
554
555
/* Write the generic error data entry into guest memory */
558
- cpu_physical_memory_write(cper_addr, cper, len);
556
+ physical_memory_write(cper_addr, cper, len);
557
558
notifier_list_notify(&acpi_generic_error_notifiers, &source_id);
559
hw/acpi/nvdimm.c
+7
-6
@@ -35,6 +35,7 @@
35
#include "hw/nvram/fw_cfg.h"
36
#include "hw/mem/nvdimm.h"
37
#include "qemu/nvdimm-utils.h"
38
+#include "system/physmem.h"
39
#include "trace.h"
40
#include "exec/cpu-common.h"
41
@@ -515,7 +516,7 @@ nvdimm_dsm_function0(uint32_t supported_func, hwaddr dsm_mem_addr)
516
.len = cpu_to_le32(sizeof(func0)),
517
.supported_func = cpu_to_le32(supported_func),
518
};
518
- cpu_physical_memory_write(dsm_mem_addr, &func0, sizeof(func0));
519
+ physical_memory_write(dsm_mem_addr, &func0, sizeof(func0));
520
}
521
522
static void
@@ -525,7 +526,7 @@ nvdimm_dsm_no_payload(uint32_t func_ret_status, hwaddr dsm_mem_addr)
526
.len = cpu_to_le32(sizeof(out)),
527
.func_ret_status = cpu_to_le32(func_ret_status),
528
};
528
- cpu_physical_memory_write(dsm_mem_addr, &out, sizeof(out));
529
+ physical_memory_write(dsm_mem_addr, &out, sizeof(out));
530
}
531
532
#define NVDIMM_DSM_RET_STATUS_SUCCESS 0 /* Success */
@@ -580,7 +581,7 @@ exit:
581
read_fit_out->func_ret_status = cpu_to_le32(func_ret_status);
582
memcpy(read_fit_out->fit, fit->data + read_fit->offset, read_len);
583
583
- cpu_physical_memory_write(dsm_mem_addr, read_fit_out, size);
584
+ physical_memory_write(dsm_mem_addr, read_fit_out, size);
585
586
g_free(read_fit_out);
587
}
@@ -666,7 +667,7 @@ static void nvdimm_dsm_label_size(NVDIMMDevice *nvdimm, hwaddr dsm_mem_addr)
667
label_size_out.label_size = cpu_to_le32(label_size);
668
label_size_out.max_xfer = cpu_to_le32(mxfer);
669
669
- cpu_physical_memory_write(dsm_mem_addr, &label_size_out,
670
+ physical_memory_write(dsm_mem_addr, &label_size_out,
671
sizeof(label_size_out));
672
}
673
@@ -735,7 +736,7 @@ static void nvdimm_dsm_get_label_data(NVDIMMDevice *nvdimm, NvdimmDsmIn *in,
736
nvc->read_label_data(nvdimm, get_label_data_out->out_buf,
737
get_label_data->length, get_label_data->offset);
738
738
- cpu_physical_memory_write(dsm_mem_addr, get_label_data_out, size);
739
+ physical_memory_write(dsm_mem_addr, get_label_data_out, size);
740
g_free(get_label_data_out);
741
}
742
@@ -845,7 +846,7 @@ nvdimm_dsm_write(void *opaque, hwaddr addr, uint64_t val, unsigned size)
846
* this by copying DSM memory to QEMU local memory.
847
*/
848
in = g_new(NvdimmDsmIn, 1);
848
- cpu_physical_memory_read(dsm_mem_addr, in, sizeof(*in));
849
+ physical_memory_read(dsm_mem_addr, in, sizeof(*in));
850
851
in->revision = le32_to_cpu(in->revision);
852
in->function = le32_to_cpu(in->function);
hw/acpi/vmgenid.c
+2
-1
@@ -20,6 +20,7 @@
20
#include "hw/core/qdev-properties.h"
21
#include "hw/core/qdev-properties-system.h"
22
#include "migration/vmstate.h"
23
+#include "system/physmem.h"
24
#include "system/reset.h"
25
#include "exec/cpu-common.h"
26
@@ -156,7 +157,7 @@ static void vmgenid_update_guest(VmGenIdState *vms)
157
* in order to implement the "OVMF SDT Header probe suppressor"
158
* see docs/specs/vmgenid.rst for more details.
159
*/
159
- cpu_physical_memory_write(vmgenid_addr, guid_le.data,
160
+ physical_memory_write(vmgenid_addr, guid_le.data,
161
sizeof(guid_le.data));
162
/* Send _GPE.E05 event */
163
acpi_send_event(DEVICE(obj), ACPI_VMGENID_CHANGE_STATUS);
hw/audio/marvell_88w8618.c
+2
-1
@@ -21,6 +21,7 @@
21
#include "qapi/error.h"
22
#include "qemu/module.h"
23
#include "qom/object.h"
24
+#include "system/physmem.h"
25
26
#define MP_AUDIO_SIZE 0x00001000
27
@@ -87,7 +88,7 @@ static void mv88w8618_audio_callback(void *opaque, int free_out, int free_in)
88
if (block_size > 4096) {
89
return;
90
}
90
- cpu_physical_memory_read(s->target_buffer + s->play_pos, buf, block_size);
91
+ physical_memory_read(s->target_buffer + s->play_pos, buf, block_size);
92
mem_buffer = buf;
93
if (s->playback_mode & MP_AUDIO_16BIT_SAMPLE) {
94
if (s->playback_mode & MP_AUDIO_MONO) {
hw/char/riscv_htif.c
+3
-2
@@ -30,6 +30,7 @@
30
#include "qemu/error-report.h"
31
#include "system/address-spaces.h"
32
#include "system/dma.h"
33
+#include "system/physmem.h"
34
#include "system/runstate.h"
35
#include "exec/cpu-common.h"
36
#include "trace.h"
@@ -209,12 +210,12 @@ static void htif_handle_tohost_write(HTIFState *s, uint64_t val_written)
210
return;
211
} else {
212
uint64_t syscall[8];
212
- cpu_physical_memory_read(payload, syscall, sizeof(syscall));
213
+ physical_memory_read(payload, syscall, sizeof(syscall));
214
if (le64_to_cpu(syscall[0]) == PK_SYS_WRITE &&
215
le64_to_cpu(syscall[1]) == HTIF_DEV_CONSOLE &&
216
le64_to_cpu(syscall[3]) == HTIF_CONSOLE_CMD_PUTC) {
217
uint8_t ch;
217
- cpu_physical_memory_read(le64_to_cpu(syscall[2]), &ch, 1);
218
+ physical_memory_read(le64_to_cpu(syscall[2]), &ch, 1);
219
/*
220
* XXX this blocks entire thread. Rewrite to use
221
* qemu_chr_fe_write and background I/O callbacks
hw/display/exynos4210_fimd.c
+4
-3
@@ -28,6 +28,7 @@
28
#include "hw/core/sysbus.h"
29
#include "exec/cpu-common.h"
30
#include "migration/vmstate.h"
31
+#include "system/physmem.h"
32
#include "ui/console.h"
33
#include "ui/pixel_ops.h"
34
#include "qemu/bswap.h"
@@ -1076,7 +1077,7 @@ static void fimd_update_memory_section(Exynos4210fimdState *s, unsigned win)
1077
}
1078
1079
if (w->host_fb_addr) {
1079
- cpu_physical_memory_unmap(w->host_fb_addr, w->fb_len, 0, 0);
1080
+ physical_memory_unmap(w->host_fb_addr, w->fb_len, 0, 0);
1081
w->host_fb_addr = NULL;
1082
w->fb_len = 0;
1083
}
@@ -1115,7 +1116,7 @@ static void fimd_update_memory_section(Exynos4210fimdState *s, unsigned win)
1116
goto error_return;
1117
}
1118
1118
- w->host_fb_addr = cpu_physical_memory_map(fb_start_addr, &fb_mapped_len,
1119
+ w->host_fb_addr = physical_memory_map(fb_start_addr, &fb_mapped_len,
1120
false);
1121
if (!w->host_fb_addr) {
1122
qemu_log_mask(LOG_GUEST_ERROR,
@@ -1127,7 +1128,7 @@ static void fimd_update_memory_section(Exynos4210fimdState *s, unsigned win)
1128
qemu_log_mask(LOG_GUEST_ERROR,
1129
"FIMD: Window %u mapped framebuffer length is less than "
1130
"expected\n", win);
1130
- cpu_physical_memory_unmap(w->host_fb_addr, fb_mapped_len, 0, 0);
1131
+ physical_memory_unmap(w->host_fb_addr, fb_mapped_len, 0, 0);
1132
goto error_return;
1133
}
1134
memory_region_set_log(w->mem_section.mr, true, DIRTY_MEMORY_VGA);
hw/display/omap_lcdc.c
+3
-2
@@ -24,6 +24,7 @@
24
#include "framebuffer.h"
25
#include "ui/pixel_ops.h"
26
#include "exec/cpu-common.h"
27
+#include "system/physmem.h"
28
29
struct omap_lcd_panel_s {
30
MemoryRegion *sysmem;
@@ -217,7 +218,7 @@ static bool omap_update_display(void *opaque)
218
219
frame_offset = 0;
220
if (omap_lcd->plm != 2) {
220
- cpu_physical_memory_read(
221
+ physical_memory_read(
222
omap_lcd->dma->phys_framebuffer[omap_lcd->dma->current_frame],
223
omap_lcd->palette, 0x200);
224
switch (omap_lcd->palette[0] >> 12 & 7) {
@@ -371,7 +372,7 @@ static void omap_lcd_update(struct omap_lcd_panel_s *s) {
372
s->dma->phys_framebuffer[1] = s->dma->src_f2_top;
373
374
if (s->plm != 2 && !s->palette_done) {
374
- cpu_physical_memory_read(
375
+ physical_memory_read(
376
s->dma->phys_framebuffer[s->dma->current_frame],
377
s->palette, 0x200);
378
s->palette_done = 1;
hw/display/ramfb.c
+4
-3
@@ -17,6 +17,7 @@
17
#include "hw/display/ramfb.h"
18
#include "hw/display/bochs-vbe.h" /* for limits */
19
#include "ui/console.h"
20
+#include "system/physmem.h"
21
#include "system/reset.h"
22
#include "exec/cpu-common.h"
23
@@ -42,7 +43,7 @@ static void ramfb_unmap_display_surface(pixman_image_t *image, void *unused)
43
void *data = pixman_image_get_data(image);
44
uint32_t size = pixman_image_get_stride(image) *
45
pixman_image_get_height(image);
45
- cpu_physical_memory_unmap(data, size, 0, 0);
46
+ physical_memory_unmap(data, size, 0, 0);
47
}
48
49
static DisplaySurface *ramfb_create_display_surface(int width, int height,
@@ -64,9 +65,9 @@ static DisplaySurface *ramfb_create_display_surface(int width, int height,
65
}
66
67
mapsize = size = stride * (height - 1) + linesize;
67
- data = cpu_physical_memory_map(addr, &mapsize, false);
68
+ data = physical_memory_map(addr, &mapsize, false);
69
if (size != mapsize) {
69
- cpu_physical_memory_unmap(data, mapsize, 0, 0);
70
+ physical_memory_unmap(data, mapsize, 0, 0);
71
return NULL;
72
}
73
hw/dma/i8257.c
+5
-4
@@ -28,6 +28,7 @@
28
#include "migration/vmstate.h"
29
#include "hw/dma/i8257.h"
30
#include "exec/cpu-common.h"
31
+#include "system/physmem.h"
32
#include "qapi/error.h"
33
#include "qemu/main-loop.h"
34
#include "qemu/module.h"
@@ -414,7 +415,7 @@ static int i8257_dma_read_memory(IsaDma *obj, int nchan, void *buf, int pos,
415
int i;
416
uint8_t *p = buf;
417
417
- cpu_physical_memory_read (addr - pos - len, buf, len);
418
+ physical_memory_read(addr - pos - len, buf, len);
419
/* What about 16bit transfers? */
420
for (i = 0; i < len >> 1; i++) {
421
uint8_t b = p[len - i - 1];
@@ -422,7 +423,7 @@ static int i8257_dma_read_memory(IsaDma *obj, int nchan, void *buf, int pos,
423
}
424
}
425
else
425
- cpu_physical_memory_read (addr + pos, buf, len);
426
+ physical_memory_read(addr + pos, buf, len);
427
428
return len;
429
}
@@ -442,7 +443,7 @@ static int i8257_dma_write_memory(IsaDma *obj, int nchan, void *buf, int pos,
443
int i;
444
uint8_t *p = buf;
445
445
- cpu_physical_memory_write (addr - pos - len, buf, len);
446
+ physical_memory_write(addr - pos - len, buf, len);
447
/* What about 16bit transfers? */
448
for (i = 0; i < len; i++) {
449
uint8_t b = p[len - i - 1];
@@ -450,7 +451,7 @@ static int i8257_dma_write_memory(IsaDma *obj, int nchan, void *buf, int pos,
451
}
452
}
453
else
453
- cpu_physical_memory_write (addr + pos, buf, len);
454
+ physical_memory_write(addr + pos, buf, len);
455
456
return len;
457
}
hw/dma/omap_dma.c
+3
-3
@@ -23,7 +23,7 @@
23
#include "hw/arm/omap.h"
24
#include "hw/core/irq.h"
25
#include "hw/arm/soc_dma.h"
26
-#include "exec/cpu-common.h"
26
+#include "system/physmem.h"
27
28
struct omap_dma_channel_s {
29
/* transfer data */
@@ -348,12 +348,12 @@ static void omap_dma_transfer_generic(struct soc_dma_ch_s *dma)
348
/* Transfer a single element */
349
/* FIXME: check the endianness */
350
if (!ch->constant_fill)
351
- cpu_physical_memory_read(a->src, value, ch->data_type);
351
+ physical_memory_read(a->src, value, ch->data_type);
352
else
353
*(uint32_t *) value = ch->color;
354
355
if (!ch->transparent_copy || *(uint32_t *) value != ch->color)
356
- cpu_physical_memory_write(a->dest, value, ch->data_type);
356
+ physical_memory_write(a->dest, value, ch->data_type);
357
358
a->src += a->elem_delta[0];
359
a->dest += a->elem_delta[1];
hw/dma/rc4030.c
+2
-1
@@ -34,6 +34,7 @@
34
#include "qemu/log.h"
35
#include "qemu/module.h"
36
#include "system/address-spaces.h"
37
+#include "system/physmem.h"
38
#include "trace.h"
39
#include "qom/object.h"
40
@@ -303,7 +304,7 @@ static void rc4030_write(void *opaque, hwaddr addr, uint64_t data,
304
if (s->cache_ltag == 0x80000001 && s->cache_bmask == 0xf0f0f0f) {
305
hwaddr dest = s->cache_ptag & ~0x1;
306
dest += (s->cache_maint & 0x3) << 3;
306
- cpu_physical_memory_write(dest, &val, 4);
307
+ physical_memory_write(dest, &val, 4);
308
}
309
break;
310
/* Remote Speed Registers */
hw/dma/sifive_pdma.c
+5
-4
@@ -30,6 +30,7 @@
30
#include "exec/cpu-common.h"
31
#include "migration/vmstate.h"
32
#include "system/dma.h"
33
+#include "system/physmem.h"
34
#include "hw/dma/sifive_pdma.h"
35
36
#define DMA_CONTROL 0x000
@@ -121,16 +122,16 @@ static void sifive_pdma_run(SiFivePDMAState *s, int ch)
122
s->chan[ch].exec_src = src;
123
124
for (n = 0; n < bytes / size; n++) {
124
- cpu_physical_memory_read(s->chan[ch].exec_src, buf, size);
125
- cpu_physical_memory_write(s->chan[ch].exec_dst, buf, size);
125
+ physical_memory_read(s->chan[ch].exec_src, buf, size);
126
+ physical_memory_write(s->chan[ch].exec_dst, buf, size);
127
s->chan[ch].exec_src += size;
128
s->chan[ch].exec_dst += size;
129
s->chan[ch].exec_bytes -= size;
130
}
131
132
if (remainder) {
132
- cpu_physical_memory_read(s->chan[ch].exec_src, buf, remainder);
133
- cpu_physical_memory_write(s->chan[ch].exec_dst, buf, remainder);
133
+ physical_memory_read(s->chan[ch].exec_src, buf, remainder);
134
+ physical_memory_write(s->chan[ch].exec_dst, buf, remainder);
135
s->chan[ch].exec_src += remainder;
136
s->chan[ch].exec_dst += remainder;
137
s->chan[ch].exec_bytes -= remainder;
hw/hyperv/hyperv.c
+13
-12
@@ -17,6 +17,7 @@
17
#include "exec/cpu-common.h"
18
#include "linux/kvm.h"
19
#include "system/kvm.h"
20
+#include "system/physmem.h"
21
#include "qemu/bitops.h"
22
#include "qemu/error-report.h"
23
#include "qemu/lockable.h"
@@ -622,7 +623,7 @@ uint16_t hyperv_hcall_post_message(uint64_t param, bool fast)
623
}
624
625
len = sizeof(*msg);
625
- msg = cpu_physical_memory_map(param, &len, 0);
626
+ msg = physical_memory_map(param, &len, 0);
627
if (len < sizeof(*msg)) {
628
ret = HV_STATUS_INSUFFICIENT_MEMORY;
629
goto unmap;
@@ -643,7 +644,7 @@ uint16_t hyperv_hcall_post_message(uint64_t param, bool fast)
644
}
645
646
unmap:
646
- cpu_physical_memory_unmap(msg, len, 0, 0);
647
+ physical_memory_unmap(msg, len, 0, 0);
648
return ret;
649
}
650
@@ -766,7 +767,7 @@ uint16_t hyperv_hcall_reset_dbg_session(uint64_t outgpa)
767
}
768
769
len = sizeof(*reset_dbg_session);
769
- reset_dbg_session = cpu_physical_memory_map(outgpa, &len, 1);
770
+ reset_dbg_session = physical_memory_map(outgpa, &len, 1);
771
if (!reset_dbg_session || len < sizeof(*reset_dbg_session)) {
772
ret = HV_STATUS_INSUFFICIENT_MEMORY;
773
goto cleanup;
@@ -789,7 +790,7 @@ uint16_t hyperv_hcall_reset_dbg_session(uint64_t outgpa)
790
sizeof(reset_dbg_session->target_mac));
791
cleanup:
792
if (reset_dbg_session) {
792
- cpu_physical_memory_unmap(reset_dbg_session,
793
+ physical_memory_unmap(reset_dbg_session,
794
sizeof(*reset_dbg_session), 1, len);
795
}
796
@@ -811,14 +812,14 @@ uint16_t hyperv_hcall_retreive_dbg_data(uint64_t ingpa, uint64_t outgpa,
812
}
813
814
in_len = sizeof(*debug_data_in);
814
- debug_data_in = cpu_physical_memory_map(ingpa, &in_len, 0);
815
+ debug_data_in = physical_memory_map(ingpa, &in_len, 0);
816
if (!debug_data_in || in_len < sizeof(*debug_data_in)) {
817
ret = HV_STATUS_INSUFFICIENT_MEMORY;
818
goto cleanup;
819
}
820
821
out_len = sizeof(*debug_data_out);
821
- debug_data_out = cpu_physical_memory_map(outgpa, &out_len, 1);
822
+ debug_data_out = physical_memory_map(outgpa, &out_len, 1);
823
if (!debug_data_out || out_len < sizeof(*debug_data_out)) {
824
ret = HV_STATUS_INSUFFICIENT_MEMORY;
825
goto cleanup;
@@ -844,12 +845,12 @@ uint16_t hyperv_hcall_retreive_dbg_data(uint64_t ingpa, uint64_t outgpa,
845
debug_data_in->count - msg.u.recv.retrieved_count;
846
cleanup:
847
if (debug_data_out) {
847
- cpu_physical_memory_unmap(debug_data_out, sizeof(*debug_data_out), 1,
848
+ physical_memory_unmap(debug_data_out, sizeof(*debug_data_out), 1,
849
out_len);
850
}
851
852
if (debug_data_in) {
852
- cpu_physical_memory_unmap(debug_data_in, sizeof(*debug_data_in), 0,
853
+ physical_memory_unmap(debug_data_in, sizeof(*debug_data_in), 0,
854
in_len);
855
}
856
@@ -870,7 +871,7 @@ uint16_t hyperv_hcall_post_dbg_data(uint64_t ingpa, uint64_t outgpa, bool fast)
871
}
872
873
in_len = sizeof(*post_data_in);
873
- post_data_in = cpu_physical_memory_map(ingpa, &in_len, 0);
874
+ post_data_in = physical_memory_map(ingpa, &in_len, 0);
875
if (!post_data_in || in_len < sizeof(*post_data_in)) {
876
ret = HV_STATUS_INSUFFICIENT_MEMORY;
877
goto cleanup;
@@ -882,7 +883,7 @@ uint16_t hyperv_hcall_post_dbg_data(uint64_t ingpa, uint64_t outgpa, bool fast)
883
}
884
885
out_len = sizeof(*post_data_out);
885
- post_data_out = cpu_physical_memory_map(outgpa, &out_len, 1);
886
+ post_data_out = physical_memory_map(outgpa, &out_len, 1);
887
if (!post_data_out || out_len < sizeof(*post_data_out)) {
888
ret = HV_STATUS_INSUFFICIENT_MEMORY;
889
goto cleanup;
@@ -902,12 +903,12 @@ uint16_t hyperv_hcall_post_dbg_data(uint64_t ingpa, uint64_t outgpa, bool fast)
903
HV_STATUS_SUCCESS;
904
cleanup:
905
if (post_data_out) {
905
- cpu_physical_memory_unmap(post_data_out,
906
+ physical_memory_unmap(post_data_out,
907
sizeof(*post_data_out), 1, out_len);
908
}
909
910
if (post_data_in) {
910
- cpu_physical_memory_unmap(post_data_in,
911
+ physical_memory_unmap(post_data_in,
912
sizeof(*post_data_in), 0, in_len);
913
}
914
hw/hyperv/syndbg.c
+7
-6
@@ -20,6 +20,7 @@
20
#include "hw/hyperv/vmbus-bridge.h"
21
#include "hw/hyperv/hyperv-proto.h"
22
#include "exec/cpu-common.h"
23
+#include "system/physmem.h"
24
#include "net/net.h"
25
#include "net/eth.h"
26
#include "net/checksum.h"
@@ -62,10 +63,10 @@ static void set_pending_state(HvSynDbg *syndbg, bool has_pending)
63
}
64
65
out_len = 1;
65
- out_data = cpu_physical_memory_map(syndbg->pending_page_gpa, &out_len, 1);
66
+ out_data = physical_memory_map(syndbg->pending_page_gpa, &out_len, 1);
67
if (out_data) {
68
*(uint8_t *)out_data = !!has_pending;
68
- cpu_physical_memory_unmap(out_data, out_len, 1, out_len);
69
+ physical_memory_unmap(out_data, out_len, 1, out_len);
70
}
71
}
72
@@ -110,7 +111,7 @@ static uint16_t handle_send_msg(HvSynDbg *syndbg, uint64_t ingpa,
111
int sent_count;
112
113
data_len = count;
113
- debug_data = cpu_physical_memory_map(ingpa, &data_len, 0);
114
+ debug_data = physical_memory_map(ingpa, &data_len, 0);
115
if (!debug_data || data_len < count) {
116
ret = HV_STATUS_INSUFFICIENT_MEMORY;
117
goto cleanup;
@@ -135,7 +136,7 @@ static uint16_t handle_send_msg(HvSynDbg *syndbg, uint64_t ingpa,
136
ret = HV_STATUS_SUCCESS;
137
cleanup:
138
if (debug_data) {
138
- cpu_physical_memory_unmap(debug_data, count, 0, data_len);
139
+ physical_memory_unmap(debug_data, count, 0, data_len);
140
}
141
142
return ret;
@@ -224,7 +225,7 @@ static uint16_t handle_recv_msg(HvSynDbg *syndbg, uint64_t outgpa,
225
out_len += UDP_PKT_HEADER_SIZE;
226
}
227
out_requested_len = out_len;
227
- out_data = cpu_physical_memory_map(outgpa, &out_len, 1);
228
+ out_data = physical_memory_map(outgpa, &out_len, 1);
229
ret = HV_STATUS_INSUFFICIENT_MEMORY;
230
if (!out_data || out_len < out_requested_len) {
231
goto cleanup_out_data;
@@ -243,7 +244,7 @@ static uint16_t handle_recv_msg(HvSynDbg *syndbg, uint64_t outgpa,
244
245
cleanup_out_data:
246
if (out_data) {
246
- cpu_physical_memory_unmap(out_data, out_len, 1, out_len);
247
+ physical_memory_unmap(out_data, out_len, 1, out_len);
248
}
249
return ret;
250
}
hw/hyperv/vmbus.c
+5
-4
@@ -21,6 +21,7 @@
21
#include "hw/core/sysbus.h"
22
#include "exec/cpu-common.h"
23
#include "system/kvm.h"
24
+#include "system/physmem.h"
25
#include "trace.h"
26
27
enum {
@@ -750,7 +751,7 @@ static int vmbus_channel_notify_guest(VMBusChannel *chan)
751
return hyperv_set_event_flag(chan->notify_route, chan->id);
752
}
753
753
- int_map = cpu_physical_memory_map(addr, &len, 1);
754
+ int_map = physical_memory_map(addr, &len, 1);
755
if (len != TARGET_PAGE_SIZE / 2) {
756
res = -ENXIO;
757
goto unmap;
@@ -764,7 +765,7 @@ static int vmbus_channel_notify_guest(VMBusChannel *chan)
765
}
766
767
unmap:
767
- cpu_physical_memory_unmap(int_map, len, 1, dirty);
768
+ physical_memory_unmap(int_map, len, 1, dirty);
769
return res;
770
}
771
@@ -2249,7 +2250,7 @@ static void vmbus_signal_event(EventNotifier *e)
2250
2251
addr = vmbus->int_page_gpa + TARGET_PAGE_SIZE / 2;
2252
len = TARGET_PAGE_SIZE / 2;
2252
- int_map = cpu_physical_memory_map(addr, &len, 1);
2253
+ int_map = physical_memory_map(addr, &len, 1);
2254
if (len != TARGET_PAGE_SIZE / 2) {
2255
goto unmap;
2256
}
@@ -2265,7 +2266,7 @@ static void vmbus_signal_event(EventNotifier *e)
2266
}
2267
2268
unmap:
2268
- cpu_physical_memory_unmap(int_map, len, 1, is_dirty);
2269
+ physical_memory_unmap(int_map, len, 1, is_dirty);
2270
}
2271
2272
static void vmbus_dev_realize(DeviceState *dev, Error **errp)
hw/i386/kvm/clock.c
+2
-1
@@ -19,6 +19,7 @@
19
#include "system/kvm.h"
20
#include "system/runstate.h"
21
#include "system/hw_accel.h"
22
+#include "system/physmem.h"
23
#include "kvm/kvm_i386.h"
24
#include "migration/vmstate.h"
25
#include "hw/core/sysbus.h"
@@ -85,7 +86,7 @@ static uint64_t kvmclock_current_nsec(KVMClockState *s)
86
}
87
88
kvmclock_struct_pa = env->system_time_msr & ~1ULL;
88
- cpu_physical_memory_read(kvmclock_struct_pa, &time, sizeof(time));
89
+ physical_memory_read(kvmclock_struct_pa, &time, sizeof(time));
90
91
assert(time.tsc_timestamp <= migration_tsc);
92
delta = migration_tsc - time.tsc_timestamp;
hw/i386/vapic.c
+11
-10
@@ -19,6 +19,7 @@
19
#include "system/whpx.h"
20
#include "system/runstate.h"
21
#include "system/address-spaces.h"
22
+#include "system/physmem.h"
23
#include "hw/i386/apic_internal.h"
24
#include "hw/core/sysbus.h"
25
#include "hw/core/boards.h"
@@ -138,13 +139,13 @@ static const TPRInstruction tpr_instr[] = {
139
140
static void read_guest_rom_state(VAPICROMState *s)
141
{
141
- cpu_physical_memory_read(s->rom_state_paddr, &s->rom_state,
142
+ physical_memory_read(s->rom_state_paddr, &s->rom_state,
143
sizeof(GuestROMState));
144
}
145
146
static void write_guest_rom_state(VAPICROMState *s)
147
{
147
- cpu_physical_memory_write(s->rom_state_paddr, &s->rom_state,
148
+ physical_memory_write(s->rom_state_paddr, &s->rom_state,
149
sizeof(GuestROMState));
150
}
151
@@ -327,14 +328,14 @@ static int update_rom_mapping(VAPICROMState *s, CPUX86State *env, target_ulong i
328
for (pos = le32_to_cpu(s->rom_state.fixup_start);
329
pos < le32_to_cpu(s->rom_state.fixup_end);
330
pos += 4) {
330
- cpu_physical_memory_read(paddr + pos - s->rom_state.vaddr,
331
+ physical_memory_read(paddr + pos - s->rom_state.vaddr,
332
&offset, sizeof(offset));
333
offset = le32_to_cpu(offset);
333
- cpu_physical_memory_read(paddr + offset, &patch, sizeof(patch));
334
+ physical_memory_read(paddr + offset, &patch, sizeof(patch));
335
patch = le32_to_cpu(patch);
336
patch += rom_state_vaddr - le32_to_cpu(s->rom_state.vaddr);
337
patch = cpu_to_le32(patch);
337
- cpu_physical_memory_write(paddr + offset, &patch, sizeof(patch));
338
+ physical_memory_write(paddr + offset, &patch, sizeof(patch));
339
}
340
read_guest_rom_state(s);
341
s->vapic_paddr = paddr + le32_to_cpu(s->rom_state.vapic_vaddr) -
@@ -378,7 +379,7 @@ static int vapic_enable(VAPICROMState *s, X86CPU *cpu)
379
}
380
vapic_paddr = s->vapic_paddr +
381
(((hwaddr)cpu_number) << VAPIC_CPU_SHIFT);
381
- cpu_physical_memory_write(vapic_paddr + offsetof(VAPICState, enabled),
382
+ physical_memory_write(vapic_paddr + offsetof(VAPICState, enabled),
383
&enabled, sizeof(enabled));
384
apic_enable_vapic(cpu->apic_state, vapic_paddr);
385
@@ -549,7 +550,7 @@ static int patch_hypercalls(VAPICROMState *s)
550
uint8_t *rom;
551
552
rom = g_malloc(s->rom_size);
552
- cpu_physical_memory_read(rom_paddr, rom, s->rom_size);
553
+ physical_memory_read(rom_paddr, rom, s->rom_size);
554
555
for (pos = 0; pos < s->rom_size - sizeof(vmcall_pattern); pos++) {
556
if (kvm_enabled() && kvm_irqchip_in_kernel()) {
@@ -565,7 +566,7 @@ static int patch_hypercalls(VAPICROMState *s)
566
}
567
if (memcmp(rom + pos, pattern, 7) == 0 &&
568
(rom[pos + 7] == alternates[0] || rom[pos + 7] == alternates[1])) {
568
- cpu_physical_memory_write(rom_paddr + pos + 5, patch, 3);
569
+ physical_memory_write(rom_paddr + pos + 5, patch, 3);
570
/*
571
* Don't flush the tb here. Under ordinary conditions, the patched
572
* calls are miles away from the current IP. Under malicious
@@ -755,7 +756,7 @@ static void do_vapic_enable(CPUState *cs, run_on_cpu_data data)
756
X86CPU *cpu = X86_CPU(cs);
757
758
static const uint8_t enabled = 1;
758
- cpu_physical_memory_write(s->vapic_paddr + offsetof(VAPICState, enabled),
759
+ physical_memory_write(s->vapic_paddr + offsetof(VAPICState, enabled),
760
&enabled, sizeof(enabled));
761
apic_enable_vapic(cpu->apic_state, s->vapic_paddr);
762
s->state = VAPIC_ACTIVE;
@@ -776,7 +777,7 @@ static void vapic_vm_state_change(void *opaque, bool running, RunState state)
777
run_on_cpu(first_cpu, do_vapic_enable, RUN_ON_CPU_HOST_PTR(s));
778
} else {
779
zero = g_malloc0(s->rom_state.vapic_size);
779
- cpu_physical_memory_write(s->vapic_paddr, zero,
780
+ physical_memory_write(s->vapic_paddr, zero,
781
s->rom_state.vapic_size);
782
g_free(zero);
783
}
hw/intc/apic.c
+2
-1
@@ -28,6 +28,7 @@
28
#include "qemu/host-utils.h"
29
#include "system/kvm.h"
30
#include "system/mshv.h"
31
+#include "system/physmem.h"
32
#include "trace.h"
33
#include "hw/i386/apic-msidef.h"
34
#include "exec/cpu-common.h"
@@ -107,7 +108,7 @@ static void apic_sync_vapic(APICCommonState *s, int sync_type)
108
return;
109
}
110
if (sync_type & SYNC_FROM_VAPIC) {
110
- cpu_physical_memory_read(s->vapic_paddr, &vapic_state,
111
+ physical_memory_read(s->vapic_paddr, &vapic_state,
112
sizeof(vapic_state));
113
s->tpr = vapic_state.tpr;
114
}
hw/intc/xive2.c
+2
-1
@@ -13,6 +13,7 @@
13
#include "target/ppc/cpu.h"
14
#include "system/cpus.h"
15
#include "system/dma.h"
16
+#include "system/physmem.h"
17
#include "hw/core/qdev-properties.h"
18
#include "hw/ppc/xive.h"
19
#include "hw/ppc/xive2.h"
@@ -1170,7 +1171,7 @@ static void xive2_tctx_accept_el(XivePresenter *xptr, XiveTCTX *tctx,
1171
report_data[0] = (rd >> 8) & 0xff;
1172
report_data[1] = rd & 0xff;
1173
}
1173
- cpu_physical_memory_write(phys_addr, report_data, REPORT_LINE_GEN1_SIZE);
1174
+ physical_memory_write(phys_addr, report_data, REPORT_LINE_GEN1_SIZE);
1175
}
1176
1177
void xive2_tm_ack_os_el(XivePresenter *xptr, XiveTCTX *tctx,
hw/m68k/next-cube.c
+2
-1
@@ -14,6 +14,7 @@
14
#include "exec/hwaddr.h"
15
#include "exec/cpu-common.h"
16
#include "exec/cpu-interrupt.h"
17
+#include "system/physmem.h"
18
#include "system/system.h"
19
#include "system/qtest.h"
20
#include "hw/core/irq.h"
@@ -585,7 +586,7 @@ static void nextdma_write(void *opaque, uint8_t *buf, int size, int type)
586
base_addr = next_state->dma[type].next_initbuf;
587
}
588
588
- cpu_physical_memory_write(base_addr, buf, size);
589
+ physical_memory_write(base_addr, buf, size);
590
591
next_state->dma[type].next_initbuf = 0;
592
hw/microblaze/boot.c
+2
-1
@@ -32,6 +32,7 @@
32
#include "qemu/error-report.h"
33
#include "qemu/guest-random.h"
34
#include "system/device_tree.h"
35
+#include "system/physmem.h"
36
#include "system/reset.h"
37
#include "exec/cpu-common.h"
38
#include "hw/core/boards.h"
@@ -106,7 +107,7 @@ static int microblaze_load_dtb(hwaddr addr,
107
initrd_end);
108
}
109
109
- cpu_physical_memory_write(addr, fdt, fdt_size);
110
+ physical_memory_write(addr, fdt, fdt_size);
111
g_free(fdt);
112
return fdt_size;
113
}
hw/misc/pc-testdev.c
+3
-2
@@ -40,6 +40,7 @@
40
#include "hw/core/irq.h"
41
#include "hw/isa/isa.h"
42
#include "exec/cpu-common.h"
43
+#include "system/physmem.h"
44
#include "qom/object.h"
45
46
#define IOMEM_LEN 0x10000
@@ -126,7 +127,7 @@ static void test_flush_page_write(void *opaque, hwaddr addr, uint64_t data,
127
unsigned len)
128
{
129
hwaddr page = 4096;
129
- void *a = cpu_physical_memory_map(data & ~0xffful, &page, false);
130
+ void *a = physical_memory_map(data & ~0xffful, &page, false);
131
132
/* We might not be able to get the full page, only mprotect what we actually
133
have mapped */
@@ -134,7 +135,7 @@ static void test_flush_page_write(void *opaque, hwaddr addr, uint64_t data,
135
mprotect(a, page, PROT_NONE);
136
mprotect(a, page, PROT_READ|PROT_WRITE);
137
#endif
137
- cpu_physical_memory_unmap(a, page, 0, 0);
138
+ physical_memory_unmap(a, page, 0, 0);
139
}
140
141
static const MemoryRegionOps test_flush_ops = {
hw/net/fsl_etsec/rings.c
+7
-6
@@ -26,6 +26,7 @@
26
#include "qemu/log.h"
27
#include "etsec.h"
28
#include "registers.h"
29
+#include "system/physmem.h"
30
#include "exec/cpu-common.h"
31
32
/* #define ETSEC_RING_DEBUG */
@@ -111,7 +112,7 @@ static void read_buffer_descriptor(eTSEC *etsec,
112
assert(bd != NULL);
113
114
RING_DEBUG("READ Buffer Descriptor @ 0x" HWADDR_FMT_plx"\n", addr);
114
- cpu_physical_memory_read(addr,
115
+ physical_memory_read(addr,
116
bd,
117
sizeof(eTSEC_rxtx_bd));
118
@@ -143,7 +144,7 @@ static void write_buffer_descriptor(eTSEC *etsec,
144
}
145
146
RING_DEBUG("Write Buffer Descriptor @ 0x" HWADDR_FMT_plx"\n", addr);
146
- cpu_physical_memory_write(addr,
147
+ physical_memory_write(addr,
148
bd,
149
sizeof(eTSEC_rxtx_bd));
150
}
@@ -240,7 +241,7 @@ static void process_tx_bd(eTSEC *etsec,
241
etsec->tx_buffer = g_realloc(etsec->tx_buffer,
242
etsec->tx_buffer_len + bd->length);
243
tmp_buff = etsec->tx_buffer + etsec->tx_buffer_len;
243
- cpu_physical_memory_read(bd->bufptr + tbdbth, tmp_buff, bd->length);
244
+ physical_memory_read(bd->bufptr + tbdbth, tmp_buff, bd->length);
245
246
/* Update buffer length */
247
etsec->tx_buffer_len += bd->length;
@@ -401,7 +402,7 @@ static void fill_rx_bd(eTSEC *etsec,
402
/* This operation will only write FCB */
403
if (etsec->rx_fcb_size != 0) {
404
404
- cpu_physical_memory_write(bufptr, etsec->rx_fcb, etsec->rx_fcb_size);
405
+ physical_memory_write(bufptr, etsec->rx_fcb, etsec->rx_fcb_size);
406
407
bufptr += etsec->rx_fcb_size;
408
bd->length += etsec->rx_fcb_size;
@@ -417,7 +418,7 @@ static void fill_rx_bd(eTSEC *etsec,
418
419
/* This operation can only write packet data and no padding */
420
if (to_write > 0) {
420
- cpu_physical_memory_write(bufptr, *buf, to_write);
421
+ physical_memory_write(bufptr, *buf, to_write);
422
423
*buf += to_write;
424
bufptr += to_write;
@@ -439,7 +440,7 @@ static void fill_rx_bd(eTSEC *etsec,
440
etsec->rx_padding -= rem;
441
*size -= rem;
442
bd->length += rem;
442
- cpu_physical_memory_write(bufptr, padd, rem);
443
+ physical_memory_write(bufptr, padd, rem);
444
}
445
}
446
}
hw/net/mcf_fec.c
+6
-5
@@ -8,6 +8,7 @@
8
9
#include "qemu/osdep.h"
10
#include "qemu/log.h"
11
+#include "system/physmem.h"
12
#include "hw/core/irq.h"
13
#include "net/net.h"
14
#include "qemu/module.h"
@@ -175,7 +176,7 @@ typedef struct {
176
177
static void mcf_fec_read_bd(mcf_fec_bd *bd, uint32_t addr)
178
{
178
- cpu_physical_memory_read(addr, bd, sizeof(*bd));
179
+ physical_memory_read(addr, bd, sizeof(*bd));
180
be16_to_cpus(&bd->flags);
181
be16_to_cpus(&bd->length);
182
be32_to_cpus(&bd->data);
@@ -187,7 +188,7 @@ static void mcf_fec_write_bd(mcf_fec_bd *bd, uint32_t addr)
188
tmp.flags = cpu_to_be16(bd->flags);
189
tmp.length = cpu_to_be16(bd->length);
190
tmp.data = cpu_to_be32(bd->data);
190
- cpu_physical_memory_write(addr, &tmp, sizeof(tmp));
191
+ physical_memory_write(addr, &tmp, sizeof(tmp));
192
}
193
194
static void mcf_fec_update(mcf_fec_state *s)
@@ -260,7 +261,7 @@ static void mcf_fec_do_tx(mcf_fec_state *s)
261
len = FEC_MAX_FRAME_SIZE - frame_size;
262
s->eir |= FEC_INT_BABT;
263
}
263
- cpu_physical_memory_read(bd.data, ptr, len);
264
+ physical_memory_read(bd.data, ptr, len);
265
ptr += len;
266
frame_size += len;
267
if (bd.flags & FEC_BD_L) {
@@ -596,10 +597,10 @@ static ssize_t mcf_fec_receive(NetClientState *nc, const uint8_t *buf, size_t si
597
if (size < 4)
598
buf_len += size - 4;
599
buf_addr = bd.data;
599
- cpu_physical_memory_write(buf_addr, buf, buf_len);
600
+ physical_memory_write(buf_addr, buf, buf_len);
601
buf += buf_len;
602
if (size < 4) {
602
- cpu_physical_memory_write(buf_addr + buf_len, crc_ptr, 4 - size);
603
+ physical_memory_write(buf_addr + buf_len, crc_ptr, 4 - size);
604
crc_ptr += 4 - size;
605
}
606
bd.flags &= ~FEC_BD_E;
hw/net/opencores_eth.c
+5
-4
@@ -32,6 +32,7 @@
32
*/
33
34
#include "qemu/osdep.h"
35
+#include "system/physmem.h"
36
#include "hw/core/irq.h"
37
#include "hw/net/mii.h"
38
#include "hw/core/qdev-properties.h"
@@ -431,7 +432,7 @@ static ssize_t open_eth_receive(NetClientState *nc,
432
}
433
#endif
434
434
- cpu_physical_memory_write(desc->buf_ptr, buf, copy_size);
435
+ physical_memory_write(desc->buf_ptr, buf, copy_size);
436
437
if (GET_REGBIT(s, MODER, PAD) && copy_size < minfl) {
438
if (minfl - copy_size > fcsl) {
@@ -443,7 +444,7 @@ static ssize_t open_eth_receive(NetClientState *nc,
444
size_t zero_sz = minfl - copy_size < sizeof(zero) ?
445
minfl - copy_size : sizeof(zero);
446
446
- cpu_physical_memory_write(desc->buf_ptr + copy_size,
447
+ physical_memory_write(desc->buf_ptr + copy_size,
448
zero, zero_sz);
449
copy_size += zero_sz;
450
}
@@ -453,7 +454,7 @@ static ssize_t open_eth_receive(NetClientState *nc,
454
* Don't do it if the frame is cut at the MAXFL or padded with 4 or
455
* more bytes to the MINFL.
456
*/
456
- cpu_physical_memory_write(desc->buf_ptr + copy_size, zero, fcsl);
457
+ physical_memory_write(desc->buf_ptr + copy_size, zero, fcsl);
458
copy_size += fcsl;
459
460
SET_FIELD(desc->len_flags, RXD_LEN, copy_size);
@@ -509,7 +510,7 @@ static void open_eth_start_xmit(OpenEthState *s, desc *tx)
510
if (len > tx_len) {
511
len = tx_len;
512
}
512
- cpu_physical_memory_read(tx->buf_ptr, buf, len);
513
+ physical_memory_read(tx->buf_ptr, buf, len);
514
if (tx_len > len) {
515
memset(buf + len, 0, tx_len - len);
516
}
hw/nvram/spapr_nvram.c
+5
-4
@@ -30,6 +30,7 @@
30
31
#include "system/block-backend.h"
32
#include "system/device_tree.h"
33
+#include "system/physmem.h"
34
#include "system/system.h"
35
#include "system/runstate.h"
36
#include "migration/vmstate.h"
@@ -89,9 +90,9 @@ static void rtas_nvram_fetch(PowerPCCPU *cpu, SpaprMachineState *spapr,
90
91
assert(nvram->buf);
92
92
- membuf = cpu_physical_memory_map(buffer, &len, true);
93
+ membuf = physical_memory_map(buffer, &len, true);
94
memcpy(membuf, nvram->buf + offset, len);
94
- cpu_physical_memory_unmap(membuf, len, 1, len);
95
+ physical_memory_unmap(membuf, len, 1, len);
96
97
rtas_st(rets, 0, RTAS_OUT_SUCCESS);
98
rtas_st(rets, 1, len);
@@ -127,7 +128,7 @@ static void rtas_nvram_store(PowerPCCPU *cpu, SpaprMachineState *spapr,
128
return;
129
}
130
130
- membuf = cpu_physical_memory_map(buffer, &len, false);
131
+ membuf = physical_memory_map(buffer, &len, false);
132
133
ret = 0;
134
if (nvram->blk) {
@@ -137,7 +138,7 @@ static void rtas_nvram_store(PowerPCCPU *cpu, SpaprMachineState *spapr,
138
assert(nvram->buf);
139
memcpy(nvram->buf + offset, membuf, len);
140
140
- cpu_physical_memory_unmap(membuf, len, 0, len);
141
+ physical_memory_unmap(membuf, len, 0, len);
142
143
rtas_st(rets, 0, (ret < 0) ? RTAS_OUT_HW_ERROR : RTAS_OUT_SUCCESS);
144
rtas_st(rets, 1, (ret < 0) ? 0 : len);
hw/ppc/amigaone.c
+3
-2
@@ -22,6 +22,7 @@
22
#include "hw/i2c/smbus_eeprom.h"
23
#include "exec/cpu-common.h"
24
#include "system/block-backend.h"
25
+#include "system/physmem.h"
26
#include "system/qtest.h"
27
#include "system/reset.h"
28
#include "kvm_ppc.h"
@@ -231,7 +232,7 @@ static void create_bd_info(hwaddr addr, ram_addr_t ram_size)
232
bd->bi_busfreq = cpu_to_be32(BUS_FREQ_HZ);
233
bd->bi_baudrate = cpu_to_be32(115200);
234
234
- cpu_physical_memory_write(addr, bd, sizeof(*bd));
235
+ physical_memory_write(addr, bd, sizeof(*bd));
236
}
237
238
static void amigaone_cpu_reset(void *opaque)
@@ -386,7 +387,7 @@ static void amigaone_init(MachineState *machine)
387
size_t len = strlen(machine->kernel_cmdline);
388
389
loadaddr = bi->bd_info + 1 * MiB;
389
- cpu_physical_memory_write(loadaddr, machine->kernel_cmdline, len + 1);
390
+ physical_memory_write(loadaddr, machine->kernel_cmdline, len + 1);
391
bi->cmdline_start = loadaddr;
392
bi->cmdline_end = loadaddr + len + 1; /* including terminating '\0' */
393
}
hw/ppc/e500.c
+2
-1
@@ -29,6 +29,7 @@
29
#include "hw/char/serial-mm.h"
30
#include "hw/pci/pci.h"
31
#include "system/block-backend-io.h"
32
+#include "system/physmem.h"
33
#include "system/system.h"
34
#include "system/kvm.h"
35
#include "system/reset.h"
@@ -661,7 +662,7 @@ static int ppce500_load_device_tree(PPCE500MachineState *pms,
662
663
done:
664
if (!dry_run) {
664
- cpu_physical_memory_write(addr, fdt, fdt_size);
665
+ physical_memory_write(addr, fdt, fdt_size);
666
667
/* Set machine->fdt for 'dumpdtb' QMP/HMP command */
668
g_free(machine->fdt);
hw/ppc/pegasos.c
+6
-5
@@ -21,6 +21,7 @@
21
#include "hw/ide/pci.h"
22
#include "hw/i2c/smbus_eeprom.h"
23
#include "hw/core/qdev-properties.h"
24
+#include "system/physmem.h"
25
#include "system/reset.h"
26
#include "system/runstate.h"
27
#include "system/qtest.h"
@@ -314,22 +315,22 @@ static void pegasos_init(MachineState *machine)
315
316
static void pegasos_superio_write(uint8_t addr, uint8_t val)
317
{
317
- cpu_physical_memory_write(0xfe0003f0, &addr, 1);
318
- cpu_physical_memory_write(0xfe0003f1, &val, 1);
318
+ physical_memory_write(0xfe0003f0, &addr, 1);
319
+ physical_memory_write(0xfe0003f1, &val, 1);
320
}
321
322
static void pegasos1_pci_config_write(PegasosMachineState *pm, int bus,
323
uint32_t addr, uint32_t len, uint32_t val)
324
{
325
addr |= BIT(31);
325
- cpu_physical_memory_write(0xfec00cf8, &addr, 4);
326
- cpu_physical_memory_write(0xfee00cfc, &val, len);
326
+ physical_memory_write(0xfec00cf8, &addr, 4);
327
+ physical_memory_write(0xfee00cfc, &val, len);
328
}
329
330
static void pegasos1_chipset_reset(PegasosMachineState *pm)
331
{
332
uint8_t elcr = 0x2e;
332
- cpu_physical_memory_write(0xfe0004d1, &elcr, sizeof(elcr));
333
+ physical_memory_write(0xfe0004d1, &elcr, sizeof(elcr));
334
335
pegasos1_pci_config_write(pm, 0, PCI_COMMAND, 2, PCI_COMMAND_IO |
336
PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER);
hw/ppc/pnv.c
+3
-2
@@ -25,6 +25,7 @@
25
#include "qemu/units.h"
26
#include "qemu/cutils.h"
27
#include "qapi/error.h"
28
+#include "system/physmem.h"
29
#include "system/qtest.h"
30
#include "system/system.h"
31
#include "system/numa.h"
@@ -843,11 +844,11 @@ static void pnv_reset(MachineState *machine, ResetType type)
844
.thread_size = cpu_to_be32(sizeof(MpiplPreservedCPUState)),
845
};
846
846
- cpu_physical_memory_write(PROC_DUMP_AREA_OFF, &proc_area,
847
+ physical_memory_write(PROC_DUMP_AREA_OFF, &proc_area,
848
sizeof(proc_area));
849
}
850
850
- cpu_physical_memory_write(PNV_FDT_ADDR, fdt, fdt_totalsize(fdt));
851
+ physical_memory_write(PNV_FDT_ADDR, fdt, fdt_totalsize(fdt));
852
853
/* Free previous device tree set by pnv_init/reset/machine_init_done */
854
g_free(machine->fdt);
hw/ppc/ppc440_uc.c
+5
-4
@@ -18,6 +18,7 @@
18
#include "hw/core/qdev-properties.h"
19
#include "hw/pci/pci.h"
20
#include "exec/cpu-common.h"
21
+#include "system/physmem.h"
22
#include "system/reset.h"
23
#include "target/ppc/cpu.h"
24
#include "ppc440.h"
@@ -606,9 +607,9 @@ static void dcr_write_dma(void *opaque, int dcrn, uint32_t val)
607
width = 1 << ((val & DMA0_CR_PW) >> 25);
608
xferlen = count * width;
609
wlen = rlen = xferlen;
609
- rptr = cpu_physical_memory_map(dma->ch[chnl].sa, &rlen,
610
+ rptr = physical_memory_map(dma->ch[chnl].sa, &rlen,
611
false);
611
- wptr = cpu_physical_memory_map(dma->ch[chnl].da, &wlen,
612
+ wptr = physical_memory_map(dma->ch[chnl].da, &wlen,
613
true);
614
if (rptr && rlen == xferlen && wptr && wlen == xferlen) {
615
if (!(val & DMA0_CR_DEC) &&
@@ -631,10 +632,10 @@ static void dcr_write_dma(void *opaque, int dcrn, uint32_t val)
632
}
633
}
634
if (wptr) {
634
- cpu_physical_memory_unmap(wptr, wlen, 1, didx);
635
+ physical_memory_unmap(wptr, wlen, 1, didx);
636
}
637
if (rptr) {
637
- cpu_physical_memory_unmap(rptr, rlen, 0, sidx);
638
+ physical_memory_unmap(rptr, rlen, 0, sidx);
639
}
640
}
641
}
hw/ppc/spapr.c
+2
-1
@@ -38,6 +38,7 @@
38
#include "system/system.h"
39
#include "system/hostmem.h"
40
#include "system/numa.h"
41
+#include "system/physmem.h"
42
#include "system/tcg.h"
43
#include "system/qtest.h"
44
#include "system/reset.h"
@@ -1858,7 +1859,7 @@ static void spapr_machine_reset(MachineState *machine, ResetType type)
1859
1860
spapr_cpu_set_entry_state(first_ppc_cpu, SPAPR_ENTRY_POINT,
1861
0, fdt_addr, 0);
1861
- cpu_physical_memory_write(fdt_addr, fdt, fdt_totalsize(fdt));
1862
+ physical_memory_write(fdt_addr, fdt, fdt_totalsize(fdt));
1863
}
1864
1865
g_free(spapr->fdt_blob);
hw/ppc/spapr_drc.c
+2
-1
@@ -25,6 +25,7 @@
25
#include "hw/ppc/spapr_nvdimm.h"
26
#include "exec/cpu-common.h"
27
#include "system/device_tree.h"
28
+#include "system/physmem.h"
29
#include "system/reset.h"
30
#include "trace.h"
31
@@ -1150,7 +1151,7 @@ out:
1151
static void configure_connector_st(target_ulong addr, target_ulong offset,
1152
const void *buf, size_t len)
1153
{
1153
- cpu_physical_memory_write(ppc64_phys_to_real(addr + offset),
1154
+ physical_memory_write(ppc64_phys_to_real(addr + offset),
1155
buf, MIN(len, CC_WA_LEN - offset));
1156
}
1157
hw/ppc/spapr_events.c
+5
-4
@@ -28,6 +28,7 @@
28
#include "qemu/osdep.h"
29
#include "qapi/error.h"
30
#include "system/device_tree.h"
31
+#include "system/physmem.h"
32
#include "system/runstate.h"
33
34
#include "hw/ppc/fdt.h"
@@ -855,9 +856,9 @@ static void spapr_mce_dispatch_elog(SpaprMachineState *spapr, PowerPCCPU *cpu,
856
857
stq_be_phys(&address_space_memory, rtas_addr + RTAS_ERROR_LOG_OFFSET,
858
env->gpr[3]);
858
- cpu_physical_memory_write(rtas_addr + RTAS_ERROR_LOG_OFFSET +
859
+ physical_memory_write(rtas_addr + RTAS_ERROR_LOG_OFFSET +
860
sizeof(env->gpr[3]), &log, sizeof(log));
860
- cpu_physical_memory_write(rtas_addr + RTAS_ERROR_LOG_OFFSET +
861
+ physical_memory_write(rtas_addr + RTAS_ERROR_LOG_OFFSET +
862
sizeof(env->gpr[3]) + sizeof(log), ext_elog,
863
sizeof(*ext_elog));
864
g_free(ext_elog);
@@ -964,8 +965,8 @@ static void check_exception(PowerPCCPU *cpu, SpaprMachineState *spapr,
965
966
header.summary = cpu_to_be32(event->summary);
967
header.extended_length = cpu_to_be32(event->extended_length);
967
- cpu_physical_memory_write(buf, &header, sizeof(header));
968
- cpu_physical_memory_write(buf + sizeof(header), event->extended_log,
968
+ physical_memory_write(buf, &header, sizeof(header));
969
+ physical_memory_write(buf + sizeof(header), event->extended_log,
970
event->extended_length);
971
rtas_st(rets, 0, RTAS_OUT_SUCCESS);
972
g_free(event->extended_log);
hw/ppc/spapr_hcall.c
+9
-8
@@ -2,6 +2,7 @@
2
#include "qemu/cutils.h"
3
#include "qapi/error.h"
4
#include "system/hw_accel.h"
5
+#include "system/physmem.h"
6
#include "system/runstate.h"
7
#include "system/tcg.h"
8
#include "qemu/log.h"
@@ -273,7 +274,7 @@ static target_ulong h_page_init(PowerPCCPU *cpu, SpaprMachineState *spapr,
274
if (!is_ram_address(spapr, dst) || (dst & ~TARGET_PAGE_MASK) != 0) {
275
return H_PARAMETER;
276
}
276
- pdst = cpu_physical_memory_map(dst, &len, true);
277
+ pdst = physical_memory_map(dst, &len, true);
278
if (!pdst || len != TARGET_PAGE_SIZE) {
279
return H_PARAMETER;
280
}
@@ -284,13 +285,13 @@ static target_ulong h_page_init(PowerPCCPU *cpu, SpaprMachineState *spapr,
285
ret = H_PARAMETER;
286
goto unmap_out;
287
}
287
- psrc = cpu_physical_memory_map(src, &len, false);
288
+ psrc = physical_memory_map(src, &len, false);
289
if (!psrc || len != TARGET_PAGE_SIZE) {
290
ret = H_PARAMETER;
291
goto unmap_out;
292
}
293
memcpy(pdst, psrc, len);
293
- cpu_physical_memory_unmap(psrc, len, 0, len);
294
+ physical_memory_unmap(psrc, len, 0, len);
295
} else if (flags & H_ZERO_PAGE) {
296
memset(pdst, 0, len); /* Just clear the destination page */
297
}
@@ -309,7 +310,7 @@ static target_ulong h_page_init(PowerPCCPU *cpu, SpaprMachineState *spapr,
310
}
311
312
unmap_out:
312
- cpu_physical_memory_unmap(pdst, TARGET_PAGE_SIZE, 1, len);
313
+ physical_memory_unmap(pdst, TARGET_PAGE_SIZE, 1, len);
314
return ret;
315
}
316
@@ -1382,8 +1383,8 @@ static target_ulong h_client_architecture_support(PowerPCCPU *cpu,
1383
spapr->fdt_size = fdt_totalsize(spapr->fdt_blob);
1384
spapr->fdt_initial_size = spapr->fdt_size;
1385
1385
- cpu_physical_memory_write(fdt_buf, &hdr, sizeof(hdr));
1386
- cpu_physical_memory_write(fdt_buf + sizeof(hdr), spapr->fdt_blob,
1386
+ physical_memory_write(fdt_buf, &hdr, sizeof(hdr));
1387
+ physical_memory_write(fdt_buf + sizeof(hdr), spapr->fdt_blob,
1388
spapr->fdt_size);
1389
trace_spapr_cas_continue(spapr->fdt_size + sizeof(hdr));
1390
}
@@ -1487,7 +1488,7 @@ static target_ulong h_update_dt(PowerPCCPU *cpu, SpaprMachineState *spapr,
1488
unsigned cb;
1489
void *fdt;
1490
1490
- cpu_physical_memory_read(dt, &hdr, sizeof(hdr));
1491
+ physical_memory_read(dt, &hdr, sizeof(hdr));
1492
cb = fdt32_to_cpu(hdr.totalsize);
1493
1494
/* Check that the fdt did not grow out of proportion */
@@ -1498,7 +1499,7 @@ static target_ulong h_update_dt(PowerPCCPU *cpu, SpaprMachineState *spapr,
1499
}
1500
1501
fdt = g_malloc0(cb);
1501
- cpu_physical_memory_read(dt, fdt, cb);
1502
+ physical_memory_read(dt, fdt, cb);
1503
1504
/* Check the fdt consistency */
1505
if (fdt_check_full(fdt, cb)) {
hw/ppc/spapr_rtas.c
+3
-2
@@ -32,6 +32,7 @@
32
#include "system/device_tree.h"
33
#include "system/cpus.h"
34
#include "system/hw_accel.h"
35
+#include "system/physmem.h"
36
#include "system/runstate.h"
37
#include "system/qtest.h"
38
#include "kvm_ppc.h"
@@ -279,7 +280,7 @@ static inline int sysparm_st(target_ulong addr, target_ulong len,
280
return RTAS_OUT_SYSPARM_PARAM_ERROR;
281
}
282
stw_be_phys(&address_space_memory, phys, vallen);
282
- cpu_physical_memory_write(phys + 2, val, MIN(len - 2, vallen));
283
+ physical_memory_write(phys + 2, val, MIN(len - 2, vallen));
284
return RTAS_OUT_SUCCESS;
285
}
286
@@ -441,7 +442,7 @@ static void rtas_ibm_os_term(PowerPCCPU *cpu,
442
return trigger_fadump_boot(spapr, rets);
443
}
444
444
- cpu_physical_memory_read(msgaddr, msg, sizeof(msg) - 1);
445
+ physical_memory_read(msgaddr, msg, sizeof(msg) - 1);
446
msg[sizeof(msg) - 1] = 0;
447
448
error_report("OS terminated: %s", msg);
hw/ppc/spapr_tpm_proxy.c
+3
-2
@@ -13,6 +13,7 @@
13
#include "qemu/osdep.h"
14
#include "qapi/error.h"
15
#include "qemu/error-report.h"
16
+#include "system/physmem.h"
17
#include "system/reset.h"
18
#include "hw/ppc/spapr.h"
19
#include "hw/core/qdev-properties.h"
@@ -69,7 +70,7 @@ static ssize_t tpm_execute(SpaprTpmProxy *tpm_proxy, target_ulong *args)
70
}
71
}
72
72
- cpu_physical_memory_read(data_in, buf_in, data_in_size);
73
+ physical_memory_read(data_in, buf_in, data_in_size);
74
75
do {
76
ret = write(tpm_proxy->host_fd, buf_in, data_in_size);
@@ -94,7 +95,7 @@ static ssize_t tpm_execute(SpaprTpmProxy *tpm_proxy, target_ulong *args)
95
return H_RESOURCE;
96
}
97
97
- cpu_physical_memory_write(data_out, buf_out, ret);
98
+ physical_memory_write(data_out, buf_out, ret);
99
args[0] = ret;
100
101
return H_SUCCESS;
hw/ppc/virtex_ml507.c
+2
-1
@@ -30,6 +30,7 @@
30
#include "hw/core/sysbus.h"
31
#include "hw/char/serial-mm.h"
32
#include "hw/block/flash.h"
33
+#include "system/physmem.h"
34
#include "system/system.h"
35
#include "system/reset.h"
36
#include "hw/core/boards.h"
@@ -174,7 +175,7 @@ static int xilinx_load_device_tree(MachineState *machine,
175
machine->kernel_cmdline);
176
if (r < 0)
177
fprintf(stderr, "couldn't set /chosen/bootargs\n");
177
- cpu_physical_memory_write(addr, fdt, fdt_size);
178
+ physical_memory_write(addr, fdt, fdt_size);
179
180
/* Set machine->fdt for 'dumpdtb' QMP/HMP command */
181
machine->fdt = fdt;
hw/s390x/css.c
+3
-2
@@ -15,6 +15,7 @@
15
#include "qemu/bitops.h"
16
#include "qemu/error-report.h"
17
#include "system/address-spaces.h"
18
+#include "system/physmem.h"
19
#include "hw/s390x/ioinst.h"
20
#include "hw/core/qdev-properties.h"
21
#include "hw/s390x/css.h"
@@ -755,13 +756,13 @@ static CCW1 copy_ccw_from_guest(hwaddr addr, bool fmt1)
756
CCW1 ret;
757
758
if (fmt1) {
758
- cpu_physical_memory_read(addr, &tmp1, sizeof(tmp1));
759
+ physical_memory_read(addr, &tmp1, sizeof(tmp1));
760
ret.cmd_code = tmp1.cmd_code;
761
ret.flags = tmp1.flags;
762
ret.count = be16_to_cpu(tmp1.count);
763
ret.cda = be32_to_cpu(tmp1.cda);
764
} else {
764
- cpu_physical_memory_read(addr, &tmp0, sizeof(tmp0));
765
+ physical_memory_read(addr, &tmp0, sizeof(tmp0));
766
if ((tmp0.cmd_code & 0x0f) == CCW_CMD_TIC) {
767
ret.cmd_code = CCW_CMD_TIC;
768
ret.flags = 0;
hw/s390x/ipl.c
+5
-4
@@ -15,6 +15,7 @@
15
#include "qemu/osdep.h"
16
#include "qemu/datadir.h"
17
#include "qapi/error.h"
18
+#include "system/physmem.h"
19
#include "system/reset.h"
20
#include "system/runstate.h"
21
#include "system/tcg.h"
@@ -431,7 +432,7 @@ static uint64_t s390_ipl_map_iplb_chain(IplParameterBlock *iplb_chain)
432
uint64_t len = sizeof(IplParameterBlock) * count;
433
uint64_t chain_addr = find_iplb_chain_addr(ipl->bios_start_addr, count);
434
434
- cpu_physical_memory_write(chain_addr, iplb_chain, len);
435
+ physical_memory_write(chain_addr, iplb_chain, len);
436
return chain_addr;
437
}
438
@@ -722,13 +723,13 @@ static void s390_ipl_prepare_qipl(S390CPU *cpu)
723
uint8_t *addr;
724
uint64_t len = 4096;
725
725
- addr = cpu_physical_memory_map(cpu->env.psa, &len, true);
726
+ addr = physical_memory_map(cpu->env.psa, &len, true);
727
if (!addr || len < QIPL_ADDRESS + sizeof(QemuIplParameters)) {
728
error_report("Cannot set QEMU IPL parameters");
729
return;
730
}
731
memcpy(addr + QIPL_ADDRESS, &ipl->qipl, sizeof(QemuIplParameters));
731
- cpu_physical_memory_unmap(addr, len, 1, len);
732
+ physical_memory_unmap(addr, len, 1, len);
733
}
734
735
int s390_ipl_prepare_pv_header(struct S390PVResponse *pv_resp, Error **errp)
@@ -738,7 +739,7 @@ int s390_ipl_prepare_pv_header(struct S390PVResponse *pv_resp, Error **errp)
739
void *hdr = g_malloc(ipib_pv->pv_header_len);
740
int rc;
741
741
- cpu_physical_memory_read(ipib_pv->pv_header_addr, hdr,
742
+ physical_memory_read(ipib_pv->pv_header_addr, hdr,
743
ipib_pv->pv_header_len);
744
rc = s390_pv_set_sec_parms((uintptr_t)hdr, ipib_pv->pv_header_len,
745
pv_resp, errp);
hw/s390x/s390-pci-bus.c
+3
-2
@@ -28,6 +28,7 @@
28
#include "exec/cpu-common.h"
29
#include "qemu/error-report.h"
30
#include "qemu/module.h"
31
+#include "system/physmem.h"
32
#include "system/reset.h"
33
#include "system/runstate.h"
34
@@ -668,7 +669,7 @@ static bool set_ind_bit_atomic(uint64_t ind_loc, uint8_t to_be_set)
669
/* avoid multiple fetches */
670
uint8_t volatile *ind_addr;
671
671
- ind_addr = cpu_physical_memory_map(ind_loc, &len, true);
672
+ ind_addr = physical_memory_map(ind_loc, &len, true);
673
if (!ind_addr) {
674
s390_pci_generate_error_event(ERR_EVENT_AIRERR, 0, 0, 0, 0);
675
return false;
@@ -678,7 +679,7 @@ static bool set_ind_bit_atomic(uint64_t ind_loc, uint8_t to_be_set)
679
expected = actual;
680
actual = qatomic_cmpxchg(ind_addr, expected, expected | to_be_set);
681
} while (actual != expected);
681
- cpu_physical_memory_unmap((void *)ind_addr, len, 1, len);
682
+ physical_memory_unmap((void *)ind_addr, len, 1, len);
683
684
return (actual & to_be_set) ? false : true;
685
}
hw/s390x/virtio-ccw.c
+3
-2
@@ -14,6 +14,7 @@
14
#include "qapi/error.h"
15
#include "system/address-spaces.h"
16
#include "system/kvm.h"
17
+#include "system/physmem.h"
18
#include "net/net.h"
19
#include "hw/virtio/virtio.h"
20
#include "migration/qemu-file-types.h"
@@ -834,7 +835,7 @@ static uint8_t virtio_set_ind_atomic(SubchDev *sch, uint64_t ind_loc,
835
/* avoid multiple fetches */
836
uint8_t volatile *ind_addr;
837
837
- ind_addr = cpu_physical_memory_map(ind_loc, &len, true);
838
+ ind_addr = physical_memory_map(ind_loc, &len, true);
839
if (!ind_addr) {
840
error_report("%s(%x.%x.%04x): unable to access indicator",
841
__func__, sch->cssid, sch->ssid, sch->schid);
@@ -846,7 +847,7 @@ static uint8_t virtio_set_ind_atomic(SubchDev *sch, uint64_t ind_loc,
847
actual = qatomic_cmpxchg(ind_addr, expected, expected | to_be_set);
848
} while (actual != expected);
849
trace_virtio_ccw_set_ind(ind_loc, actual, actual | to_be_set);
849
- cpu_physical_memory_unmap((void *)ind_addr, len, 1, len);
850
+ physical_memory_unmap((void *)ind_addr, len, 1, len);
851
852
return actual;
853
}
hw/scsi/vmw_pvscsi.c
+6
-6
@@ -34,7 +34,7 @@
34
#include "scsi/constants.h"
35
#include "hw/pci/msi.h"
36
#include "hw/core/qdev-properties.h"
37
-#include "exec/cpu-common.h"
37
+#include "system/physmem.h"
38
#include "vmw_pvscsi.h"
39
#include "trace.h"
40
#include "qom/object.h"
@@ -395,7 +395,7 @@ pvscsi_cmp_ring_put(PVSCSIState *s, struct PVSCSIRingCmpDesc *cmp_desc)
395
396
cmp_descr_pa = pvscsi_ring_pop_cmp_descr(&s->rings);
397
trace_pvscsi_cmp_ring_put(cmp_descr_pa);
398
- cpu_physical_memory_write(cmp_descr_pa, cmp_desc, sizeof(*cmp_desc));
398
+ physical_memory_write(cmp_descr_pa, cmp_desc, sizeof(*cmp_desc));
399
}
400
401
static void
@@ -405,7 +405,7 @@ pvscsi_msg_ring_put(PVSCSIState *s, struct PVSCSIRingMsgDesc *msg_desc)
405
406
msg_descr_pa = pvscsi_ring_pop_msg_descr(&s->rings);
407
trace_pvscsi_msg_ring_put(msg_descr_pa);
408
- cpu_physical_memory_write(msg_descr_pa, msg_desc, sizeof(*msg_desc));
408
+ physical_memory_write(msg_descr_pa, msg_desc, sizeof(*msg_desc));
409
}
410
411
static void
@@ -480,7 +480,7 @@ pvscsi_get_next_sg_elem(PVSCSISGState *sg)
480
{
481
struct PVSCSISGElement elem;
482
483
- cpu_physical_memory_read(sg->elemAddr, &elem, sizeof(elem));
483
+ physical_memory_read(sg->elemAddr, &elem, sizeof(elem));
484
if ((elem.flags & ~PVSCSI_KNOWN_FLAGS) != 0) {
485
/*
486
* There is PVSCSI_SGE_FLAG_CHAIN_ELEMENT flag described in
@@ -501,7 +501,7 @@ pvscsi_write_sense(PVSCSIRequest *r, uint8_t *sense, int len)
501
{
502
r->cmp.senseLen = MIN(r->req.senseLen, len);
503
r->sense_key = sense[(sense[0] & 2) ? 1 : 2];
504
- cpu_physical_memory_write(r->req.senseAddr, sense, r->cmp.senseLen);
504
+ physical_memory_write(r->req.senseAddr, sense, r->cmp.senseLen);
505
}
506
507
static void
@@ -758,7 +758,7 @@ pvscsi_process_io(PVSCSIState *s)
758
smp_rmb();
759
760
trace_pvscsi_process_io(next_descr_pa);
761
- cpu_physical_memory_read(next_descr_pa, &descr, sizeof(descr));
761
+ physical_memory_read(next_descr_pa, &descr, sizeof(descr));
762
pvscsi_process_request_descriptor(s, &descr);
763
}
764
hw/xen/xen_pt_graphics.c
+2
-2
@@ -5,8 +5,8 @@
5
#include "qapi/error.h"
6
#include "hw/xen/xen_pt.h"
7
#include "hw/xen/xen_igd.h"
8
-#include "exec/cpu-common.h"
8
#include "xen-host-pci-device.h"
9
+#include "system/physmem.h"
10
11
static unsigned long igd_guest_opregion;
12
static unsigned long igd_host_opregion;
@@ -223,7 +223,7 @@ void xen_pt_setup_vga(XenPCIPassthroughState *s, XenHostPCIDevice *dev,
223
}
224
225
/* Currently we fixed this address as a primary for legacy BIOS. */
226
- cpu_physical_memory_write(0xc0000, bios, bios_size);
226
+ physical_memory_write(0xc0000, bios, bios_size);
227
}
228
229
uint32_t igd_read_opregion(XenPCIPassthroughState *s)
hw/xtensa/bootparam.h
+3
-3
@@ -1,8 +1,8 @@
1
#ifndef HW_XTENSA_BOOTPARAM_H
2
#define HW_XTENSA_BOOTPARAM_H
3
4
-#include "exec/cpu-common.h"
4
#include "exec/tswap.h"
5
+#include "system/physmem.h"
6
7
#define BP_TAG_COMMAND_LINE 0x1001 /* command line (0-terminated string)*/
8
#define BP_TAG_INITRD 0x1002 /* ramdisk addr and size (bp_meminfo) */
@@ -41,9 +41,9 @@ static inline ram_addr_t put_tag(ram_addr_t addr, uint16_t tag,
41
.size = tswap16((size + 3) & ~3),
42
};
43
44
- cpu_physical_memory_write(addr, &bp_tag, sizeof(bp_tag));
44
+ physical_memory_write(addr, &bp_tag, sizeof(bp_tag));
45
addr += sizeof(bp_tag);
46
- cpu_physical_memory_write(addr, data, size);
46
+ physical_memory_write(addr, data, size);
47
addr += (size + 3) & ~3;
48
49
return addr;
hw/xtensa/xtfpga.c
+3
-2
@@ -35,6 +35,7 @@
35
#include "hw/core/qdev-properties.h"
36
#include "elf.h"
37
#include "system/memory.h"
38
+#include "system/physmem.h"
39
#include "exec/tswap.h"
40
#include "hw/char/serial-mm.h"
41
#include "net/net.h"
@@ -370,7 +371,7 @@ static void xtfpga_init(const XtfpgaBoardDesc *board, MachineState *machine)
371
exit(EXIT_FAILURE);
372
}
373
373
- cpu_physical_memory_write(cur_lowmem, fdt, fdt_size);
374
+ physical_memory_write(cur_lowmem, fdt, fdt_size);
375
cur_tagptr = put_tag(cur_tagptr, BP_TAG_FDT,
376
sizeof(dtb_addr), &dtb_addr);
377
cur_lowmem = QEMU_ALIGN_UP(cur_lowmem + fdt_size, 4 * KiB);
@@ -449,7 +450,7 @@ static void xtfpga_init(const XtfpgaBoardDesc *board, MachineState *machine)
450
451
memcpy(boot + 4, &entry_pc, sizeof(entry_pc));
452
memcpy(boot + 8, &entry_a2, sizeof(entry_a2));
452
- cpu_physical_memory_write(env->pc, boot, boot_sz);
453
+ physical_memory_write(env->pc, boot, boot_sz);
454
}
455
} else {
456
if (flash) {
include/exec/cpu-common.h
-50
@@ -9,7 +9,6 @@
9
#define CPU_COMMON_H
10
11
#include "exec/vaddr.h"
12
-#include "exec/hwaddr.h"
12
#include "hw/core/cpu.h"
13
#include "tcg/debug-assert.h"
14
#include "exec/page-protection.h"
@@ -64,55 +63,6 @@ void cpu_address_space_init(CPUState *cpu, int asidx,
63
*/
64
void cpu_destroy_address_spaces(CPUState *cpu);
65
67
-/**
68
- * cpu_physical_memory_read: Read from the legacy global address space.
69
- *
70
- * This function access the legacy global #address_space_memory address
71
- * space and does not say whether the operation succeeded or failed.
72
- *
73
- * @addr: address within the legacy global address space
74
- * @buf: buffer with the data transferred
75
- * @len: length of the data transferred
76
- */
77
-void cpu_physical_memory_read(hwaddr addr, void *buf, hwaddr len);
78
-/**
79
- * cpu_physical_memory_write: Write to the legacy global address space.
80
- *
81
- * This function access the legacy global #address_space_memory address
82
- * space and does not say whether the operation succeeded or failed.
83
- *
84
- * @addr: address within the legacy global address space
85
- * @buf: buffer with the data transferred
86
- * @len: the number of bytes to write
87
- */
88
-void cpu_physical_memory_write(hwaddr addr, const void *buf, hwaddr len);
89
-/**
90
- * cpu_physical_memory_map: Map guest physical memory region into host virtual
91
- * address.
92
- *
93
- * Map a memory region from the legacy global #address_space_memory address
94
- * space. May return %NULL and set *@plen to zero(0), if resources needed to
95
- * perform the mapping are exhausted.
96
- *
97
- * @addr: address within that address space
98
- * @len: pointer to length of buffer; updated on return
99
- * @is_write: whether the translation operation is for write
100
- */
101
-void *cpu_physical_memory_map(hwaddr addr,
102
- hwaddr *plen,
103
- bool is_write);
104
-/**
105
- * cpu_physical_memory_unmap: Unmaps a memory region previously mapped by
106
- * cpu_physical_memory_map()
107
- *
108
- * @buffer: host pointer as returned by cpu_physical_memory_map()
109
- * @len: buffer length as returned by cpu_physical_memory_map()
110
- * @is_write: whether the translation operation is for write
111
- * @access_len: amount of data actually transferred
112
- */
113
-void cpu_physical_memory_unmap(void *buffer, hwaddr len,
114
- bool is_write, hwaddr access_len);
115
-
66
/* vl.c */
67
void list_cpus(void);
68
include/system/physmem.h
+50
@@ -11,6 +11,56 @@
11
#include "exec/hwaddr.h"
12
#include "system/ramlist.h"
13
14
+/**
15
+ * physical_memory_map: Map guest physical memory region into host virtual
16
+ * address.
17
+ *
18
+ * Map a memory region from the legacy global #address_space_memory address
19
+ * space. May return %NULL and set *@plen to zero(0), if resources needed to
20
+ * perform the mapping are exhausted.
21
+ *
22
+ * @addr: address within that address space
23
+ * @len: pointer to length of buffer; updated on return
24
+ * @is_write: whether the translation operation is for write
25
+ */
26
+void *physical_memory_map(hwaddr addr, hwaddr *plen, bool is_write);
27
+
28
+/**
29
+ * physical_memory_unmap: Unmaps a memory region previously mapped by
30
+ * physical_memory_map()
31
+ *
32
+ * @buffer: host pointer as returned by physical_memory_map()
33
+ * @len: buffer length as returned by physical_memory_map()
34
+ * @is_write: whether the translation operation is for write
35
+ * @access_len: amount of data actually transferred
36
+ */
37
+void physical_memory_unmap(void *buffer, hwaddr len,
38
+ bool is_write, hwaddr access_len);
39
+
40
+/**
41
+ * physical_memory_read: Read from the legacy global address space.
42
+ *
43
+ * This function access the legacy global #address_space_memory address
44
+ * space and does not say whether the operation succeeded or failed.
45
+ *
46
+ * @addr: address within the legacy global address space
47
+ * @buf: buffer with the data transferred
48
+ * @len: length of the data transferred
49
+ */
50
+void physical_memory_read(hwaddr addr, void *buf, hwaddr len);
51
+
52
+/**
53
+ * physical_memory_write: Write to the legacy global address space.
54
+ *
55
+ * This function access the legacy global #address_space_memory address
56
+ * space and does not say whether the operation succeeded or failed.
57
+ *
58
+ * @addr: address within the legacy global address space
59
+ * @buf: buffer with the data transferred
60
+ * @len: the number of bytes to write
61
+ */
62
+void physical_memory_write(hwaddr addr, const void *buf, hwaddr len);
63
+
64
#define DIRTY_CLIENTS_ALL ((1 << DIRTY_MEMORY_NUM) - 1)
65
#define DIRTY_CLIENTS_NOCODE (DIRTY_CLIENTS_ALL & ~(1 << DIRTY_MEMORY_CODE))
66
scripts/coccinelle/exec_rw_const.cocci
+8
-8
@@ -21,11 +21,11 @@ expression E1, E2, E3, E4, E5;
21
+ address_space_rw(E1, E2, E3, E4, E5, true)
22
|
23
24
-- cpu_physical_memory_map(E1, E2, 0)
25
-+ cpu_physical_memory_map(E1, E2, false)
24
+- physical_memory_map(E1, E2, 0)
25
++ physical_memory_map(E1, E2, false)
26
|
27
-- cpu_physical_memory_map(E1, E2, 1)
28
-+ cpu_physical_memory_map(E1, E2, true)
27
+- physical_memory_map(E1, E2, 1)
28
++ physical_memory_map(E1, E2, true)
29
)
30
31
// Use address_space_write instead of casting to non-const
@@ -74,11 +74,11 @@ type T;
74
+ address_space_write_rom(E1, E2, E3, E4, E5)
75
|
76
77
-- cpu_physical_memory_read(E1, (T *)(E2), E3)
78
-+ cpu_physical_memory_read(E1, E2, E3)
77
+- physical_memory_read(E1, (T *)(E2), E3)
78
++ physical_memory_read(E1, E2, E3)
79
|
80
-- cpu_physical_memory_write(E1, (T *)(E2), E3)
81
-+ cpu_physical_memory_write(E1, E2, E3)
80
+- physical_memory_write(E1, (T *)(E2), E3)
81
++ physical_memory_write(E1, E2, E3)
82
|
83
84
- dma_memory_read(E1, E2, (T *)(E3), E4)
system/cpus.c
+2
-1
@@ -40,6 +40,7 @@
40
#include "system/cpus.h"
41
#include "qemu/guest-random.h"
42
#include "hw/core/nmi.h"
43
+#include "system/physmem.h"
44
#include "system/replay.h"
45
#include "system/runstate.h"
46
#include "system/cpu-timers.h"
@@ -898,7 +899,7 @@ void qmp_pmemsave(uint64_t addr, uint64_t size, const char *filename,
899
l = sizeof(buf);
900
if (l > size)
901
l = size;
901
- cpu_physical_memory_read(addr, buf, l);
902
+ physical_memory_read(addr, buf, l);
903
if (fwrite(buf, 1, l, f) != l) {
904
error_setg(errp, "writing memory to '%s' failed",
905
filename);
system/physmem.c
+5
-7
@@ -3477,13 +3477,13 @@ MemTxResult address_space_set(const AddressSpace *as, hwaddr addr,
3477
return error;
3478
}
3479
3480
-void cpu_physical_memory_read(hwaddr addr, void *buf, hwaddr len)
3480
+void physical_memory_read(hwaddr addr, void *buf, hwaddr len)
3481
{
3482
address_space_read(&address_space_memory, addr,
3483
MEMTXATTRS_UNSPECIFIED, buf, len);
3484
}
3485
3486
-void cpu_physical_memory_write(hwaddr addr, const void *buf, hwaddr len)
3486
+void physical_memory_write(hwaddr addr, const void *buf, hwaddr len)
3487
{
3488
address_space_write(&address_space_memory, addr,
3489
MEMTXATTRS_UNSPECIFIED, buf, len);
@@ -3808,16 +3808,14 @@ void address_space_unmap(AddressSpace *as, void *buffer, hwaddr len,
3808
address_space_notify_map_clients(as);
3809
}
3810
3811
-void *cpu_physical_memory_map(hwaddr addr,
3812
- hwaddr *plen,
3813
- bool is_write)
3811
+void *physical_memory_map(hwaddr addr, hwaddr *plen, bool is_write)
3812
{
3813
return address_space_map(&address_space_memory, addr, plen, is_write,
3814
MEMTXATTRS_UNSPECIFIED);
3815
}
3816
3819
-void cpu_physical_memory_unmap(void *buffer, hwaddr len,
3820
- bool is_write, hwaddr access_len)
3817
+void physical_memory_unmap(void *buffer, hwaddr len,
3818
+ bool is_write, hwaddr access_len)
3819
{
3820
return address_space_unmap(&address_space_memory, buffer, len, is_write, access_len);
3821
}