mirror of
https://github.com/utmapp/qemu.git
synced 2026-12-06 11:02:25 -10:00
Compare commits
141
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
83a9cdbd65 | ||
|
|
7cb0210fcc | ||
|
|
979cdfbbfd | ||
|
|
b96bb74e3a | ||
|
|
bfe876cb30 | ||
|
|
1d711f97a5 | ||
|
|
f43e4e2594 | ||
|
|
ade1bed2b7 | ||
|
|
e85ab8f753 | ||
|
|
48be003029 | ||
|
|
dab9a65dfa | ||
|
|
e0711f74b2 | ||
|
|
4f558fd185 | ||
|
|
b3c94ecf3c | ||
|
|
bc5740e178 | ||
|
|
715e8123ed | ||
|
|
868b90e44a | ||
|
|
60c42b8623 | ||
|
|
49f1e02bac | ||
|
|
fd902c54e5 | ||
|
|
18963f458f | ||
|
|
71e05c42cc | ||
|
|
3d81ba8da4 | ||
|
|
adef4fe350 | ||
|
|
f8592e9431 | ||
|
|
5300472ec0 | ||
|
|
ca93a302a0 | ||
|
|
157529eee6 | ||
|
|
5a87bcee89 | ||
|
|
f8e673df7e | ||
|
|
357b42486c | ||
|
|
b2ec463649 | ||
|
|
2eee26f579 | ||
|
|
2bff614256 | ||
|
|
220869aae1 | ||
|
|
123b4291f9 | ||
|
|
8eed78e2bf | ||
|
|
5f3fe5657d | ||
|
|
0827053612 | ||
|
|
c8b714f047 | ||
|
|
c5498fdda0 | ||
|
|
76507abbe1 | ||
|
|
e5e8a86064 | ||
|
|
6bd56e0f82 | ||
|
|
bdbf5e1016 | ||
|
|
6f7c39a912 | ||
|
|
59a728a031 | ||
|
|
5a61789df8 | ||
|
|
bdfecfbc1d | ||
|
|
feb0814b3b | ||
|
|
f90a8b9357 | ||
|
|
c4a4731408 | ||
|
|
0102c92a1c | ||
|
|
5de88d6e10 | ||
|
|
0167759c9a | ||
|
|
35720b3d90 | ||
|
|
d1063b6551 | ||
|
|
fa72d8bcf4 | ||
|
|
7b336dcd06 | ||
|
|
c280ac3b60 | ||
|
|
520d5fb4cb | ||
|
|
b2b1b99da9 | ||
|
|
523f529d40 | ||
|
|
eefa524832 | ||
|
|
aa308958e6 | ||
|
|
70ba7cbf50 | ||
|
|
f48e3ec581 | ||
|
|
43462f7706 | ||
|
|
741df485e8 | ||
|
|
73d6ac24c8 | ||
|
|
720db12b8b | ||
|
|
bcb1e0522e | ||
|
|
a342ce9dfe | ||
|
|
fb64b62378 | ||
|
|
d2402a83a7 | ||
|
|
78e8c9c1a1 | ||
|
|
477ab906d1 | ||
|
|
df1e45c9df | ||
|
|
383fb8c05c | ||
|
|
58b3e4ff5f | ||
|
|
55ee115e7a | ||
|
|
ce6331222d | ||
|
|
246b0cf1ac | ||
|
|
5e8838524a | ||
|
|
a76c5126ec | ||
|
|
8c792a532e | ||
|
|
dc4c852d4d | ||
|
|
aab37b2002 | ||
|
|
d33534a4c7 | ||
|
|
46fe2deaef | ||
|
|
c10525874c | ||
|
|
b62e5d8ac1 | ||
|
|
06f32b3dcf | ||
|
|
29c753001b | ||
|
|
8fa1462292 | ||
|
|
deb40cf67a | ||
|
|
cf7950282d | ||
|
|
72a23f2991 | ||
|
|
b9e1415e16 | ||
|
|
4553eee156 | ||
|
|
22d71f9eb3 | ||
|
|
f38ca28c66 | ||
|
|
2bdaf89162 | ||
|
|
fb8b14025b | ||
|
|
4a83e27b21 | ||
|
|
e7d265340e | ||
|
|
1de8291e29 | ||
|
|
3c6346625b | ||
|
|
d09e35feb5 | ||
|
|
967e42986f | ||
|
|
b9d2887be4 | ||
|
|
828af6b31f | ||
|
|
fe88635449 | ||
|
|
6a69a58b1c | ||
|
|
1797de7f82 | ||
|
|
903c71251b | ||
|
|
454d4e4380 | ||
|
|
5cd229064a | ||
|
|
1b4417178e | ||
|
|
373cc0f3b5 | ||
|
|
9b7c1e431e | ||
|
|
0a3a9ae1f2 | ||
|
|
0d4bced374 | ||
|
|
8776c6cf6a | ||
|
|
76d4eb3a5e | ||
|
|
6a9f9e6499 | ||
|
|
f81a5d6863 | ||
|
|
505f0c68c9 | ||
|
|
cdda1ce158 | ||
|
|
bc8e883065 | ||
|
|
e0968d21e2 | ||
|
|
772a83c6db | ||
|
|
9e36edcf03 | ||
|
|
e0baf24b4a | ||
|
|
eef92fac91 | ||
|
|
7fd387715b | ||
|
|
76b7002ec7 | ||
|
|
880f7d12be | ||
|
|
864ce70c1c | ||
|
|
25b846c85e | ||
|
|
eca6ebee52 |
No files matched your search
@@ -102,8 +102,8 @@ crash-test-debian:
|
||||
IMAGE: debian-amd64
|
||||
script:
|
||||
- cd build
|
||||
- make check-venv
|
||||
- tests/venv/bin/python3 scripts/device-crash-test -q ./qemu-system-i386
|
||||
- make NINJA=":" check-venv
|
||||
- tests/venv/bin/python3 scripts/device-crash-test -q --tcg-only ./qemu-system-i386
|
||||
|
||||
build-system-fedora:
|
||||
extends:
|
||||
@@ -145,7 +145,7 @@ crash-test-fedora:
|
||||
IMAGE: fedora
|
||||
script:
|
||||
- cd build
|
||||
- make check-venv
|
||||
- make NINJA=":" check-venv
|
||||
- tests/venv/bin/python3 scripts/device-crash-test -q ./qemu-system-ppc
|
||||
- tests/venv/bin/python3 scripts/device-crash-test -q ./qemu-system-riscv32
|
||||
|
||||
|
||||
@@ -55,9 +55,6 @@
|
||||
[submodule "roms/vbootrom"]
|
||||
path = roms/vbootrom
|
||||
url = https://gitlab.com/qemu-project/vbootrom.git
|
||||
[submodule "libucontext"]
|
||||
path = subprojects/libucontext
|
||||
url = https://github.com/utmapp/libucontext.git
|
||||
[submodule "tests/lcitool/libvirt-ci"]
|
||||
path = tests/lcitool/libvirt-ci
|
||||
url = https://gitlab.com/libvirt/libvirt-ci.git
|
||||
|
||||
+13
-38
@@ -57,10 +57,13 @@
|
||||
#include "sysemu/hvf_int.h"
|
||||
#include "sysemu/runstate.h"
|
||||
#include "qemu/guest-random.h"
|
||||
#include "hw/boards.h"
|
||||
|
||||
HVFState *hvf_state;
|
||||
|
||||
#ifdef __aarch64__
|
||||
#define HV_VM_DEFAULT NULL
|
||||
#endif
|
||||
|
||||
/* Memory slots */
|
||||
|
||||
hvf_slot *hvf_find_overlap_slot(uint64_t start, uint64_t size)
|
||||
@@ -316,44 +319,25 @@ bool hvf_allowed;
|
||||
|
||||
static int hvf_accel_init(MachineState *ms)
|
||||
{
|
||||
int x;
|
||||
hv_return_t ret;
|
||||
HVFState *s = HVF_STATE(ms->accelerator);
|
||||
HVFState *s;
|
||||
|
||||
ret = hvf_arch_vm_create(s);
|
||||
ret = hv_vm_create(HV_VM_DEFAULT);
|
||||
assert_hvf_ok(ret);
|
||||
|
||||
hvf_state = s;
|
||||
memory_listener_register(&hvf_memory_listener, &address_space_memory);
|
||||
|
||||
return hvf_arch_init();
|
||||
}
|
||||
|
||||
#if defined(CONFIG_HVF_PRIVATE) && defined(__aarch64__)
|
||||
|
||||
static bool hvf_get_tso(Object *obj, Error **errp)
|
||||
{
|
||||
HVFState *s = HVF_STATE(obj);
|
||||
return s->tso_mode;
|
||||
}
|
||||
|
||||
static void hvf_set_tso(Object *obj, bool value, Error **errp)
|
||||
{
|
||||
HVFState *s = HVF_STATE(obj);
|
||||
s->tso_mode = value;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static void hvf_accel_instance_init(Object *obj)
|
||||
{
|
||||
int x;
|
||||
HVFState *s = HVF_STATE(obj);
|
||||
s = g_new0(HVFState, 1);
|
||||
|
||||
s->num_slots = ARRAY_SIZE(s->slots);
|
||||
for (x = 0; x < s->num_slots; ++x) {
|
||||
s->slots[x].size = 0;
|
||||
s->slots[x].slot_id = x;
|
||||
}
|
||||
|
||||
hvf_state = s;
|
||||
memory_listener_register(&hvf_memory_listener, &address_space_memory);
|
||||
|
||||
return hvf_arch_init();
|
||||
}
|
||||
|
||||
static void hvf_accel_class_init(ObjectClass *oc, void *data)
|
||||
@@ -362,21 +346,12 @@ static void hvf_accel_class_init(ObjectClass *oc, void *data)
|
||||
ac->name = "HVF";
|
||||
ac->init_machine = hvf_accel_init;
|
||||
ac->allowed = &hvf_allowed;
|
||||
|
||||
#if defined(CONFIG_HVF_PRIVATE) && defined(__aarch64__)
|
||||
object_class_property_add_bool(oc, "tso",
|
||||
hvf_get_tso, hvf_set_tso);
|
||||
object_class_property_set_description(oc, "tso",
|
||||
"Set on/off to enable/disable total store ordering mode");
|
||||
#endif
|
||||
}
|
||||
|
||||
static const TypeInfo hvf_accel_type = {
|
||||
.name = TYPE_HVF_ACCEL,
|
||||
.parent = TYPE_ACCEL,
|
||||
.instance_init = hvf_accel_instance_init,
|
||||
.class_init = hvf_accel_class_init,
|
||||
.instance_size = sizeof(HVFState),
|
||||
};
|
||||
|
||||
static void hvf_type_init(void)
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
#include "disas/disas.h"
|
||||
#include "exec/exec-all.h"
|
||||
#include "tcg/tcg.h"
|
||||
#include "tcg/tcg-apple-jit.h"
|
||||
#include "qemu/atomic.h"
|
||||
#include "qemu/rcu.h"
|
||||
#include "exec/log.h"
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
#include "exec/translate-all.h"
|
||||
#include "sysemu/tcg.h"
|
||||
#include "tcg/tcg.h"
|
||||
#include "tcg/tcg-apple-jit.h"
|
||||
#include "tb-hash.h"
|
||||
#include "tb-context.h"
|
||||
#include "internal.h"
|
||||
@@ -1094,6 +1093,9 @@ tb_invalidate_phys_page_range__locked(struct page_collection *pages,
|
||||
TranslationBlock *current_tb = retaddr ? tcg_tb_lookup(retaddr) : NULL;
|
||||
#endif /* TARGET_HAS_PRECISE_SMC */
|
||||
|
||||
/* Range may not cross a page. */
|
||||
tcg_debug_assert(((start ^ last) & TARGET_PAGE_MASK) == 0);
|
||||
|
||||
/*
|
||||
* We remove all the TBs in the range [start, last].
|
||||
* XXX: see if in some cases it could be faster to invalidate all the code
|
||||
@@ -1184,15 +1186,17 @@ void tb_invalidate_phys_range(tb_page_addr_t start, tb_page_addr_t last)
|
||||
index_last = last >> TARGET_PAGE_BITS;
|
||||
for (index = start >> TARGET_PAGE_BITS; index <= index_last; index++) {
|
||||
PageDesc *pd = page_find(index);
|
||||
tb_page_addr_t bound;
|
||||
tb_page_addr_t page_start, page_last;
|
||||
|
||||
if (pd == NULL) {
|
||||
continue;
|
||||
}
|
||||
assert_page_locked(pd);
|
||||
bound = (index << TARGET_PAGE_BITS) | ~TARGET_PAGE_MASK;
|
||||
bound = MIN(bound, last);
|
||||
tb_invalidate_phys_page_range__locked(pages, pd, start, bound, 0);
|
||||
page_start = index << TARGET_PAGE_BITS;
|
||||
page_last = page_start | ~TARGET_PAGE_MASK;
|
||||
page_last = MIN(page_last, last);
|
||||
tb_invalidate_phys_page_range__locked(pages, pd,
|
||||
page_start, page_last, 0);
|
||||
}
|
||||
page_collection_unlock(pages);
|
||||
}
|
||||
|
||||
@@ -59,11 +59,6 @@ void tcg_cpu_init_cflags(CPUState *cpu, bool parallel)
|
||||
|
||||
cflags |= parallel ? CF_PARALLEL : 0;
|
||||
cflags |= icount_enabled() ? CF_USE_ICOUNT : 0;
|
||||
#if defined(CONFIG_TCG_THREADED_INTERPRETER)
|
||||
// GOTO_PTR is too complex to emit a simple gadget for.
|
||||
// We'll let C handle it, since the overhead is similar.
|
||||
cflags |= CF_NO_GOTO_PTR;
|
||||
#endif
|
||||
cpu->tcg_cflags |= cflags;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
#include "disas/disas.h"
|
||||
#include "exec/exec-all.h"
|
||||
#include "tcg/tcg.h"
|
||||
#include "tcg/tcg-apple-jit.h"
|
||||
#if defined(CONFIG_USER_ONLY)
|
||||
#include "qemu.h"
|
||||
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||
|
||||
+6
-24
@@ -1403,21 +1403,12 @@ void audio_run(AudioState *s, const char *msg)
|
||||
#endif
|
||||
}
|
||||
|
||||
void audio_generic_initialize_buffer_in(HWVoiceIn *hw)
|
||||
{
|
||||
if (hw->buf_emul) {
|
||||
g_free(hw->buf_emul);
|
||||
}
|
||||
|
||||
hw->size_emul = hw->samples * hw->info.bytes_per_frame;
|
||||
hw->buf_emul = g_malloc(hw->size_emul);
|
||||
hw->pos_emul = hw->pending_emul = 0;
|
||||
}
|
||||
|
||||
void audio_generic_run_buffer_in(HWVoiceIn *hw)
|
||||
{
|
||||
if (unlikely(!hw->buf_emul)) {
|
||||
audio_generic_initialize_buffer_in(hw);
|
||||
hw->size_emul = hw->samples * hw->info.bytes_per_frame;
|
||||
hw->buf_emul = g_malloc(hw->size_emul);
|
||||
hw->pos_emul = hw->pending_emul = 0;
|
||||
}
|
||||
|
||||
while (hw->pending_emul < hw->size_emul) {
|
||||
@@ -1451,17 +1442,6 @@ void audio_generic_put_buffer_in(HWVoiceIn *hw, void *buf, size_t size)
|
||||
hw->pending_emul -= size;
|
||||
}
|
||||
|
||||
void audio_generic_initialize_buffer_out(HWVoiceOut *hw)
|
||||
{
|
||||
if (hw->buf_emul) {
|
||||
g_free(hw->buf_emul);
|
||||
}
|
||||
|
||||
hw->size_emul = hw->samples * hw->info.bytes_per_frame;
|
||||
hw->buf_emul = g_malloc(hw->size_emul);
|
||||
hw->pos_emul = hw->pending_emul = 0;
|
||||
}
|
||||
|
||||
size_t audio_generic_buffer_get_free(HWVoiceOut *hw)
|
||||
{
|
||||
if (hw->buf_emul) {
|
||||
@@ -1493,7 +1473,9 @@ void audio_generic_run_buffer_out(HWVoiceOut *hw)
|
||||
void *audio_generic_get_buffer_out(HWVoiceOut *hw, size_t *size)
|
||||
{
|
||||
if (unlikely(!hw->buf_emul)) {
|
||||
audio_generic_initialize_buffer_out(hw);
|
||||
hw->size_emul = hw->samples * hw->info.bytes_per_frame;
|
||||
hw->buf_emul = g_malloc(hw->size_emul);
|
||||
hw->pos_emul = hw->pending_emul = 0;
|
||||
}
|
||||
|
||||
*size = MIN(hw->size_emul - hw->pending_emul,
|
||||
|
||||
@@ -188,11 +188,9 @@ struct audio_pcm_ops {
|
||||
void (*volume_in)(HWVoiceIn *hw, Volume *vol);
|
||||
};
|
||||
|
||||
void audio_generic_initialize_buffer_in(HWVoiceIn *hw);
|
||||
void audio_generic_run_buffer_in(HWVoiceIn *hw);
|
||||
void *audio_generic_get_buffer_in(HWVoiceIn *hw, size_t *size);
|
||||
void audio_generic_put_buffer_in(HWVoiceIn *hw, void *buf, size_t size);
|
||||
void audio_generic_initialize_buffer_out(HWVoiceOut *hw);
|
||||
void audio_generic_run_buffer_out(HWVoiceOut *hw);
|
||||
size_t audio_generic_buffer_get_free(HWVoiceOut *hw);
|
||||
void *audio_generic_get_buffer_out(HWVoiceOut *hw, size_t *size);
|
||||
|
||||
+22
-28
@@ -360,10 +360,7 @@ static OSStatus audioDeviceIOProc(
|
||||
static OSStatus init_out_device(coreaudioVoiceOut *core)
|
||||
{
|
||||
OSStatus status;
|
||||
AudioDeviceID deviceID;
|
||||
AudioValueRange frameRange;
|
||||
UInt32 audioDevicePropertyBufferFrameSize;
|
||||
AudioDeviceIOProcID ioprocid;
|
||||
|
||||
AudioStreamBasicDescription streamBasicDescription = {
|
||||
.mBitsPerChannel = core->hw.info.bits,
|
||||
@@ -376,19 +373,20 @@ static OSStatus init_out_device(coreaudioVoiceOut *core)
|
||||
.mSampleRate = core->hw.info.freq
|
||||
};
|
||||
|
||||
status = coreaudio_get_voice(&deviceID);
|
||||
status = coreaudio_get_voice(&core->outputDeviceID);
|
||||
if (status != kAudioHardwareNoError) {
|
||||
coreaudio_playback_logerr (status,
|
||||
"Could not get default output Device\n");
|
||||
return status;
|
||||
}
|
||||
if (deviceID == kAudioDeviceUnknown) {
|
||||
if (core->outputDeviceID == kAudioDeviceUnknown) {
|
||||
dolog ("Could not initialize playback - Unknown Audiodevice\n");
|
||||
return status;
|
||||
}
|
||||
|
||||
/* get minimum and maximum buffer frame sizes */
|
||||
status = coreaudio_get_framesizerange(deviceID, &frameRange);
|
||||
status = coreaudio_get_framesizerange(core->outputDeviceID,
|
||||
&frameRange);
|
||||
if (status == kAudioHardwareBadObjectError) {
|
||||
return 0;
|
||||
}
|
||||
@@ -399,31 +397,31 @@ static OSStatus init_out_device(coreaudioVoiceOut *core)
|
||||
}
|
||||
|
||||
if (frameRange.mMinimum > core->frameSizeSetting) {
|
||||
audioDevicePropertyBufferFrameSize = (UInt32) frameRange.mMinimum;
|
||||
core->audioDevicePropertyBufferFrameSize = (UInt32) frameRange.mMinimum;
|
||||
dolog ("warning: Upsizing Buffer Frames to %f\n", frameRange.mMinimum);
|
||||
} else if (frameRange.mMaximum < core->frameSizeSetting) {
|
||||
audioDevicePropertyBufferFrameSize = (UInt32) frameRange.mMaximum;
|
||||
core->audioDevicePropertyBufferFrameSize = (UInt32) frameRange.mMaximum;
|
||||
dolog ("warning: Downsizing Buffer Frames to %f\n", frameRange.mMaximum);
|
||||
} else {
|
||||
audioDevicePropertyBufferFrameSize = core->frameSizeSetting;
|
||||
core->audioDevicePropertyBufferFrameSize = core->frameSizeSetting;
|
||||
}
|
||||
|
||||
/* set Buffer Frame Size */
|
||||
status = coreaudio_set_framesize(deviceID,
|
||||
&audioDevicePropertyBufferFrameSize);
|
||||
status = coreaudio_set_framesize(core->outputDeviceID,
|
||||
&core->audioDevicePropertyBufferFrameSize);
|
||||
if (status == kAudioHardwareBadObjectError) {
|
||||
return 0;
|
||||
}
|
||||
if (status != kAudioHardwareNoError) {
|
||||
coreaudio_playback_logerr (status,
|
||||
"Could not set device buffer frame size %" PRIu32 "\n",
|
||||
(uint32_t)audioDevicePropertyBufferFrameSize);
|
||||
(uint32_t)core->audioDevicePropertyBufferFrameSize);
|
||||
return status;
|
||||
}
|
||||
|
||||
/* get Buffer Frame Size */
|
||||
status = coreaudio_get_framesize(deviceID,
|
||||
&audioDevicePropertyBufferFrameSize);
|
||||
status = coreaudio_get_framesize(core->outputDeviceID,
|
||||
&core->audioDevicePropertyBufferFrameSize);
|
||||
if (status == kAudioHardwareBadObjectError) {
|
||||
return 0;
|
||||
}
|
||||
@@ -432,9 +430,11 @@ static OSStatus init_out_device(coreaudioVoiceOut *core)
|
||||
"Could not get device buffer frame size\n");
|
||||
return status;
|
||||
}
|
||||
core->hw.samples = core->bufferCount * core->audioDevicePropertyBufferFrameSize;
|
||||
|
||||
/* set Samplerate */
|
||||
status = coreaudio_set_streamformat(deviceID, &streamBasicDescription);
|
||||
status = coreaudio_set_streamformat(core->outputDeviceID,
|
||||
&streamBasicDescription);
|
||||
if (status == kAudioHardwareBadObjectError) {
|
||||
return 0;
|
||||
}
|
||||
@@ -442,6 +442,7 @@ static OSStatus init_out_device(coreaudioVoiceOut *core)
|
||||
coreaudio_playback_logerr (status,
|
||||
"Could not set samplerate %lf\n",
|
||||
streamBasicDescription.mSampleRate);
|
||||
core->outputDeviceID = kAudioDeviceUnknown;
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -455,25 +456,20 @@ static OSStatus init_out_device(coreaudioVoiceOut *core)
|
||||
* Therefore, the specified callback must be designed to avoid a deadlock
|
||||
* with the callers of AudioObjectGetPropertyData.
|
||||
*/
|
||||
ioprocid = NULL;
|
||||
status = AudioDeviceCreateIOProcID(deviceID,
|
||||
core->ioprocid = NULL;
|
||||
status = AudioDeviceCreateIOProcID(core->outputDeviceID,
|
||||
audioDeviceIOProc,
|
||||
&core->hw,
|
||||
&ioprocid);
|
||||
&core->ioprocid);
|
||||
if (status == kAudioHardwareBadDeviceError) {
|
||||
return 0;
|
||||
}
|
||||
if (status != kAudioHardwareNoError || ioprocid == NULL) {
|
||||
if (status != kAudioHardwareNoError || core->ioprocid == NULL) {
|
||||
coreaudio_playback_logerr (status, "Could not set IOProc\n");
|
||||
core->outputDeviceID = kAudioDeviceUnknown;
|
||||
return status;
|
||||
}
|
||||
|
||||
core->outputDeviceID = deviceID;
|
||||
core->audioDevicePropertyBufferFrameSize = audioDevicePropertyBufferFrameSize;
|
||||
core->hw.samples = core->bufferCount * core->audioDevicePropertyBufferFrameSize;
|
||||
audio_generic_initialize_buffer_out(&core->hw);
|
||||
core->ioprocid = ioprocid;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -557,9 +553,7 @@ static OSStatus handle_voice_change(
|
||||
fini_out_device(core);
|
||||
}
|
||||
|
||||
init_out_device(core);
|
||||
|
||||
if (core->outputDeviceID) {
|
||||
if (!init_out_device(core)) {
|
||||
update_device_playback_state(core);
|
||||
}
|
||||
|
||||
|
||||
@@ -191,6 +191,11 @@ static int cryptodev_backend_account(CryptoDevBackend *backend,
|
||||
if (algtype == QCRYPTODEV_BACKEND_ALG_ASYM) {
|
||||
CryptoDevBackendAsymOpInfo *asym_op_info = op_info->u.asym_op_info;
|
||||
len = asym_op_info->src_len;
|
||||
|
||||
if (unlikely(!backend->asym_stat)) {
|
||||
error_report("cryptodev: Unexpected asym operation");
|
||||
return -VIRTIO_CRYPTO_NOTSUPP;
|
||||
}
|
||||
switch (op_info->op_code) {
|
||||
case VIRTIO_CRYPTO_AKCIPHER_ENCRYPT:
|
||||
CryptodevAsymStatIncEncrypt(backend, len);
|
||||
@@ -210,6 +215,11 @@ static int cryptodev_backend_account(CryptoDevBackend *backend,
|
||||
} else if (algtype == QCRYPTODEV_BACKEND_ALG_SYM) {
|
||||
CryptoDevBackendSymOpInfo *sym_op_info = op_info->u.sym_op_info;
|
||||
len = sym_op_info->src_len;
|
||||
|
||||
if (unlikely(!backend->sym_stat)) {
|
||||
error_report("cryptodev: Unexpected sym operation");
|
||||
return -VIRTIO_CRYPTO_NOTSUPP;
|
||||
}
|
||||
switch (op_info->op_code) {
|
||||
case VIRTIO_CRYPTO_CIPHER_ENCRYPT:
|
||||
CryptodevSymStatIncEncrypt(backend, len);
|
||||
|
||||
+2
-40
@@ -44,10 +44,10 @@
|
||||
|
||||
#if defined(__APPLE__) && (__MACH__)
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/mount.h>
|
||||
#if defined(HAVE_HOST_BLOCK_DEVICE)
|
||||
#include <paths.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/mount.h>
|
||||
#include <IOKit/IOKitLib.h>
|
||||
#include <IOKit/IOBSD.h>
|
||||
#include <IOKit/storage/IOMediaBSDClient.h>
|
||||
@@ -131,14 +131,6 @@
|
||||
#define RAW_LOCK_PERM_BASE 100
|
||||
#define RAW_LOCK_SHARED_BASE 200
|
||||
|
||||
/*
|
||||
* qemu_lock_fd_test always returns 0 when fd is not open for writing and
|
||||
* exclusive is true on macOS 11.3.1.
|
||||
*/
|
||||
#ifdef __APPLE__
|
||||
#define RAW_LOCK_WRITES
|
||||
#endif
|
||||
|
||||
typedef struct BDRVRawState {
|
||||
int fd;
|
||||
bool use_lock;
|
||||
@@ -281,13 +273,6 @@ static int raw_normalize_devicepath(const char **filename, Error **errp)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_IOS)
|
||||
static int probe_logical_blocksize(int fd, unsigned int *sector_size_p)
|
||||
{
|
||||
return -ENOTSUP; /* not supported on iOS */
|
||||
}
|
||||
#else /* CONFIG_IOS */
|
||||
|
||||
/*
|
||||
* Get logical block size via ioctl. On success store it in @sector_size_p.
|
||||
*/
|
||||
@@ -321,8 +306,6 @@ static int probe_logical_blocksize(int fd, unsigned int *sector_size_p)
|
||||
return success ? 0 : -errno;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Get physical block size of @fd.
|
||||
* On success, store it in @blk_size and return 0.
|
||||
@@ -691,11 +674,7 @@ static int raw_open_common(BlockDriverState *bs, QDict *options,
|
||||
false);
|
||||
|
||||
s->open_flags = open_flags;
|
||||
#ifdef RAW_LOCK_WRITES
|
||||
raw_parse_flags(bdrv_flags, &s->open_flags, s->use_lock);
|
||||
#else
|
||||
raw_parse_flags(bdrv_flags, &s->open_flags, false);
|
||||
#endif
|
||||
|
||||
s->fd = -1;
|
||||
fd = qemu_open(filename, s->open_flags, errp);
|
||||
@@ -1060,11 +1039,6 @@ static int raw_reconfigure_getfd(BlockDriverState *bs, int flags,
|
||||
bool has_writers = perm &
|
||||
(BLK_PERM_WRITE | BLK_PERM_WRITE_UNCHANGED | BLK_PERM_RESIZE);
|
||||
int fcntl_flags = O_APPEND | O_NONBLOCK;
|
||||
#ifdef RAW_LOCK_WRITES
|
||||
if (s->use_lock) {
|
||||
has_writers = true;
|
||||
}
|
||||
#endif
|
||||
#ifdef O_NOATIME
|
||||
fcntl_flags |= O_NOATIME;
|
||||
#endif
|
||||
@@ -1457,24 +1431,12 @@ static bool preadv_present = true;
|
||||
static ssize_t
|
||||
qemu_preadv(int fd, const struct iovec *iov, int nr_iov, off_t offset)
|
||||
{
|
||||
#ifdef CONFIG_DARWIN /* preadv introduced in macOS 11 */
|
||||
if (!__builtin_available(macOS 11, iOS 14, watchOS 7, tvOS 14, *)) {
|
||||
preadv_present = false;
|
||||
return -ENOSYS;
|
||||
} else
|
||||
#endif
|
||||
return preadv(fd, iov, nr_iov, offset);
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
qemu_pwritev(int fd, const struct iovec *iov, int nr_iov, off_t offset)
|
||||
{
|
||||
#ifdef CONFIG_DARWIN /* pwritev introduced in macOS 11 */
|
||||
if (!__builtin_available(macOS 11, iOS 14, watchOS 7, tvOS 14, *)) {
|
||||
preadv_present = false;
|
||||
return -ENOSYS;
|
||||
} else
|
||||
#endif
|
||||
return pwritev(fd, iov, nr_iov, offset);
|
||||
}
|
||||
|
||||
|
||||
@@ -293,7 +293,6 @@ meson=""
|
||||
ninja=""
|
||||
bindir="bin"
|
||||
skip_meson=no
|
||||
shared_lib="no"
|
||||
vfio_user_server="disabled"
|
||||
|
||||
# The following Meson options are handled manually (still they
|
||||
@@ -897,12 +896,6 @@ for opt do
|
||||
;;
|
||||
--disable-vfio-user-server) vfio_user_server="disabled"
|
||||
;;
|
||||
--enable-shared-lib)
|
||||
shared_lib="yes"
|
||||
plugins="no"
|
||||
;;
|
||||
--disable-shared-lib) shared_lib="no"
|
||||
;;
|
||||
# everything else has the same name in configure and meson
|
||||
--*) meson_option_parse "$opt" "$optarg"
|
||||
;;
|
||||
@@ -914,10 +907,6 @@ if test "$plugins" = "yes" -a "$tcg" = "disabled"; then
|
||||
error_exit "Can't enable plugins on non-TCG builds"
|
||||
fi
|
||||
|
||||
if test "$plugins" = "yes" -a "$shared_lib" = "yes"; then
|
||||
error_exit "Can't enable plugins on shared library builds"
|
||||
fi
|
||||
|
||||
case $git_submodules_action in
|
||||
update|validate)
|
||||
if test ! -e "$source_path/.git"; then
|
||||
@@ -1042,7 +1031,7 @@ Advanced options (experts only):
|
||||
--disable-stack-protector disable compiler-provided stack protection
|
||||
--cpu=CPU Build for host CPU [$cpu]
|
||||
--with-coroutine=BACKEND coroutine backend. Supported options:
|
||||
ucontext, libucontext, sigaltstack, windows
|
||||
ucontext, sigaltstack, windows
|
||||
--enable-plugins
|
||||
enable plugins via shared library loading
|
||||
--disable-containers don't use containers for cross-building
|
||||
@@ -1633,26 +1622,12 @@ else
|
||||
error_exit "only the 'windows' coroutine backend is valid for Windows"
|
||||
fi
|
||||
;;
|
||||
libucontext)
|
||||
;;
|
||||
*)
|
||||
error_exit "unknown coroutine backend $coroutine"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
case $coroutine in
|
||||
libucontext)
|
||||
git_submodules="${git_submodules} subprojects/libucontext"
|
||||
coroutine_impl=ucontext
|
||||
libucontext="enabled"
|
||||
;;
|
||||
*)
|
||||
coroutine_impl=$coroutine
|
||||
libucontext="disabled"
|
||||
;;
|
||||
esac
|
||||
|
||||
##################################################
|
||||
# SafeStack
|
||||
|
||||
@@ -2417,7 +2392,7 @@ if [ "$bsd" = "yes" ] ; then
|
||||
echo "CONFIG_BSD=y" >> $config_host_mak
|
||||
fi
|
||||
|
||||
echo "CONFIG_COROUTINE_BACKEND=$coroutine_impl" >> $config_host_mak
|
||||
echo "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
|
||||
|
||||
if test "$have_asan_iface_fiber" = "yes" ; then
|
||||
echo "CONFIG_ASAN_IFACE_FIBER=y" >> $config_host_mak
|
||||
@@ -2431,10 +2406,6 @@ if test "$plugins" = "yes" ; then
|
||||
echo "CONFIG_PLUGIN=y" >> $config_host_mak
|
||||
fi
|
||||
|
||||
if test "$shared_lib" = "yes" ; then
|
||||
echo "CONFIG_SHARED_LIBRARY_BUILD=y" >> $config_host_mak
|
||||
fi
|
||||
|
||||
if test -n "$gdb_bin"; then
|
||||
gdb_version=$($gdb_bin --version | head -n 1)
|
||||
if version_ge ${gdb_version##* } 9.1; then
|
||||
@@ -2616,11 +2587,7 @@ if test "$skip_meson" = no; then
|
||||
if has $sdl2_config; then
|
||||
echo "sdl2-config = [$(meson_quote $sdl2_config)]" >> $cross
|
||||
fi
|
||||
if test "$shared_lib" = "yes"; then
|
||||
echo "strip = [$(meson_quote $strip), '-x']" >> $cross
|
||||
else
|
||||
echo "strip = [$(meson_quote $strip)]" >> $cross
|
||||
fi
|
||||
echo "strip = [$(meson_quote $strip)]" >> $cross
|
||||
echo "widl = [$(meson_quote $widl)]" >> $cross
|
||||
echo "windres = [$(meson_quote $windres)]" >> $cross
|
||||
echo "windmc = [$(meson_quote $windmc)]" >> $cross
|
||||
|
||||
@@ -323,7 +323,7 @@ virgl_cmd_set_scanout(VuGpu *g,
|
||||
struct virtio_gpu_ctrl_command *cmd)
|
||||
{
|
||||
struct virtio_gpu_set_scanout ss;
|
||||
struct virgl_renderer_texture_info info;
|
||||
struct virgl_renderer_resource_info info;
|
||||
int ret;
|
||||
|
||||
VUGPU_FILL_CMD(ss);
|
||||
@@ -338,7 +338,7 @@ virgl_cmd_set_scanout(VuGpu *g,
|
||||
memset(&info, 0, sizeof(info));
|
||||
|
||||
if (ss.resource_id && ss.r.width && ss.r.height) {
|
||||
ret = virgl_renderer_borrow_texture_for_scanout(ss.resource_id, &info);
|
||||
ret = virgl_renderer_resource_get_info(ss.resource_id, &info);
|
||||
if (ret == -1) {
|
||||
g_critical("%s: illegal resource specified %d\n",
|
||||
__func__, ss.resource_id);
|
||||
|
||||
@@ -151,8 +151,6 @@ static void initialize_debug_host(CPUDebug *s)
|
||||
#endif
|
||||
#if defined(CONFIG_TCG_INTERPRETER)
|
||||
s->info.print_insn = print_insn_tci;
|
||||
#elif defined(CONFIG_TCG_THREADED_INTERPRETER)
|
||||
s->info.print_insn = print_insn_tcti;
|
||||
#elif defined(__i386__)
|
||||
s->info.mach = bfd_mach_i386_i386;
|
||||
s->info.cap_arch = CS_ARCH_X86;
|
||||
|
||||
@@ -41,8 +41,6 @@ operating system.
|
||||
|
||||
QEMU files related to TPM CRB interface:
|
||||
- ``hw/tpm/tpm_crb.c``
|
||||
- ``hw/tpm/tpm_crb_common.c``
|
||||
- ``hw/tpm/tpm_crb_sysbus.c``
|
||||
|
||||
SPAPR interface
|
||||
---------------
|
||||
|
||||
@@ -4,7 +4,7 @@ Multi-process QEMU
|
||||
==================
|
||||
|
||||
This document describes how to configure and use multi-process qemu.
|
||||
For the design document refer to docs/devel/qemu-multiprocess.
|
||||
For the design document refer to docs/devel/multi-process.rst.
|
||||
|
||||
1) Configuration
|
||||
----------------
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "qemu/xattr.h"
|
||||
#include "9p-iov-marshal.h"
|
||||
#include "hw/9pfs/9p-proxy.h"
|
||||
#include "hw/9pfs/9p-util.h"
|
||||
#include "fsdev/9p-iov-marshal.h"
|
||||
|
||||
#define PROGNAME "virtfs-proxy-helper"
|
||||
@@ -338,6 +339,28 @@ static void resetugid(int suid, int sgid)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Open regular file or directory. Attempts to open any special file are
|
||||
* rejected.
|
||||
*
|
||||
* returns file descriptor or -1 on error
|
||||
*/
|
||||
static int open_regular(const char *pathname, int flags, mode_t mode)
|
||||
{
|
||||
int fd;
|
||||
|
||||
fd = open(pathname, flags, mode);
|
||||
if (fd < 0) {
|
||||
return fd;
|
||||
}
|
||||
|
||||
if (close_if_special_file(fd) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
/*
|
||||
* send response in two parts
|
||||
* 1) ProxyHeader
|
||||
@@ -682,7 +705,7 @@ static int do_create(struct iovec *iovec)
|
||||
if (ret < 0) {
|
||||
goto unmarshal_err_out;
|
||||
}
|
||||
ret = open(path.data, flags, mode);
|
||||
ret = open_regular(path.data, flags, mode);
|
||||
if (ret < 0) {
|
||||
ret = -errno;
|
||||
}
|
||||
@@ -707,7 +730,7 @@ static int do_open(struct iovec *iovec)
|
||||
if (ret < 0) {
|
||||
goto err_out;
|
||||
}
|
||||
ret = open(path.data, flags);
|
||||
ret = open_regular(path.data, flags, 0);
|
||||
if (ret < 0) {
|
||||
ret = -errno;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
#ifndef QEMU_9P_UTIL_H
|
||||
#define QEMU_9P_UTIL_H
|
||||
|
||||
#include "qemu/error-report.h"
|
||||
|
||||
#ifdef O_PATH
|
||||
#define O_PATH_9P_UTIL O_PATH
|
||||
#else
|
||||
@@ -95,6 +97,7 @@ static inline int errno_to_dotl(int err) {
|
||||
#endif
|
||||
|
||||
#define qemu_openat openat
|
||||
#define qemu_fstat fstat
|
||||
#define qemu_fstatat fstatat
|
||||
#define qemu_mkdirat mkdirat
|
||||
#define qemu_renameat renameat
|
||||
@@ -108,6 +111,38 @@ static inline void close_preserve_errno(int fd)
|
||||
errno = serrno;
|
||||
}
|
||||
|
||||
/**
|
||||
* close_if_special_file() - Close @fd if neither regular file nor directory.
|
||||
*
|
||||
* @fd: file descriptor of open file
|
||||
* Return: 0 on regular file or directory, -1 otherwise
|
||||
*
|
||||
* CVE-2023-2861: Prohibit opening any special file directly on host
|
||||
* (especially device files), as a compromised client could potentially gain
|
||||
* access outside exported tree under certain, unsafe setups. We expect
|
||||
* client to handle I/O on special files exclusively on guest side.
|
||||
*/
|
||||
static inline int close_if_special_file(int fd)
|
||||
{
|
||||
struct stat stbuf;
|
||||
|
||||
if (qemu_fstat(fd, &stbuf) < 0) {
|
||||
close_preserve_errno(fd);
|
||||
return -1;
|
||||
}
|
||||
if (!S_ISREG(stbuf.st_mode) && !S_ISDIR(stbuf.st_mode)) {
|
||||
error_report_once(
|
||||
"9p: broken or compromised client detected; attempt to open "
|
||||
"special file (i.e. neither regular file, nor directory)"
|
||||
);
|
||||
close(fd);
|
||||
errno = ENXIO;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int openat_dir(int dirfd, const char *name)
|
||||
{
|
||||
return qemu_openat(dirfd, name,
|
||||
@@ -142,6 +177,10 @@ again:
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (close_if_special_file(fd) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
serrno = errno;
|
||||
/* O_NONBLOCK was only needed to open the file. Let's drop it. We don't
|
||||
* do that with O_PATH since fcntl(F_SETFL) isn't supported, and openat()
|
||||
|
||||
+1
-6
@@ -31,7 +31,6 @@
|
||||
#include "hw/pci/pci_bus.h"
|
||||
#include "hw/pci/pci_bridge.h"
|
||||
#include "qemu/cutils.h"
|
||||
#include "qom/object.h"
|
||||
|
||||
static GArray *build_alloc_array(void)
|
||||
{
|
||||
@@ -2219,7 +2218,7 @@ void build_tpm2(GArray *table_data, BIOSLinker *linker, GArray *tcpalog,
|
||||
{
|
||||
uint8_t start_method_params[12] = {};
|
||||
unsigned log_addr_offset;
|
||||
uint64_t baseaddr, control_area_start_address;
|
||||
uint64_t control_area_start_address;
|
||||
TPMIf *tpmif = tpm_find();
|
||||
uint32_t start_method;
|
||||
AcpiTable table = { .sig = "TPM2", .rev = 4,
|
||||
@@ -2237,10 +2236,6 @@ void build_tpm2(GArray *table_data, BIOSLinker *linker, GArray *tcpalog,
|
||||
} else if (TPM_IS_CRB(tpmif)) {
|
||||
control_area_start_address = TPM_CRB_ADDR_CTRL;
|
||||
start_method = TPM2_START_METHOD_CRB;
|
||||
} else if (TPM_IS_CRB_SYSBUS(tpmif)) {
|
||||
baseaddr = object_property_get_uint(OBJECT(tpmif), "baseaddr", NULL);
|
||||
control_area_start_address = baseaddr + A_CRB_CTRL_REQ;
|
||||
start_method = TPM2_START_METHOD_CRB;
|
||||
} else {
|
||||
g_assert_not_reached();
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ config ARM_VIRT
|
||||
imply VFIO_AMD_XGBE
|
||||
imply VFIO_PLATFORM
|
||||
imply VFIO_XGMAC
|
||||
imply TPM_CRB_SYSBUS
|
||||
imply TPM_TIS_SYSBUS
|
||||
imply NVDIMM
|
||||
select ARM_GIC
|
||||
|
||||
@@ -192,8 +192,7 @@ static int get_pte(dma_addr_t baseaddr, uint32_t index, uint64_t *pte,
|
||||
dma_addr_t addr = baseaddr + index * sizeof(*pte);
|
||||
|
||||
/* TODO: guarantee 64-bit single-copy atomicity */
|
||||
ret = dma_memory_read(&address_space_memory, addr, pte, sizeof(*pte),
|
||||
MEMTXATTRS_UNSPECIFIED);
|
||||
ret = ldq_le_dma(&address_space_memory, addr, pte, MEMTXATTRS_UNSPECIFIED);
|
||||
|
||||
if (ret != MEMTX_OK) {
|
||||
info->type = SMMU_PTW_ERR_WALK_EABT;
|
||||
|
||||
+31
-8
@@ -98,20 +98,34 @@ static void smmuv3_write_gerrorn(SMMUv3State *s, uint32_t new_gerrorn)
|
||||
trace_smmuv3_write_gerrorn(toggled & pending, s->gerrorn);
|
||||
}
|
||||
|
||||
static inline MemTxResult queue_read(SMMUQueue *q, void *data)
|
||||
static inline MemTxResult queue_read(SMMUQueue *q, Cmd *cmd)
|
||||
{
|
||||
dma_addr_t addr = Q_CONS_ENTRY(q);
|
||||
MemTxResult ret;
|
||||
int i;
|
||||
|
||||
return dma_memory_read(&address_space_memory, addr, data, q->entry_size,
|
||||
MEMTXATTRS_UNSPECIFIED);
|
||||
ret = dma_memory_read(&address_space_memory, addr, cmd, sizeof(Cmd),
|
||||
MEMTXATTRS_UNSPECIFIED);
|
||||
if (ret != MEMTX_OK) {
|
||||
return ret;
|
||||
}
|
||||
for (i = 0; i < ARRAY_SIZE(cmd->word); i++) {
|
||||
le32_to_cpus(&cmd->word[i]);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static MemTxResult queue_write(SMMUQueue *q, void *data)
|
||||
static MemTxResult queue_write(SMMUQueue *q, Evt *evt_in)
|
||||
{
|
||||
dma_addr_t addr = Q_PROD_ENTRY(q);
|
||||
MemTxResult ret;
|
||||
Evt evt = *evt_in;
|
||||
int i;
|
||||
|
||||
ret = dma_memory_write(&address_space_memory, addr, data, q->entry_size,
|
||||
for (i = 0; i < ARRAY_SIZE(evt.word); i++) {
|
||||
cpu_to_le32s(&evt.word[i]);
|
||||
}
|
||||
ret = dma_memory_write(&address_space_memory, addr, &evt, sizeof(Evt),
|
||||
MEMTXATTRS_UNSPECIFIED);
|
||||
if (ret != MEMTX_OK) {
|
||||
return ret;
|
||||
@@ -291,7 +305,7 @@ static void smmuv3_init_regs(SMMUv3State *s)
|
||||
static int smmu_get_ste(SMMUv3State *s, dma_addr_t addr, STE *buf,
|
||||
SMMUEventInfo *event)
|
||||
{
|
||||
int ret;
|
||||
int ret, i;
|
||||
|
||||
trace_smmuv3_get_ste(addr);
|
||||
/* TODO: guarantee 64-bit single-copy atomicity */
|
||||
@@ -304,6 +318,9 @@ static int smmu_get_ste(SMMUv3State *s, dma_addr_t addr, STE *buf,
|
||||
event->u.f_ste_fetch.addr = addr;
|
||||
return -EINVAL;
|
||||
}
|
||||
for (i = 0; i < ARRAY_SIZE(buf->word); i++) {
|
||||
le32_to_cpus(&buf->word[i]);
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
@@ -313,7 +330,7 @@ static int smmu_get_cd(SMMUv3State *s, STE *ste, uint32_t ssid,
|
||||
CD *buf, SMMUEventInfo *event)
|
||||
{
|
||||
dma_addr_t addr = STE_CTXPTR(ste);
|
||||
int ret;
|
||||
int ret, i;
|
||||
|
||||
trace_smmuv3_get_cd(addr);
|
||||
/* TODO: guarantee 64-bit single-copy atomicity */
|
||||
@@ -326,6 +343,9 @@ static int smmu_get_cd(SMMUv3State *s, STE *ste, uint32_t ssid,
|
||||
event->u.f_ste_fetch.addr = addr;
|
||||
return -EINVAL;
|
||||
}
|
||||
for (i = 0; i < ARRAY_SIZE(buf->word); i++) {
|
||||
le32_to_cpus(&buf->word[i]);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -407,7 +427,7 @@ static int smmu_find_ste(SMMUv3State *s, uint32_t sid, STE *ste,
|
||||
return -EINVAL;
|
||||
}
|
||||
if (s->features & SMMU_FEATURE_2LVL_STE) {
|
||||
int l1_ste_offset, l2_ste_offset, max_l2_ste, span;
|
||||
int l1_ste_offset, l2_ste_offset, max_l2_ste, span, i;
|
||||
dma_addr_t l1ptr, l2ptr;
|
||||
STEDesc l1std;
|
||||
|
||||
@@ -431,6 +451,9 @@ static int smmu_find_ste(SMMUv3State *s, uint32_t sid, STE *ste,
|
||||
event->u.f_ste_fetch.addr = l1ptr;
|
||||
return -EINVAL;
|
||||
}
|
||||
for (i = 0; i < ARRAY_SIZE(l1std.word); i++) {
|
||||
le32_to_cpus(&l1std.word[i]);
|
||||
}
|
||||
|
||||
span = L1STD_SPAN(&l1std);
|
||||
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
#include "target/arm/cpu.h"
|
||||
#include "hw/acpi/acpi-defs.h"
|
||||
#include "hw/acpi/acpi.h"
|
||||
#include "hw/acpi/acpi_aml_interface.h"
|
||||
#include "hw/nvram/fw_cfg.h"
|
||||
#include "hw/acpi/bios-linker-loader.h"
|
||||
#include "hw/acpi/aml-build.h"
|
||||
@@ -208,6 +207,41 @@ static void acpi_dsdt_add_gpio(Aml *scope, const MemMapEntry *gpio_memmap,
|
||||
aml_append(scope, dev);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_TPM
|
||||
static void acpi_dsdt_add_tpm(Aml *scope, VirtMachineState *vms)
|
||||
{
|
||||
PlatformBusDevice *pbus = PLATFORM_BUS_DEVICE(vms->platform_bus_dev);
|
||||
hwaddr pbus_base = vms->memmap[VIRT_PLATFORM_BUS].base;
|
||||
SysBusDevice *sbdev = SYS_BUS_DEVICE(tpm_find());
|
||||
MemoryRegion *sbdev_mr;
|
||||
hwaddr tpm_base;
|
||||
|
||||
if (!sbdev) {
|
||||
return;
|
||||
}
|
||||
|
||||
tpm_base = platform_bus_get_mmio_addr(pbus, sbdev, 0);
|
||||
assert(tpm_base != -1);
|
||||
|
||||
tpm_base += pbus_base;
|
||||
|
||||
sbdev_mr = sysbus_mmio_get_region(sbdev, 0);
|
||||
|
||||
Aml *dev = aml_device("TPM0");
|
||||
aml_append(dev, aml_name_decl("_HID", aml_string("MSFT0101")));
|
||||
aml_append(dev, aml_name_decl("_STR", aml_string("TPM 2.0 Device")));
|
||||
aml_append(dev, aml_name_decl("_UID", aml_int(0)));
|
||||
|
||||
Aml *crs = aml_resource_template();
|
||||
aml_append(crs,
|
||||
aml_memory32_fixed(tpm_base,
|
||||
(uint32_t)memory_region_size(sbdev_mr),
|
||||
AML_READ_WRITE));
|
||||
aml_append(dev, aml_name_decl("_CRS", crs));
|
||||
aml_append(scope, dev);
|
||||
}
|
||||
#endif
|
||||
|
||||
#define ID_MAPPING_ENTRY_SIZE 20
|
||||
#define SMMU_V3_ENTRY_SIZE 68
|
||||
#define ROOT_COMPLEX_ENTRY_SIZE 36
|
||||
@@ -856,7 +890,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
|
||||
|
||||
acpi_dsdt_add_power_button(scope);
|
||||
#ifdef CONFIG_TPM
|
||||
call_dev_aml_func(DEVICE(tpm_find()), scope);
|
||||
acpi_dsdt_add_tpm(scope, vms);
|
||||
#endif
|
||||
|
||||
aml_append(dsdt, scope);
|
||||
|
||||
@@ -1779,11 +1779,7 @@ static void virt_set_memmap(VirtMachineState *vms, int pa_bits)
|
||||
* irrespective of the underlying capabilities of the HW.
|
||||
*/
|
||||
if (!vms->highmem) {
|
||||
#ifdef CONFIG_DARWIN
|
||||
pa_bits = 36;
|
||||
#else
|
||||
pa_bits = 32;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2802,36 +2798,6 @@ static void virt_virtio_md_pci_unplug_request(HotplugHandler *hotplug_dev,
|
||||
error_setg(errp, "virtio based memory devices cannot be unplugged.");
|
||||
}
|
||||
|
||||
#ifdef CONFIG_TPM
|
||||
static void virt_tpm_plug(VirtMachineState *vms, TPMIf *tpmif)
|
||||
{
|
||||
PlatformBusDevice *pbus = PLATFORM_BUS_DEVICE(vms->platform_bus_dev);
|
||||
hwaddr pbus_base = vms->memmap[VIRT_PLATFORM_BUS].base;
|
||||
SysBusDevice *sbdev = SYS_BUS_DEVICE(tpmif);
|
||||
MemoryRegion *sbdev_mr;
|
||||
hwaddr tpm_base;
|
||||
uint64_t tpm_size;
|
||||
|
||||
if (!sbdev || !object_dynamic_cast(OBJECT(sbdev), TYPE_SYS_BUS_DEVICE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
tpm_base = platform_bus_get_mmio_addr(pbus, sbdev, 0);
|
||||
assert(tpm_base != -1);
|
||||
|
||||
tpm_base += pbus_base;
|
||||
|
||||
sbdev_mr = sysbus_mmio_get_region(sbdev, 0);
|
||||
tpm_size = memory_region_size(sbdev_mr);
|
||||
|
||||
if (object_property_find(OBJECT(sbdev), "baseaddr")) {
|
||||
object_property_set_uint(OBJECT(sbdev), "baseaddr", tpm_base, NULL);
|
||||
}
|
||||
if (object_property_find(OBJECT(sbdev), "size")) {
|
||||
object_property_set_uint(OBJECT(sbdev), "size", tpm_size, NULL);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static void virt_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev,
|
||||
DeviceState *dev, Error **errp)
|
||||
@@ -2905,12 +2871,6 @@ static void virt_machine_device_plug_cb(HotplugHandler *hotplug_dev,
|
||||
vms->virtio_iommu_bdf = pci_get_bdf(pdev);
|
||||
create_virtio_iommu_dt_bindings(vms);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_TPM
|
||||
if (object_dynamic_cast(OBJECT(dev), TYPE_TPM_IF)) {
|
||||
virt_tpm_plug(vms, TPM_IF(dev));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void virt_dimm_unplug_request(HotplugHandler *hotplug_dev,
|
||||
@@ -3045,7 +3005,6 @@ static void virt_machine_class_init(ObjectClass *oc, void *data)
|
||||
machine_class_allow_dynamic_sysbus_dev(mc, TYPE_VFIO_PLATFORM);
|
||||
#ifdef CONFIG_TPM
|
||||
machine_class_allow_dynamic_sysbus_dev(mc, TYPE_TPM_TIS_SYSBUS);
|
||||
machine_class_allow_dynamic_sysbus_dev(mc, TYPE_TPM_CRB_SYSBUS);
|
||||
#endif
|
||||
mc->block_default_type = IF_VIRTIO;
|
||||
mc->no_cdrom = 1;
|
||||
|
||||
@@ -213,7 +213,7 @@ static void xlnx_zynqmp_create_rpu(MachineState *ms, XlnxZynqMPState *s,
|
||||
const char *boot_cpu, Error **errp)
|
||||
{
|
||||
int i;
|
||||
int num_rpus = MIN(ms->smp.cpus - XLNX_ZYNQMP_NUM_APU_CPUS,
|
||||
int num_rpus = MIN((int)(ms->smp.cpus - XLNX_ZYNQMP_NUM_APU_CPUS),
|
||||
XLNX_ZYNQMP_NUM_RPU_CPUS);
|
||||
|
||||
if (num_rpus <= 0) {
|
||||
|
||||
@@ -47,6 +47,3 @@ config PL041
|
||||
|
||||
config CS4231
|
||||
bool
|
||||
|
||||
config SCREAMER
|
||||
bool
|
||||
@@ -12,4 +12,3 @@ softmmu_ss.add(when: 'CONFIG_PL041', if_true: files('pl041.c', 'lm4549.c'))
|
||||
softmmu_ss.add(when: 'CONFIG_SB16', if_true: files('sb16.c'))
|
||||
softmmu_ss.add(when: 'CONFIG_VT82C686', if_true: files('via-ac97.c'))
|
||||
softmmu_ss.add(when: 'CONFIG_WM8750', if_true: files('wm8750.c'))
|
||||
softmmu_ss.add(when: 'CONFIG_SCREAMER', if_true: files('screamer.c'))
|
||||
@@ -1,986 +0,0 @@
|
||||
/*
|
||||
* File: Screamer.c
|
||||
* Description: Implement the Screamer sound chip used in Apple Macintoshes.
|
||||
* It works by filling a buffer, then playing the buffer.
|
||||
*/
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
#include "audio/audio.h"
|
||||
#include "hw/hw.h"
|
||||
#include "hw/irq.h"
|
||||
#include <inttypes.h>
|
||||
#include "hw/ppc/mac_dbdma.h"
|
||||
#include "hw/qdev-properties.h"
|
||||
#include "migration/vmstate.h"
|
||||
#include "include/hw/audio/screamer.h"
|
||||
|
||||
#define DEBUG_SCREAMER 0
|
||||
#define DPRINTF(fmt, ...) \
|
||||
do { if (DEBUG_SCREAMER) { printf(fmt , ## __VA_ARGS__); } } while (0)
|
||||
|
||||
#define SOUND_CONTROL_REG 0
|
||||
#define CODEC_CONTROL_REG 1
|
||||
#define CODEC_STATUS_REG 2
|
||||
#define CLIP_COUNT_REG 3
|
||||
#define BYTE_SWAP_REG 4
|
||||
#define FRAME_COUNT_REG 5
|
||||
|
||||
#define AWACS_BUSY 0x01000000
|
||||
|
||||
/* Used with AWACS register 1 */
|
||||
#define RECALIBRATE 0x004
|
||||
#define LOOPTHRU 0x040
|
||||
#define SPEAKER_MUTE 0x080
|
||||
#define HEADPHONE_MUTE 0x200
|
||||
#define OUTPUT_ZERO 0x400
|
||||
#define OUTPUT_ONE 0x800
|
||||
#define PARALLEL_OUTPUT 0xc00
|
||||
|
||||
/* Function prototypes */
|
||||
static uint32_t set_busy_bit(uint32_t value, int bit);
|
||||
static uint32_t set_part_ready_bit(uint32_t value, int bit_value);
|
||||
static uint32_t set_revision(uint32_t input_value);
|
||||
static uint32_t set_manufacturer(uint32_t input_value);
|
||||
static int get_sampling_rate(ScreamerState *s);
|
||||
static uint32_t get_frame_count_reg(ScreamerState *s);
|
||||
static void add_to_speaker_buffer(DBDMA_io *io);
|
||||
static void dma_request(DBDMA_io *io);
|
||||
|
||||
|
||||
/**************************** Getters *************************/
|
||||
|
||||
/* Returns the codec control register's encoded AWACS address */
|
||||
static uint8_t get_codec_control_address(uint32_t value)
|
||||
{
|
||||
uint8_t return_value;
|
||||
return_value = (value >> 12) & 0x00000fff;
|
||||
return return_value;
|
||||
}
|
||||
|
||||
|
||||
static uint32_t get_sound_control_reg(ScreamerState *s)
|
||||
{
|
||||
DPRINTF("%s() called - returned 0x%x\n", __func__, s->sound_control);
|
||||
return s->sound_control;
|
||||
}
|
||||
|
||||
/* The AWACS registers are accessed thru this register */
|
||||
static uint32_t get_codec_control_reg(ScreamerState *s)
|
||||
{
|
||||
int awacs_register = get_codec_control_address(s->codec_control);
|
||||
uint32_t return_value = s->awacs[awacs_register];
|
||||
return_value = set_busy_bit(return_value, 0); /* Tell CPU we are ready */
|
||||
DPRINTF("%s() called - returned 0x%x\tAWACS register: %d\n", __func__,
|
||||
return_value, awacs_register);
|
||||
return return_value;
|
||||
}
|
||||
|
||||
/*
|
||||
* Determines if the readback bit is set.
|
||||
* It is used by the Codec Control register.
|
||||
*/
|
||||
static bool readback_enabled(ScreamerState *s)
|
||||
{
|
||||
/* Note: bit zero is the readback enabled bit */
|
||||
if (s->awacs[7] & 1) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t get_codec_status_reg(ScreamerState *s)
|
||||
{
|
||||
uint32_t return_value;
|
||||
|
||||
/* if in readback mode - return AWACS register value */
|
||||
if (readback_enabled(s)) {
|
||||
int awacs_register = (s->awacs[7] & 0xe) >> 1;
|
||||
s->awacs[7] = s->awacs[7] & 0xfffffffe; /* turn off readback mode */
|
||||
return_value = s->awacs[awacs_register] << 4;
|
||||
DPRINTF("readback enable bit is set, returning AWACS register %d\t"
|
||||
"value:0x%x\n", awacs_register, return_value);
|
||||
|
||||
return return_value;
|
||||
}
|
||||
|
||||
/* Tell CPU we are ready */
|
||||
return_value = set_part_ready_bit(s->codec_status, 1);
|
||||
|
||||
/* Set Revision to Screamer */
|
||||
return_value = set_revision(return_value);
|
||||
|
||||
/* Set the Manufacturer to Crystal */
|
||||
return_value = set_manufacturer(return_value);
|
||||
DPRINTF("%s() called - returned 0x%x\n", __func__, return_value);
|
||||
|
||||
return return_value;
|
||||
}
|
||||
|
||||
static uint32_t get_clip_count_reg(ScreamerState *s)
|
||||
{
|
||||
DPRINTF("%s() called - returned 0x%x\n", __func__, s->clip_count);
|
||||
uint32_t return_value;
|
||||
return_value = s->clip_count;
|
||||
/* This is reset everytime it is read */
|
||||
s->clip_count = 0;
|
||||
return return_value;
|
||||
}
|
||||
|
||||
static uint32_t get_byte_swap_reg(ScreamerState *s)
|
||||
{
|
||||
DPRINTF("%s() called - returned 0x%x\n", __func__, s->byte_swap);
|
||||
/*
|
||||
* If all you hear is noise, it could be this register reporting the
|
||||
* wrong value.
|
||||
*/
|
||||
return s->byte_swap ? 0 : 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the frame (sample) count
|
||||
*/
|
||||
static uint32_t get_frame_count_reg(ScreamerState *s)
|
||||
{
|
||||
DPRINTF("%s() called - returned 0x%x\n", __func__, s->frame_count);
|
||||
return s->frame_count;
|
||||
}
|
||||
|
||||
static uint8_t get_left_vol(uint32_t value)
|
||||
{
|
||||
return value & 0xf;
|
||||
}
|
||||
|
||||
static uint8_t get_right_vol(uint32_t value)
|
||||
{
|
||||
return value & 0x3c0 >> 6;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the sampling rate.
|
||||
* If the audio is playing back too fast or too slow, this function may be the
|
||||
* cause.
|
||||
*/
|
||||
static int get_sampling_rate(ScreamerState *s)
|
||||
{
|
||||
uint32_t screamer_rate = s->sound_control & 0x700;
|
||||
int return_value;
|
||||
|
||||
/* All return values are in Hertz */
|
||||
switch (screamer_rate) {
|
||||
case 0x0:
|
||||
return_value = 44100;
|
||||
break;
|
||||
case 0x100:
|
||||
return_value = 29400;
|
||||
break;
|
||||
case 0x200:
|
||||
return_value = 22050;
|
||||
break;
|
||||
case 0x300:
|
||||
return_value = 17640;
|
||||
break;
|
||||
case 0x400:
|
||||
return_value = 14700;
|
||||
break;
|
||||
case 0x500:
|
||||
return_value = 11025;
|
||||
break;
|
||||
case 0x600:
|
||||
return_value = 8820;
|
||||
break;
|
||||
case 0x700:
|
||||
return_value = 7350;
|
||||
break;
|
||||
default:
|
||||
DPRINTF("get_sampling_rate() unknown value: 0x%x\nDefaulting to"
|
||||
" 44100 Hz.\n", screamer_rate);
|
||||
return 44100;
|
||||
}
|
||||
DPRINTF("%s() called - returning %dHz\n", __func__, return_value);
|
||||
return return_value;
|
||||
}
|
||||
|
||||
/**************************** End of getters *************************/
|
||||
|
||||
/***************************** Speaker call back *************************/
|
||||
|
||||
/* resets the play and buffer position markers */
|
||||
static void reset_markers(ScreamerState *s)
|
||||
{
|
||||
s->spk_play_position = 0;
|
||||
s->spk_buffer_position = 0;
|
||||
}
|
||||
|
||||
|
||||
/* Sends the samples to the host for playing */
|
||||
static void send_samples_to_host(ScreamerState *s, int max_samples)
|
||||
{
|
||||
int write_length, requested_length;
|
||||
requested_length = MIN(max_samples, (s->spk_buffer_position -
|
||||
s->spk_play_position));
|
||||
write_length = AUD_write(s->speaker_voice,
|
||||
&s->spk_buffer[s->spk_play_position],
|
||||
requested_length);
|
||||
DPRINTF("requested length: %d\twrite length: %d\t",
|
||||
requested_length, write_length);
|
||||
s->spk_play_position += write_length;
|
||||
DPRINTF("AUD_write %d/%d\n", s->spk_play_position, s->spk_buffer_position);
|
||||
s->frame_count += write_length;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Called by QEMU's audio system to tell the output backend to send samples
|
||||
* from the buffer to the host sound system.
|
||||
* opaque: a pointer to the ScreamerState instance.
|
||||
* max_samples: the number of samples that can be sent to the hardware buffer.
|
||||
*/
|
||||
static void speaker_callback(void *opaque, int max_samples)
|
||||
{
|
||||
ScreamerState *s = (ScreamerState *) opaque;
|
||||
|
||||
/* if we have more samples to play */
|
||||
if (s->spk_buffer_position > 0) {
|
||||
if (s->spk_buffer_position > s->spk_play_position) {
|
||||
DPRINTF("%s() called - max_samples: %d\n", __func__, max_samples);
|
||||
send_samples_to_host(s, max_samples);
|
||||
}
|
||||
if (s->spk_play_position >= s->spk_buffer_position) {
|
||||
DPRINTF("done playing buffer\n");
|
||||
DPRINTF("pp: %d\tbp: %d\n", s->spk_play_position,
|
||||
s->spk_buffer_position);
|
||||
if (s->spk_play_position > s->spk_buffer_position) {
|
||||
DPRINTF("Error detected! - pp > bp\n\a");
|
||||
}
|
||||
reset_markers(s);
|
||||
/* play postponed samples */
|
||||
if (s->dma_io.len > 0) {
|
||||
DPRINTF("playing postponed samples\n");
|
||||
add_to_speaker_buffer(&s->dma_io);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/************************* End of speaker call back *************************/
|
||||
|
||||
|
||||
/* Opens the speaker's voice */
|
||||
static void open_speaker_voice(ScreamerState *s)
|
||||
{
|
||||
DPRINTF("%s() called\n", __func__);
|
||||
|
||||
/* if voice is already open return from function */
|
||||
if (s->speaker_voice != NULL) {
|
||||
DPRINTF("closing speaker voice\n");
|
||||
AUD_close_out(&s->card, s->speaker_voice);
|
||||
s->speaker_voice = NULL;
|
||||
}
|
||||
struct audsettings audio_settings;
|
||||
audio_settings.freq = get_sampling_rate(s); /* in hertz */
|
||||
audio_settings.nchannels = 2; /* stereo output */
|
||||
audio_settings.fmt = AUDIO_FORMAT_S16; /* signed 16 bit */
|
||||
audio_settings.endianness = get_byte_swap_reg(s); /* endianness */
|
||||
s->speaker_voice = AUD_open_out(&s->card, s->speaker_voice, SOUND_CHIP_NAME
|
||||
" speaker", s, speaker_callback,
|
||||
&audio_settings);
|
||||
if (!s->speaker_voice) {
|
||||
AUD_log(SOUND_CHIP_NAME, "Out voice could not be opened\n");
|
||||
} else {
|
||||
AUD_set_active_out(s->speaker_voice, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/******************************* Setters *************************************/
|
||||
|
||||
|
||||
/* Updates QEMU's audio backend settings */
|
||||
static void set_QEMU_audio_settings(ScreamerState *s)
|
||||
{
|
||||
DPRINTF("%s() called\n", __func__);
|
||||
open_speaker_voice(s);
|
||||
}
|
||||
|
||||
|
||||
/* Return value: 1 = muted 0 = not muted */
|
||||
static int is_muted(ScreamerState *s)
|
||||
{
|
||||
int mute_state = s->awacs[1] & SPEAKER_MUTE ? 1 : 0;
|
||||
if (s->awacs[1] & SPEAKER_MUTE) {
|
||||
DPRINTF("speaker is muted\n");
|
||||
} else {
|
||||
DPRINTF("speaker is unmuted\n");
|
||||
}
|
||||
|
||||
if (s->awacs[1] & HEADPHONE_MUTE) {
|
||||
DPRINTF("headphone is muted\n");
|
||||
} else {
|
||||
DPRINTF("headphone is unmuted\n");
|
||||
}
|
||||
return mute_state;
|
||||
}
|
||||
|
||||
|
||||
/* Converts Screamer's volume system to QEMU's system */
|
||||
static int screamer_to_qemu_volume(int x)
|
||||
{
|
||||
return -16 * x + 240;
|
||||
}
|
||||
|
||||
|
||||
/* Sets QEMU's volume. */
|
||||
static void set_volume(ScreamerState *s)
|
||||
{
|
||||
int should_mute = is_muted(s);
|
||||
|
||||
/* Get Screamer volume values */
|
||||
uint8_t left_vol = get_left_vol(s->awacs[4]);
|
||||
uint8_t right_vol = get_right_vol(s->awacs[4]);
|
||||
DPRINTF("set_volume() called - M:%d\tL:%d\tR:%d\n", should_mute, left_vol,
|
||||
right_vol);
|
||||
|
||||
/* Convert Screamer to QEMU volume values */
|
||||
left_vol = screamer_to_qemu_volume(left_vol);
|
||||
right_vol = screamer_to_qemu_volume(right_vol);
|
||||
DPRINTF("QEMU volume: L:%d\tR:%d\n", left_vol, right_vol);
|
||||
AUD_set_volume_out(s->speaker_voice, should_mute, left_vol, right_vol);
|
||||
}
|
||||
|
||||
|
||||
/* Sets the sound control register */
|
||||
static void set_sound_control_reg(ScreamerState *s, uint32_t value)
|
||||
{
|
||||
DPRINTF("set_sound_control_reg() called - value: 0x%x\n", value);
|
||||
s->sound_control = value;
|
||||
set_QEMU_audio_settings(s);
|
||||
}
|
||||
|
||||
|
||||
/* Used for input gain only - can be ignored for now. */
|
||||
static void set_awacs_0_reg(ScreamerState *s, uint32_t new_value)
|
||||
{
|
||||
DPRINTF("Settings AWACS register 0 to 0x%x\n", s->awacs[0]);
|
||||
s->awacs[0] = new_value;
|
||||
}
|
||||
|
||||
|
||||
static void set_awacs_1_reg(ScreamerState *s, uint32_t new_value)
|
||||
{
|
||||
DPRINTF("Settings AWACS register 1 to 0x%x\n", new_value);
|
||||
|
||||
s->awacs[1] = new_value;
|
||||
|
||||
/* If recalibration requested */
|
||||
if (new_value & RECALIBRATE) {
|
||||
DPRINTF("Recalibration requested - unimplemented\n");
|
||||
new_value = new_value ^ RECALIBRATE; /* Turn off recalibrate bit */
|
||||
}
|
||||
|
||||
/* If loop thru set - what does this mean? */
|
||||
if (new_value & LOOPTHRU) {
|
||||
DPRINTF("Loopthru enabled - doing nothing\n");
|
||||
}
|
||||
|
||||
/* Set headphone jack mute state */
|
||||
if (new_value & HEADPHONE_MUTE) {
|
||||
DPRINTF("Headphone muted\n");
|
||||
}
|
||||
|
||||
else {
|
||||
DPRINTF("Headphone unmuted\n");
|
||||
}
|
||||
|
||||
if (new_value & SPEAKER_MUTE) {
|
||||
DPRINTF("Speaker muted\n");
|
||||
}
|
||||
|
||||
else {
|
||||
DPRINTF("Speaker unmuted\n");
|
||||
}
|
||||
|
||||
if (new_value & OUTPUT_ZERO) {
|
||||
DPRINTF("output zero set - not sure what this means\n");
|
||||
}
|
||||
|
||||
if (new_value & OUTPUT_ONE) {
|
||||
DPRINTF("output one set - not sure what this means\n");
|
||||
}
|
||||
|
||||
if (new_value & PARALLEL_OUTPUT) {
|
||||
DPRINTF("parallel port enabled - but no parallel port here\n");
|
||||
}
|
||||
|
||||
set_volume(s);
|
||||
}
|
||||
|
||||
|
||||
/* This is used for headphone volume - not needed */
|
||||
static void set_awacs_2_reg(ScreamerState *s, uint32_t new_value)
|
||||
{
|
||||
DPRINTF("Settings AWACS register 2 to 0x%x\n"
|
||||
"Ignoring change in headphone volume.\n", s->awacs[2]);
|
||||
s->awacs[2] = new_value;
|
||||
}
|
||||
|
||||
|
||||
/* Unknown register purpose */
|
||||
static void set_awacs_3_reg(ScreamerState *s, uint32_t new_value)
|
||||
{
|
||||
DPRINTF("Settings AWACS register 3 to 0x%x\n"
|
||||
"This register has an unknown purpose and does not do anything\n",
|
||||
s->awacs[3]);
|
||||
s->awacs[3] = new_value;
|
||||
}
|
||||
|
||||
|
||||
/* Mostly deals with speaker volume */
|
||||
static void set_awacs_4_reg(ScreamerState *s, uint32_t new_value)
|
||||
{
|
||||
DPRINTF("AWACS register 4 write: 0x%x\n", new_value);
|
||||
s->awacs[4] = new_value;
|
||||
set_volume(s);
|
||||
}
|
||||
|
||||
|
||||
/* This register is about loop thru stuff I don't understand */
|
||||
static void set_awacs_5_reg(ScreamerState *s, uint32_t new_value)
|
||||
{
|
||||
DPRINTF("Settings AWACS register 5 to 0x%x\n"
|
||||
"Loop thru update ignored.\n", s->awacs[5]);
|
||||
s->awacs[5] = new_value;
|
||||
}
|
||||
|
||||
|
||||
/* Prints the states of the AWACS power register */
|
||||
static void print_power_reg_values(uint32_t value)
|
||||
{
|
||||
if ((value & 0x3) == 0) {
|
||||
printf("Screamer run state set\n");
|
||||
}
|
||||
if ((value & 0x3) == 1) {
|
||||
printf("Screamer doze state set\n");
|
||||
}
|
||||
if ((value & 0x3) == 2) {
|
||||
printf("Screamer idle state set\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Power Magement register */
|
||||
static void set_awacs_6_reg(ScreamerState *s, uint32_t new_value)
|
||||
{
|
||||
DPRINTF("Settings AWACS register 6 to 0x%x\n"
|
||||
"Power management update ignored.\n", s->awacs[6]);
|
||||
if (DEBUG_SCREAMER) {
|
||||
print_power_reg_values(new_value);
|
||||
}
|
||||
s->awacs[6] = new_value;
|
||||
}
|
||||
|
||||
|
||||
/* Read Back - repeating something that was sent to this chip? */
|
||||
static void set_awacs_7_reg(ScreamerState *s, uint32_t new_value)
|
||||
{
|
||||
DPRINTF("Settings AWACS register 7 to 0x%x\n", new_value);
|
||||
s->awacs[7] = new_value;
|
||||
}
|
||||
|
||||
|
||||
/* Sets the AWACs registers - a.k.a. shadow registers */
|
||||
static void set_awacs_register(ScreamerState *s, uint32_t value)
|
||||
{
|
||||
int the_register = get_codec_control_address(value);
|
||||
|
||||
switch (the_register) {
|
||||
case 0:
|
||||
set_awacs_0_reg(s, value);
|
||||
break;
|
||||
case 1:
|
||||
set_awacs_1_reg(s, value);
|
||||
break;
|
||||
case 2:
|
||||
set_awacs_2_reg(s, value);
|
||||
break;
|
||||
case 3:
|
||||
set_awacs_3_reg(s, value);
|
||||
break;
|
||||
case 4:
|
||||
set_awacs_4_reg(s, value);
|
||||
break;
|
||||
case 5:
|
||||
set_awacs_5_reg(s, value);
|
||||
break;
|
||||
case 6:
|
||||
set_awacs_6_reg(s, value);
|
||||
break;
|
||||
case 7:
|
||||
set_awacs_7_reg(s, value);
|
||||
break;
|
||||
default:
|
||||
DPRINTF("Unhandled awacs registers %d\n", the_register);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Used to set the AWACS registers */
|
||||
static void set_codec_control_reg(ScreamerState *s, uint32_t value)
|
||||
{
|
||||
DPRINTF("set_codec_control_reg() called - value: 0x%x\n", value);
|
||||
s->codec_control = value;
|
||||
set_awacs_register(s, value);
|
||||
}
|
||||
|
||||
static void set_codec_status_reg(ScreamerState *s, uint32_t value)
|
||||
{
|
||||
DPRINTF("set_codec_status_reg() called - value: 0x%x\n", value);
|
||||
s->codec_status = value;
|
||||
}
|
||||
|
||||
static void set_clip_count_reg(ScreamerState *s, uint32_t new_value)
|
||||
{
|
||||
DPRINTF("set_clip_count_reg() called - value: 0x%x\n", new_value);
|
||||
s->clip_count = new_value;
|
||||
}
|
||||
|
||||
static void set_byte_swap_reg(ScreamerState *s, uint32_t value)
|
||||
{
|
||||
DPRINTF("set_byte_swap_reg() called - value: 0x%x\n", value);
|
||||
s->byte_swap = value;
|
||||
}
|
||||
|
||||
static void set_frame_count_reg(ScreamerState *s, uint32_t new_value)
|
||||
{
|
||||
DPRINTF("%s() called - value: 0x%x\n", __func__, new_value);
|
||||
s->frame_count = new_value;
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the busy bit of codec control register.
|
||||
* It is used to tell the CPU to wait.
|
||||
* value: the codec control register's value
|
||||
* bit_value: used to set or disable the busy bit
|
||||
*/
|
||||
static uint32_t set_busy_bit(uint32_t value, int bit_value)
|
||||
{
|
||||
const int busy_bit = 0x01000000;
|
||||
uint32_t return_value;
|
||||
if (bit_value == 1) /* Set this bit */
|
||||
return_value = (value | busy_bit);
|
||||
else /* bit_value == 0 Disable this bit */
|
||||
return_value = (value & ~busy_bit);
|
||||
return return_value;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Sets the part ready bit of the codec status register
|
||||
* value: the codec status register's value
|
||||
* bit_value: used to set or disable the part ready bit
|
||||
*/
|
||||
static uint32_t set_part_ready_bit(uint32_t value, int bit_value)
|
||||
{
|
||||
const int part_ready_bit = 0x00400000;
|
||||
uint32_t return_value;
|
||||
if (bit_value == 1) /* Set this bit */
|
||||
return_value = (value | part_ready_bit);
|
||||
else /* bit_value == 0 Disable this bit */
|
||||
return_value = (value & ~part_ready_bit);
|
||||
return return_value;
|
||||
}
|
||||
|
||||
/* Sets bits 12 and 13 to 1 to indicate the Screamer revision */
|
||||
static uint32_t set_revision(uint32_t input_value)
|
||||
{
|
||||
uint32_t return_value;
|
||||
return_value = input_value | 0x3000;
|
||||
return return_value;
|
||||
}
|
||||
|
||||
/* Sets bit 8 to indicate Crystal as the manufacturer */
|
||||
static uint32_t set_manufacturer(uint32_t input_value)
|
||||
{
|
||||
uint32_t return_value;
|
||||
return_value = input_value | 0x100;
|
||||
return return_value;
|
||||
}
|
||||
|
||||
|
||||
/************************** End of Setters *********************************/
|
||||
|
||||
|
||||
/*************************** DMA functions *********************************/
|
||||
|
||||
/*
|
||||
* Sends audio samples from a microphone or line-in to memory.
|
||||
* Used for sound input.
|
||||
* Currently only prevents a deadlock condition with Mac OS 9.
|
||||
*/
|
||||
static void screamer_to_dma(DBDMA_io *io)
|
||||
{
|
||||
DPRINTF("%s() called\n", __func__);
|
||||
ScreamerState *s = (ScreamerState *)io->opaque;
|
||||
DBDMAState *dbs = s->dbdma;
|
||||
DBDMA_channel *ch = &dbs->channels[0x12];
|
||||
ch->regs[DBDMA_STATUS] |= DEAD;
|
||||
ch->regs[DBDMA_STATUS] &= ~ACTIVE;
|
||||
io->dma_end(io);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
static void print_dma_info(DBDMA_io *io)
|
||||
{
|
||||
#define RUN 0x8000
|
||||
#define PAUSE 0x4000
|
||||
#define FLUSH 0x2000
|
||||
#define WAKE 0x1000
|
||||
#define DEAD 0x0800
|
||||
#define ACTIVE 0x0400
|
||||
#define BT 0x0100
|
||||
#define DEVSTAT 0x00ff
|
||||
|
||||
/*
|
||||
* RUN and PAUSE are bits under software control only.
|
||||
* FLUSH and WAKE are set by SW and cleared by hardware.
|
||||
* DEAD, ACTIVE and BT are only under hardware control.
|
||||
*/
|
||||
|
||||
DBDMA_channel *ch = io->channel;
|
||||
printf("DMA FLAGS: ");
|
||||
|
||||
if (ch->regs[DBDMA_STATUS] & RUN) {
|
||||
printf("RUN ");
|
||||
}
|
||||
|
||||
if (ch->regs[DBDMA_STATUS] & ACTIVE) {
|
||||
printf("ACTIVE ");
|
||||
}
|
||||
|
||||
if (ch->regs[DBDMA_STATUS] & PAUSE) {
|
||||
printf("PAUSE ");
|
||||
}
|
||||
|
||||
if (ch->regs[DBDMA_STATUS] & DEAD) {
|
||||
printf("DEAD ");
|
||||
}
|
||||
|
||||
if (ch->regs[DBDMA_STATUS] & WAKE) {
|
||||
printf("WAKE ");
|
||||
}
|
||||
|
||||
if (ch->regs[DBDMA_STATUS] & BT) {
|
||||
printf("BT ");
|
||||
}
|
||||
|
||||
if (ch->regs[DBDMA_STATUS] & DEVSTAT) {
|
||||
printf("DEVSTAT ");
|
||||
}
|
||||
|
||||
if (ch->regs[DBDMA_STATUS] & FLUSH) {
|
||||
printf("FLUSH ");
|
||||
}
|
||||
|
||||
if (ch->io.processing == true) {
|
||||
printf("processing ");
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
/* Tell the DMA controller we request more samples */
|
||||
static void dma_request(DBDMA_io *io)
|
||||
{
|
||||
DPRINTF("%s() called\n", __func__);
|
||||
if (DEBUG_SCREAMER) {
|
||||
print_dma_info(io);
|
||||
}
|
||||
io->len = 0;
|
||||
io->dma_end(io);
|
||||
}
|
||||
|
||||
|
||||
/* Adds sample data to the buffer */
|
||||
static void add_to_speaker_buffer(DBDMA_io *io)
|
||||
{
|
||||
ScreamerState *s = (ScreamerState *) io->opaque;
|
||||
|
||||
if (s->spk_buffer_position + io->len > MAX_BUFFER_SIZE) {
|
||||
/* postpone calling these samples until the buffer has been emptied */
|
||||
memcpy(&s->dma_io, io, sizeof(DBDMA_io));
|
||||
return;
|
||||
}
|
||||
dma_memory_read(&address_space_memory, io->addr,
|
||||
&s->spk_buffer[s->spk_buffer_position], io->len,
|
||||
MEMTXATTRS_UNSPECIFIED);
|
||||
s->spk_buffer_position += io->len;
|
||||
DPRINTF("%s() called - len: %d pos: %d/%d\n", __func__, io->len,
|
||||
s->spk_buffer_position, MAX_BUFFER_SIZE);
|
||||
|
||||
dma_request(io);
|
||||
}
|
||||
|
||||
/*
|
||||
* Called by the DMA chip to transfer samples from memory to the
|
||||
* Screamer chip.
|
||||
* Used for sound output.
|
||||
*/
|
||||
static void dma_to_screamer(DBDMA_io *io)
|
||||
{
|
||||
add_to_speaker_buffer(io);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* This will flush the audio buffer of previous audio - eliminating previous
|
||||
* audio playback.
|
||||
*/
|
||||
static void send_silence_to_speaker(ScreamerState *s)
|
||||
{
|
||||
DPRINTF("Silencing audio buffer...\n");
|
||||
int length = MAX_BUFFER_SIZE;
|
||||
s->spk_buffer_position = length;
|
||||
s->spk_play_position = 0;
|
||||
memset(s->spk_buffer, 0, length);
|
||||
s->dma_io.len = 0; /* stop any postponed samples from playing */
|
||||
}
|
||||
|
||||
|
||||
/* This is called after audio stops playing */
|
||||
static void dma_send_flush(DBDMA_io *io)
|
||||
{
|
||||
DPRINTF("dma_send_flush() called\n");
|
||||
if (DEBUG_SCREAMER) {
|
||||
print_dma_info(io);
|
||||
}
|
||||
ScreamerState *s = (ScreamerState *)io->opaque;
|
||||
reset_markers(s);
|
||||
send_silence_to_speaker(s);
|
||||
if (io->len > 0) {
|
||||
dma_request(io);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void dma_receive_flush(DBDMA_io *io)
|
||||
{
|
||||
DPRINTF("dma_receive_flush() called\n");
|
||||
}
|
||||
|
||||
|
||||
/* Set the functions the DMA system will call */
|
||||
void screamer_register_dma_functions(ScreamerState *s, void *dbdma,
|
||||
int send_channel, int receive_channel)
|
||||
{
|
||||
DPRINTF("%s() called\n", __func__);
|
||||
DPRINTF("send channel: %d\treceive channel: %d\n", send_channel,
|
||||
receive_channel);
|
||||
s->dbdma = dbdma;
|
||||
|
||||
/* Setup the DMA send system */
|
||||
DBDMA_register_channel(s->dbdma, send_channel, s->dma_send_irq,
|
||||
dma_to_screamer, dma_send_flush, s);
|
||||
|
||||
/* Setup the DMA receive system */
|
||||
DBDMA_register_channel(s->dbdma, receive_channel, s->dma_receive_irq,
|
||||
screamer_to_dma, dma_receive_flush, s);
|
||||
}
|
||||
|
||||
/************************* End of DMA functions **************************/
|
||||
|
||||
/* Resets this sound chip */
|
||||
static void screamer_reset(DeviceState *d)
|
||||
{
|
||||
DPRINTF("screamer_reset() called\n");
|
||||
ScreamerState *s = SCREAMER(d);
|
||||
set_sound_control_reg(s, 0);
|
||||
set_codec_control_reg(s, 0);
|
||||
set_codec_status_reg(s, 0);
|
||||
set_clip_count_reg(s, 0);
|
||||
set_byte_swap_reg(s, 0);
|
||||
set_frame_count_reg(s, 0);
|
||||
int i, num_awacs_regs = 8;
|
||||
for (i = 0; i < num_awacs_regs; i++) {
|
||||
s->awacs[i] = 0;
|
||||
}
|
||||
set_QEMU_audio_settings(s);
|
||||
reset_markers(s);
|
||||
s->dma_io.len = 0;
|
||||
}
|
||||
|
||||
/* Called when the CPU reads the memory addresses assigned to Screamer */
|
||||
static uint64_t screamer_mmio_read(void *opaque, hwaddr addr, unsigned size)
|
||||
{
|
||||
ScreamerState *state = opaque;
|
||||
uint32_t return_value;
|
||||
|
||||
addr = addr >> 4;
|
||||
switch (addr) {
|
||||
case SOUND_CONTROL_REG:
|
||||
return_value = get_sound_control_reg(state);
|
||||
break;
|
||||
case CODEC_CONTROL_REG:
|
||||
return_value = get_codec_control_reg(state);
|
||||
break;
|
||||
case CODEC_STATUS_REG:
|
||||
return_value = get_codec_status_reg(state);
|
||||
break;
|
||||
case CLIP_COUNT_REG:
|
||||
return_value = get_clip_count_reg(state);
|
||||
break;
|
||||
case BYTE_SWAP_REG:
|
||||
return_value = get_byte_swap_reg(state);
|
||||
break;
|
||||
case FRAME_COUNT_REG:
|
||||
return_value = get_frame_count_reg(state);
|
||||
break;
|
||||
default:
|
||||
DPRINTF("Unknown register read - addr:%" HWADDR_PRIx "\tsize:%d\n",
|
||||
addr, size);
|
||||
return_value = 12021981; /* Value used for debugging purposes */
|
||||
}
|
||||
DPRINTF("screamer_mmio_read() called addr: %" HWADDR_PRIx " size: %d",
|
||||
addr >> 4, size);
|
||||
DPRINTF(" returning 0x%x\n", return_value);
|
||||
return return_value;
|
||||
}
|
||||
|
||||
|
||||
/* Called when the CPU writes to the memory addresses assigned to Screamer */
|
||||
static void screamer_mmio_write(void *opaque, hwaddr addr, uint64_t raw_value,
|
||||
unsigned size)
|
||||
{
|
||||
DPRINTF("screamer_mmio_write() called - size: %d\n", size);
|
||||
ScreamerState *state = opaque;
|
||||
uint32_t value = raw_value & 0xffffffff;
|
||||
addr = addr >> 4;
|
||||
|
||||
switch (addr) {
|
||||
case SOUND_CONTROL_REG:
|
||||
set_sound_control_reg(state, value);
|
||||
break;
|
||||
case CODEC_CONTROL_REG:
|
||||
set_codec_control_reg(state, value);
|
||||
break;
|
||||
case CODEC_STATUS_REG:
|
||||
set_codec_status_reg(state, value);
|
||||
break;
|
||||
case CLIP_COUNT_REG:
|
||||
set_clip_count_reg(state, value);
|
||||
break;
|
||||
case BYTE_SWAP_REG:
|
||||
set_byte_swap_reg(state, value);
|
||||
break;
|
||||
case FRAME_COUNT_REG:
|
||||
set_frame_count_reg(state, value);
|
||||
break;
|
||||
default:
|
||||
DPRINTF("Unknown register write - addr:%" HWADDR_PRIx "\tvalue:%d\n",
|
||||
addr, value);
|
||||
}
|
||||
}
|
||||
|
||||
/* Used for memory_region_init_io() for memory mapped I/O */
|
||||
static const MemoryRegionOps screamer_ops = {
|
||||
.read = screamer_mmio_read,
|
||||
.write = screamer_mmio_write,
|
||||
.endianness = DEVICE_LITTLE_ENDIAN,
|
||||
.valid = {
|
||||
.min_access_size = 4,
|
||||
.max_access_size = 4
|
||||
}
|
||||
};
|
||||
|
||||
/* Called when the device has become active */
|
||||
static void screamer_realize(DeviceState *dev, Error **errp)
|
||||
{
|
||||
DPRINTF("screamer_realize() called\n");
|
||||
screamer_reset(dev);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Called when an instance of the Screamer device is created.
|
||||
* Also called when this HMP command is called: device_add screamer
|
||||
*/
|
||||
static void screamer_init(Object *obj)
|
||||
{
|
||||
DPRINTF("screamer_init() called\n");
|
||||
|
||||
ScreamerState *s = (ScreamerState *)obj;
|
||||
SysBusDevice *d = SYS_BUS_DEVICE(obj);
|
||||
const int region_size = 5 * 32;
|
||||
|
||||
/* Makes the read and write ops work */
|
||||
memory_region_init_io(&s->io_memory_region, OBJECT(s),
|
||||
&screamer_ops, s, SOUND_CHIP_NAME, region_size);
|
||||
|
||||
/* Sets the SysBusDevice's memory property */
|
||||
sysbus_init_mmio(d, &s->io_memory_region);
|
||||
|
||||
/* Setup all the interrupt requests */
|
||||
sysbus_init_irq(d, &s->irq);
|
||||
sysbus_init_irq(d, &s->dma_send_irq);
|
||||
sysbus_init_irq(d, &s->dma_receive_irq);
|
||||
|
||||
/* Registers Screamer with QEMU's audio system */
|
||||
AUD_register_card(SOUND_CHIP_NAME, &s->card);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* When saving and restoring the state of the VM, this is used to save and
|
||||
* restore the registers.
|
||||
*/
|
||||
static const VMStateDescription vmstate_screamer = {
|
||||
.name = "Screamer",
|
||||
.version_id = 1,
|
||||
.minimum_version_id = 1,
|
||||
.fields = (VMStateField[]) {
|
||||
VMSTATE_UINT16_ARRAY(awacs, ScreamerState, 8), /* 8 AWACS registers */
|
||||
VMSTATE_UINT32(sound_control, ScreamerState),
|
||||
VMSTATE_UINT32(codec_control, ScreamerState),
|
||||
VMSTATE_UINT32(codec_status, ScreamerState),
|
||||
VMSTATE_UINT32(clip_count, ScreamerState),
|
||||
VMSTATE_UINT32(byte_swap, ScreamerState),
|
||||
VMSTATE_UINT32(frame_count, ScreamerState),
|
||||
VMSTATE_END_OF_LIST()
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Sets the class data. It is like polymorphism and inheritance in object
|
||||
* oriented languages.
|
||||
*/
|
||||
static void screamer_class_init(ObjectClass *class, void *data)
|
||||
{
|
||||
DPRINTF("screamer_class_init() called\n");
|
||||
DeviceClass *dc = DEVICE_CLASS(class);
|
||||
dc->realize = screamer_realize;
|
||||
dc->reset = screamer_reset;
|
||||
dc->desc = "Apple Screamer";
|
||||
dc->vmsd = &vmstate_screamer;
|
||||
dc->hotpluggable = false;
|
||||
}
|
||||
|
||||
/* Used for QOM function registration */
|
||||
static const TypeInfo screamer_info = {
|
||||
.name = "screamer",
|
||||
.parent = TYPE_SYS_BUS_DEVICE,
|
||||
.instance_size = sizeof(ScreamerState),
|
||||
.instance_init = screamer_init,
|
||||
.class_init = screamer_class_init,
|
||||
};
|
||||
|
||||
/* QOM registration of above functions for calling */
|
||||
static void screamer_register_types(void)
|
||||
{
|
||||
DPRINTF("screamer_register_types() called\n");
|
||||
type_register_static(&screamer_info);
|
||||
}
|
||||
|
||||
/* QEMU Object Model (QOM) stuff */
|
||||
type_init(screamer_register_types)
|
||||
@@ -763,14 +763,15 @@ static XenBlockDrive *xen_block_drive_create(const char *id,
|
||||
drive = g_new0(XenBlockDrive, 1);
|
||||
drive->id = g_strdup(id);
|
||||
|
||||
file_layer = qdict_new();
|
||||
driver_layer = qdict_new();
|
||||
|
||||
rc = stat(filename, &st);
|
||||
if (rc) {
|
||||
error_setg_errno(errp, errno, "Could not stat file '%s'", filename);
|
||||
goto done;
|
||||
}
|
||||
|
||||
file_layer = qdict_new();
|
||||
driver_layer = qdict_new();
|
||||
|
||||
if (S_ISBLK(st.st_mode)) {
|
||||
qdict_put_str(file_layer, "driver", "host_device");
|
||||
} else {
|
||||
@@ -778,7 +779,6 @@ static XenBlockDrive *xen_block_drive_create(const char *id,
|
||||
}
|
||||
|
||||
qdict_put_str(file_layer, "filename", filename);
|
||||
g_free(filename);
|
||||
|
||||
if (mode && *mode != 'w') {
|
||||
qdict_put_bool(file_layer, "read-only", true);
|
||||
@@ -813,7 +813,6 @@ static XenBlockDrive *xen_block_drive_create(const char *id,
|
||||
qdict_put_str(file_layer, "locking", "off");
|
||||
|
||||
qdict_put_str(driver_layer, "driver", driver);
|
||||
g_free(driver);
|
||||
|
||||
qdict_put(driver_layer, "file", file_layer);
|
||||
|
||||
@@ -824,6 +823,8 @@ static XenBlockDrive *xen_block_drive_create(const char *id,
|
||||
qobject_unref(driver_layer);
|
||||
|
||||
done:
|
||||
g_free(filename);
|
||||
g_free(driver);
|
||||
if (*errp) {
|
||||
xen_block_drive_destroy(drive, NULL);
|
||||
return NULL;
|
||||
|
||||
@@ -493,7 +493,6 @@ static const BindingEntry bindings[] = {
|
||||
#endif
|
||||
#ifdef CONFIG_TPM
|
||||
TYPE_BINDING(TYPE_TPM_TIS_SYSBUS, add_tpm_tis_fdt_node),
|
||||
TYPE_BINDING(TYPE_TPM_CRB_SYSBUS, add_tpm_tis_fdt_node),
|
||||
#endif
|
||||
TYPE_BINDING(TYPE_RAMFB_DEVICE, no_fdt_node),
|
||||
TYPE_BINDING("", NULL), /* last element */
|
||||
|
||||
@@ -81,16 +81,6 @@ if config_all_devices.has_key('CONFIG_VIRTIO_GPU')
|
||||
endif
|
||||
endif
|
||||
|
||||
if config_all_devices.has_key('CONFIG_FW_CFG_DMA')
|
||||
virtio_ramfb_ss = ss.source_set()
|
||||
virtio_ramfb_ss.add(when: 'CONFIG_FW_CFG_DMA', if_true: files('virtio-ramfb.c'))
|
||||
hw_display_modules += {'virtio-ramfb': virtio_ramfb_ss}
|
||||
virtio_ramfb_gl_ss = ss.source_set()
|
||||
virtio_ramfb_gl_ss.add(when: ['CONFIG_FW_CFG_DMA', virgl, opengl],
|
||||
if_true: files('virtio-ramfb-gl.c'))
|
||||
hw_display_modules += {'virtio-ramfb-gl': virtio_ramfb_gl_ss}
|
||||
endif
|
||||
|
||||
if config_all_devices.has_key('CONFIG_VIRTIO_PCI')
|
||||
virtio_gpu_pci_ss = ss.source_set()
|
||||
virtio_gpu_pci_ss.add(when: ['CONFIG_VIRTIO_GPU', 'CONFIG_VIRTIO_PCI'],
|
||||
|
||||
@@ -141,39 +141,12 @@ static void virgl_cmd_resource_flush(VirtIOGPU *g,
|
||||
}
|
||||
}
|
||||
|
||||
static GLuint virgl_borrow_texture_for_scanout(uint32_t id, bool *y_0_top,
|
||||
uint32_t *width,
|
||||
uint32_t *height)
|
||||
{
|
||||
struct virgl_renderer_texture_info info;
|
||||
int ret;
|
||||
|
||||
memset(&info, 0, sizeof(info));
|
||||
|
||||
ret = virgl_renderer_borrow_texture_for_scanout(id, &info);
|
||||
if (ret == -1) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (y_0_top) {
|
||||
*y_0_top = info.flags & VIRTIO_GPU_RESOURCE_FLAG_Y_0_TOP;
|
||||
}
|
||||
|
||||
if (width) {
|
||||
*width = info.width;
|
||||
}
|
||||
|
||||
if (height) {
|
||||
*height = info.height;
|
||||
}
|
||||
|
||||
return info.tex_id;
|
||||
}
|
||||
|
||||
static void virgl_cmd_set_scanout(VirtIOGPU *g,
|
||||
struct virtio_gpu_ctrl_command *cmd)
|
||||
{
|
||||
struct virtio_gpu_set_scanout ss;
|
||||
struct virgl_renderer_resource_info info;
|
||||
int ret;
|
||||
|
||||
VIRTIO_GPU_FILL_CMD(ss);
|
||||
trace_virtio_gpu_cmd_set_scanout(ss.scanout_id, ss.resource_id,
|
||||
@@ -187,13 +160,24 @@ static void virgl_cmd_set_scanout(VirtIOGPU *g,
|
||||
}
|
||||
g->parent_obj.enable = 1;
|
||||
|
||||
memset(&info, 0, sizeof(info));
|
||||
|
||||
if (ss.resource_id && ss.r.width && ss.r.height) {
|
||||
ret = virgl_renderer_resource_get_info(ss.resource_id, &info);
|
||||
if (ret == -1) {
|
||||
qemu_log_mask(LOG_GUEST_ERROR,
|
||||
"%s: illegal resource specified %d\n",
|
||||
__func__, ss.resource_id);
|
||||
cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID;
|
||||
return;
|
||||
}
|
||||
qemu_console_resize(g->parent_obj.scanout[ss.scanout_id].con,
|
||||
ss.r.width, ss.r.height);
|
||||
virgl_renderer_force_ctx_0();
|
||||
dpy_gl_scanout_texture(
|
||||
g->parent_obj.scanout[ss.scanout_id].con, ss.resource_id,
|
||||
virgl_borrow_texture_for_scanout,
|
||||
g->parent_obj.scanout[ss.scanout_id].con, info.tex_id,
|
||||
info.flags & VIRTIO_GPU_RESOURCE_FLAG_Y_0_TOP,
|
||||
info.width, info.height,
|
||||
ss.r.x, ss.r.y, ss.r.width, ss.r.height);
|
||||
} else {
|
||||
dpy_gfx_replace_surface(
|
||||
|
||||
+22
-5
@@ -498,6 +498,8 @@ static void virtio_gpu_resource_flush(VirtIOGPU *g,
|
||||
struct virtio_gpu_resource_flush rf;
|
||||
struct virtio_gpu_scanout *scanout;
|
||||
pixman_region16_t flush_region;
|
||||
bool within_bounds = false;
|
||||
bool update_submitted = false;
|
||||
int i;
|
||||
|
||||
VIRTIO_GPU_FILL_CMD(rf);
|
||||
@@ -518,13 +520,28 @@ static void virtio_gpu_resource_flush(VirtIOGPU *g,
|
||||
rf.r.x < scanout->x + scanout->width &&
|
||||
rf.r.x + rf.r.width >= scanout->x &&
|
||||
rf.r.y < scanout->y + scanout->height &&
|
||||
rf.r.y + rf.r.height >= scanout->y &&
|
||||
console_has_gl(scanout->con)) {
|
||||
dpy_gl_update(scanout->con, 0, 0, scanout->width,
|
||||
scanout->height);
|
||||
rf.r.y + rf.r.height >= scanout->y) {
|
||||
within_bounds = true;
|
||||
|
||||
if (console_has_gl(scanout->con)) {
|
||||
dpy_gl_update(scanout->con, 0, 0, scanout->width,
|
||||
scanout->height);
|
||||
update_submitted = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
||||
if (update_submitted) {
|
||||
return;
|
||||
}
|
||||
if (!within_bounds) {
|
||||
qemu_log_mask(LOG_GUEST_ERROR, "%s: flush bounds outside scanouts"
|
||||
" bounds for flush %d: %d %d %d %d\n",
|
||||
__func__, rf.resource_id, rf.r.x, rf.r.y,
|
||||
rf.r.width, rf.r.height);
|
||||
cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_PARAMETER;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!res->blob &&
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
#include "qemu/osdep.h"
|
||||
#include "hw/pci/pci.h"
|
||||
#include "hw/qdev-properties.h"
|
||||
#include "hw/virtio/virtio-gpu.h"
|
||||
#include "hw/display/vga.h"
|
||||
#include "qapi/error.h"
|
||||
#include "qemu/module.h"
|
||||
#include "virtio-ramfb.h"
|
||||
#include "qom/object.h"
|
||||
|
||||
#define TYPE_VIRTIO_RAMFB_GL "virtio-ramfb-gl"
|
||||
|
||||
typedef struct VirtIORAMFBGL VirtIORAMFBGL;
|
||||
DECLARE_INSTANCE_CHECKER(VirtIORAMFBGL, VIRTIO_RAMFB_GL,
|
||||
TYPE_VIRTIO_RAMFB_GL)
|
||||
|
||||
struct VirtIORAMFBGL {
|
||||
VirtIORAMFBBase parent_obj;
|
||||
|
||||
VirtIOGPUGL vdev;
|
||||
};
|
||||
|
||||
static void virtio_ramfb_gl_inst_initfn(Object *obj)
|
||||
{
|
||||
VirtIORAMFBGL *dev = VIRTIO_RAMFB_GL(obj);
|
||||
|
||||
virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
|
||||
TYPE_VIRTIO_GPU_GL);
|
||||
VIRTIO_RAMFB_BASE(dev)->vgpu = VIRTIO_GPU_BASE(&dev->vdev);
|
||||
}
|
||||
|
||||
|
||||
static VirtioPCIDeviceTypeInfo virtio_ramfb_gl_info = {
|
||||
.generic_name = TYPE_VIRTIO_RAMFB_GL,
|
||||
.parent = TYPE_VIRTIO_RAMFB_BASE,
|
||||
.instance_size = sizeof(VirtIORAMFBGL),
|
||||
.instance_init = virtio_ramfb_gl_inst_initfn,
|
||||
};
|
||||
module_obj(TYPE_VIRTIO_RAMFB_GL);
|
||||
|
||||
static void virtio_ramfb_register_types(void)
|
||||
{
|
||||
if (have_vga) {
|
||||
virtio_pci_types_register(&virtio_ramfb_gl_info);
|
||||
}
|
||||
}
|
||||
|
||||
type_init(virtio_ramfb_register_types)
|
||||
|
||||
module_dep("hw-display-virtio-ramfb");
|
||||
@@ -1,191 +0,0 @@
|
||||
#include "qemu/osdep.h"
|
||||
#include "sysemu/sysemu.h"
|
||||
#include "hw/pci/pci.h"
|
||||
#include "ui/console.h"
|
||||
#include "hw/qdev-properties.h"
|
||||
#include "virtio-ramfb.h"
|
||||
#include "qapi/error.h"
|
||||
#include "qom/object.h"
|
||||
|
||||
static int virtio_ramfb_get_flags(void *opaque)
|
||||
{
|
||||
VirtIORAMFBBase *vramfb = opaque;
|
||||
VirtIOGPUBase *g = vramfb->vgpu;
|
||||
|
||||
if (g->hw_ops->get_flags) {
|
||||
return g->hw_ops->get_flags(g);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void virtio_ramfb_invalidate_display(void *opaque)
|
||||
{
|
||||
VirtIORAMFBBase *vramfb = opaque;
|
||||
VirtIOGPUBase *g = vramfb->vgpu;
|
||||
|
||||
if (g->enable) {
|
||||
g->hw_ops->invalidate(g);
|
||||
}
|
||||
}
|
||||
|
||||
static void virtio_ramfb_text_update(void *opaque, console_ch_t *chardata)
|
||||
{
|
||||
VirtIORAMFBBase *vramfb = opaque;
|
||||
VirtIOGPUBase *g = vramfb->vgpu;
|
||||
|
||||
if (g->hw_ops->text_update) {
|
||||
g->hw_ops->text_update(g, chardata);
|
||||
}
|
||||
}
|
||||
|
||||
static void virtio_ramfb_update_display(void *opaque)
|
||||
{
|
||||
VirtIORAMFBBase *vramfb = opaque;
|
||||
VirtIOGPUBase *g = vramfb->vgpu;
|
||||
|
||||
if (g->enable) {
|
||||
g->hw_ops->gfx_update(g);
|
||||
} else {
|
||||
ramfb_display_update(g->scanout[0].con, vramfb->ramfb);
|
||||
}
|
||||
}
|
||||
|
||||
static void virtio_ramfb_ui_info(void *opaque, uint32_t idx, QemuUIInfo *info)
|
||||
{
|
||||
VirtIORAMFBBase *vramfb = opaque;
|
||||
VirtIOGPUBase *g = vramfb->vgpu;
|
||||
|
||||
if (g->hw_ops->ui_info) {
|
||||
g->hw_ops->ui_info(g, idx, info);
|
||||
}
|
||||
}
|
||||
|
||||
static void virtio_ramfb_gl_block(void *opaque, bool block)
|
||||
{
|
||||
VirtIORAMFBBase *vramfb = opaque;
|
||||
VirtIOGPUBase *g = vramfb->vgpu;
|
||||
|
||||
if (g->hw_ops->gl_block) {
|
||||
g->hw_ops->gl_block(g, block);
|
||||
}
|
||||
}
|
||||
|
||||
static const GraphicHwOps virtio_ramfb_ops = {
|
||||
.get_flags = virtio_ramfb_get_flags,
|
||||
.invalidate = virtio_ramfb_invalidate_display,
|
||||
.gfx_update = virtio_ramfb_update_display,
|
||||
.text_update = virtio_ramfb_text_update,
|
||||
.ui_info = virtio_ramfb_ui_info,
|
||||
.gl_block = virtio_ramfb_gl_block,
|
||||
};
|
||||
|
||||
static const VMStateDescription vmstate_virtio_ramfb = {
|
||||
.name = "virtio-ramfb",
|
||||
.version_id = 2,
|
||||
.minimum_version_id = 2,
|
||||
.fields = (VMStateField[]) {
|
||||
/* no pci stuff here, saving the virtio device will handle that */
|
||||
/* FIXME */
|
||||
VMSTATE_END_OF_LIST()
|
||||
}
|
||||
};
|
||||
|
||||
/* RAMFB device wrapper around PCI device around virtio GPU */
|
||||
static void virtio_ramfb_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
|
||||
{
|
||||
VirtIORAMFBBase *vramfb = VIRTIO_RAMFB_BASE(vpci_dev);
|
||||
VirtIOGPUBase *g = vramfb->vgpu;
|
||||
int i;
|
||||
|
||||
/* init virtio bits */
|
||||
virtio_pci_force_virtio_1(vpci_dev);
|
||||
if (!qdev_realize(DEVICE(g), BUS(&vpci_dev->bus), errp)) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* init ramfb */
|
||||
vramfb->ramfb = ramfb_setup(errp);
|
||||
graphic_console_set_hwops(g->scanout[0].con, &virtio_ramfb_ops, vramfb);
|
||||
|
||||
for (i = 0; i < g->conf.max_outputs; i++) {
|
||||
object_property_set_link(OBJECT(g->scanout[i].con), "device",
|
||||
OBJECT(vpci_dev), &error_abort);
|
||||
}
|
||||
}
|
||||
|
||||
static void virtio_ramfb_reset(DeviceState *dev)
|
||||
{
|
||||
VirtIORAMFBBaseClass *klass = VIRTIO_RAMFB_BASE_GET_CLASS(dev);
|
||||
|
||||
/* reset virtio-gpu */
|
||||
klass->parent_reset(dev);
|
||||
}
|
||||
|
||||
static Property virtio_ramfb_base_properties[] = {
|
||||
DEFINE_VIRTIO_GPU_PCI_PROPERTIES(VirtIOPCIProxy),
|
||||
DEFINE_PROP_END_OF_LIST(),
|
||||
};
|
||||
|
||||
static void virtio_ramfb_base_class_init(ObjectClass *klass, void *data)
|
||||
{
|
||||
DeviceClass *dc = DEVICE_CLASS(klass);
|
||||
VirtioPCIClass *k = VIRTIO_PCI_CLASS(klass);
|
||||
VirtIORAMFBBaseClass *v = VIRTIO_RAMFB_BASE_CLASS(klass);
|
||||
PCIDeviceClass *pcidev_k = PCI_DEVICE_CLASS(klass);
|
||||
|
||||
set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories);
|
||||
device_class_set_props(dc, virtio_ramfb_base_properties);
|
||||
dc->vmsd = &vmstate_virtio_ramfb;
|
||||
dc->hotpluggable = false;
|
||||
device_class_set_parent_reset(dc, virtio_ramfb_reset,
|
||||
&v->parent_reset);
|
||||
|
||||
k->realize = virtio_ramfb_realize;
|
||||
pcidev_k->class_id = PCI_CLASS_DISPLAY_VGA;
|
||||
}
|
||||
|
||||
static const TypeInfo virtio_ramfb_base_info = {
|
||||
.name = TYPE_VIRTIO_RAMFB_BASE,
|
||||
.parent = TYPE_VIRTIO_PCI,
|
||||
.instance_size = sizeof(VirtIORAMFBBase),
|
||||
.class_size = sizeof(VirtIORAMFBBaseClass),
|
||||
.class_init = virtio_ramfb_base_class_init,
|
||||
.abstract = true,
|
||||
};
|
||||
|
||||
#define TYPE_VIRTIO_RAMFB "virtio-ramfb"
|
||||
|
||||
typedef struct VirtIORAMFB VirtIORAMFB;
|
||||
DECLARE_INSTANCE_CHECKER(VirtIORAMFB, VIRTIO_RAMFB,
|
||||
TYPE_VIRTIO_RAMFB)
|
||||
|
||||
struct VirtIORAMFB {
|
||||
VirtIORAMFBBase parent_obj;
|
||||
|
||||
VirtIOGPU vdev;
|
||||
};
|
||||
|
||||
static void virtio_ramfb_inst_initfn(Object *obj)
|
||||
{
|
||||
VirtIORAMFB *dev = VIRTIO_RAMFB(obj);
|
||||
|
||||
virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
|
||||
TYPE_VIRTIO_GPU);
|
||||
VIRTIO_RAMFB_BASE(dev)->vgpu = VIRTIO_GPU_BASE(&dev->vdev);
|
||||
}
|
||||
|
||||
static VirtioPCIDeviceTypeInfo virtio_ramfb_info = {
|
||||
.generic_name = TYPE_VIRTIO_RAMFB,
|
||||
.parent = TYPE_VIRTIO_RAMFB_BASE,
|
||||
.instance_size = sizeof(VirtIORAMFB),
|
||||
.instance_init = virtio_ramfb_inst_initfn,
|
||||
};
|
||||
|
||||
static void virtio_ramfb_register_types(void)
|
||||
{
|
||||
type_register_static(&virtio_ramfb_base_info);
|
||||
virtio_pci_types_register(&virtio_ramfb_info);
|
||||
}
|
||||
|
||||
type_init(virtio_ramfb_register_types)
|
||||
@@ -1,28 +0,0 @@
|
||||
#ifndef VIRTIO_RAMFB_H
|
||||
#define VIRTIO_RAMFB_H
|
||||
|
||||
#include "hw/virtio/virtio-gpu-pci.h"
|
||||
#include "hw/display/ramfb.h"
|
||||
#include "qom/object.h"
|
||||
|
||||
/*
|
||||
* virtio-ramfb-base: This extends VirtioPCIProxy.
|
||||
*/
|
||||
#define TYPE_VIRTIO_RAMFB_BASE "virtio-ramfb-base"
|
||||
OBJECT_DECLARE_TYPE(VirtIORAMFBBase, VirtIORAMFBBaseClass,
|
||||
VIRTIO_RAMFB_BASE)
|
||||
|
||||
struct VirtIORAMFBBase {
|
||||
VirtIOPCIProxy parent_obj;
|
||||
|
||||
VirtIOGPUBase *vgpu;
|
||||
RAMFBState *ramfb;
|
||||
};
|
||||
|
||||
struct VirtIORAMFBBaseClass {
|
||||
VirtioPCIClass parent_class;
|
||||
|
||||
DeviceReset parent_reset;
|
||||
};
|
||||
|
||||
#endif /* VIRTIO_RAMFB_H */
|
||||
@@ -168,6 +168,11 @@ static inline int stream_idle(struct Stream *s)
|
||||
return !!(s->regs[R_DMASR] & DMASR_IDLE);
|
||||
}
|
||||
|
||||
static inline int stream_halted(struct Stream *s)
|
||||
{
|
||||
return !!(s->regs[R_DMASR] & DMASR_HALTED);
|
||||
}
|
||||
|
||||
static void stream_reset(struct Stream *s)
|
||||
{
|
||||
s->regs[R_DMASR] = DMASR_HALTED; /* starts up halted. */
|
||||
@@ -269,7 +274,7 @@ static void stream_process_mem2s(struct Stream *s, StreamSink *tx_data_dev,
|
||||
uint64_t addr;
|
||||
bool eop;
|
||||
|
||||
if (!stream_running(s) || stream_idle(s)) {
|
||||
if (!stream_running(s) || stream_idle(s) || stream_halted(s)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -326,7 +331,7 @@ static size_t stream_process_s2mem(struct Stream *s, unsigned char *buf,
|
||||
unsigned int rxlen;
|
||||
size_t pos = 0;
|
||||
|
||||
if (!stream_running(s) || stream_idle(s)) {
|
||||
if (!stream_running(s) || stream_idle(s) || stream_halted(s)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -407,7 +412,7 @@ xilinx_axidma_data_stream_can_push(StreamSink *obj,
|
||||
XilinxAXIDMAStreamSink *ds = XILINX_AXI_DMA_DATA_STREAM(obj);
|
||||
struct Stream *s = &ds->dma->streams[1];
|
||||
|
||||
if (!stream_running(s) || stream_idle(s)) {
|
||||
if (!stream_running(s) || stream_idle(s) || stream_halted(s)) {
|
||||
ds->dma->notify = notify;
|
||||
ds->dma->notify_opaque = notify_opaque;
|
||||
return false;
|
||||
|
||||
+13
-2
@@ -122,6 +122,7 @@ static FWCfgState *create_fw_cfg(MachineState *ms)
|
||||
{
|
||||
FWCfgState *fw_cfg;
|
||||
uint64_t val;
|
||||
const char qemu_version[] = QEMU_VERSION;
|
||||
|
||||
fw_cfg = fw_cfg_init_mem(FW_CFG_IO_BASE, FW_CFG_IO_BASE + 4);
|
||||
fw_cfg_add_i16(fw_cfg, FW_CFG_NB_CPUS, ms->smp.cpus);
|
||||
@@ -147,6 +148,10 @@ static FWCfgState *create_fw_cfg(MachineState *ms)
|
||||
fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, ms->boot_config.order[0]);
|
||||
qemu_register_boot_set(fw_cfg_boot_set, fw_cfg);
|
||||
|
||||
fw_cfg_add_file(fw_cfg, "/etc/qemu-version",
|
||||
g_memdup(qemu_version, sizeof(qemu_version)),
|
||||
sizeof(qemu_version));
|
||||
|
||||
return fw_cfg;
|
||||
}
|
||||
|
||||
@@ -417,10 +422,16 @@ static void hppa_machine_reset(MachineState *ms, ShutdownCause reason)
|
||||
|
||||
/* Start all CPUs at the firmware entry point.
|
||||
* Monarch CPU will initialize firmware, secondary CPUs
|
||||
* will enter a small idle look and wait for rendevouz. */
|
||||
* will enter a small idle loop and wait for rendevouz. */
|
||||
for (i = 0; i < smp_cpus; i++) {
|
||||
cpu_set_pc(CPU(cpu[i]), firmware_entry);
|
||||
CPUState *cs = CPU(cpu[i]);
|
||||
|
||||
cpu_set_pc(cs, firmware_entry);
|
||||
cpu[i]->env.psw = PSW_Q;
|
||||
cpu[i]->env.gr[5] = CPU_HPA + i * 0x1000;
|
||||
|
||||
cs->exception_index = -1;
|
||||
cs->halted = 0;
|
||||
}
|
||||
|
||||
/* already initialized by machine_hppa_init()? */
|
||||
|
||||
@@ -1441,6 +1441,9 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
|
||||
uint32_t nr_mem = machine->ram_slots;
|
||||
int root_bus_limit = 0xFF;
|
||||
PCIBus *bus = NULL;
|
||||
#ifdef CONFIG_TPM
|
||||
TPMIf *tpm = tpm_find();
|
||||
#endif
|
||||
bool cxl_present = false;
|
||||
int i;
|
||||
VMBusBridge *vmbus_bridge = vmbus_bridge_find();
|
||||
@@ -1790,6 +1793,26 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef CONFIG_TPM
|
||||
if (TPM_IS_CRB(tpm)) {
|
||||
dev = aml_device("TPM");
|
||||
aml_append(dev, aml_name_decl("_HID", aml_string("MSFT0101")));
|
||||
aml_append(dev, aml_name_decl("_STR",
|
||||
aml_string("TPM 2.0 Device")));
|
||||
crs = aml_resource_template();
|
||||
aml_append(crs, aml_memory32_fixed(TPM_CRB_ADDR_BASE,
|
||||
TPM_CRB_ADDR_SIZE, AML_READ_WRITE));
|
||||
aml_append(dev, aml_name_decl("_CRS", crs));
|
||||
|
||||
aml_append(dev, aml_name_decl("_STA", aml_int(0xf)));
|
||||
aml_append(dev, aml_name_decl("_UID", aml_int(1)));
|
||||
|
||||
tpm_build_ppi_acpi(tpm, dev);
|
||||
|
||||
aml_append(sb_scope, dev);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (pcms->sgx_epc.size != 0) {
|
||||
uint64_t epc_base = pcms->sgx_epc.base;
|
||||
uint64_t epc_size = pcms->sgx_epc.size;
|
||||
|
||||
+14
-9
@@ -755,6 +755,8 @@ static int vtd_get_pdire_from_pdir_table(dma_addr_t pasid_dir_base,
|
||||
return -VTD_FR_PASID_TABLE_INV;
|
||||
}
|
||||
|
||||
pdire->val = le64_to_cpu(pdire->val);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -779,6 +781,9 @@ static int vtd_get_pe_in_pasid_leaf_table(IntelIOMMUState *s,
|
||||
pe, entry_size, MEMTXATTRS_UNSPECIFIED)) {
|
||||
return -VTD_FR_PASID_TABLE_INV;
|
||||
}
|
||||
for (size_t i = 0; i < ARRAY_SIZE(pe->val); i++) {
|
||||
pe->val[i] = le64_to_cpu(pe->val[i]);
|
||||
}
|
||||
|
||||
/* Do translation type check */
|
||||
if (!vtd_pe_type_check(x86_iommu, pe)) {
|
||||
@@ -3322,14 +3327,15 @@ static int vtd_irte_get(IntelIOMMUState *iommu, uint16_t index,
|
||||
return -VTD_FR_IR_ROOT_INVAL;
|
||||
}
|
||||
|
||||
trace_vtd_ir_irte_get(index, le64_to_cpu(entry->data[1]),
|
||||
le64_to_cpu(entry->data[0]));
|
||||
entry->data[0] = le64_to_cpu(entry->data[0]);
|
||||
entry->data[1] = le64_to_cpu(entry->data[1]);
|
||||
|
||||
trace_vtd_ir_irte_get(index, entry->data[1], entry->data[0]);
|
||||
|
||||
if (!entry->irte.present) {
|
||||
error_report_once("%s: detected non-present IRTE "
|
||||
"(index=%u, high=0x%" PRIx64 ", low=0x%" PRIx64 ")",
|
||||
__func__, index, le64_to_cpu(entry->data[1]),
|
||||
le64_to_cpu(entry->data[0]));
|
||||
__func__, index, entry->data[1], entry->data[0]);
|
||||
return -VTD_FR_IR_ENTRY_P;
|
||||
}
|
||||
|
||||
@@ -3337,14 +3343,13 @@ static int vtd_irte_get(IntelIOMMUState *iommu, uint16_t index,
|
||||
entry->irte.__reserved_2) {
|
||||
error_report_once("%s: detected non-zero reserved IRTE "
|
||||
"(index=%u, high=0x%" PRIx64 ", low=0x%" PRIx64 ")",
|
||||
__func__, index, le64_to_cpu(entry->data[1]),
|
||||
le64_to_cpu(entry->data[0]));
|
||||
__func__, index, entry->data[1], entry->data[0]);
|
||||
return -VTD_FR_IR_IRTE_RSVD;
|
||||
}
|
||||
|
||||
if (sid != X86_IOMMU_SID_INVALID) {
|
||||
/* Validate IRTE SID */
|
||||
source_id = le32_to_cpu(entry->irte.source_id);
|
||||
source_id = entry->irte.source_id;
|
||||
switch (entry->irte.sid_vtype) {
|
||||
case VTD_SVT_NONE:
|
||||
break;
|
||||
@@ -3398,7 +3403,7 @@ static int vtd_remap_irq_get(IntelIOMMUState *iommu, uint16_t index,
|
||||
irq->trigger_mode = irte.irte.trigger_mode;
|
||||
irq->vector = irte.irte.vector;
|
||||
irq->delivery_mode = irte.irte.delivery_mode;
|
||||
irq->dest = le32_to_cpu(irte.irte.dest_id);
|
||||
irq->dest = irte.irte.dest_id;
|
||||
if (!iommu->intr_eime) {
|
||||
#define VTD_IR_APIC_DEST_MASK (0xff00ULL)
|
||||
#define VTD_IR_APIC_DEST_SHIFT (8)
|
||||
@@ -3453,7 +3458,7 @@ static int vtd_interrupt_remap_msi(IntelIOMMUState *iommu,
|
||||
goto out;
|
||||
}
|
||||
|
||||
index = addr.addr.index_h << 15 | le16_to_cpu(addr.addr.index_l);
|
||||
index = addr.addr.index_h << 15 | addr.addr.index_l;
|
||||
|
||||
#define VTD_IR_MSI_DATA_SUBHANDLE (0x0000ffff)
|
||||
#define VTD_IR_MSI_DATA_RESERVED (0xffff0000)
|
||||
|
||||
@@ -321,12 +321,21 @@ typedef enum VTDFaultReason {
|
||||
|
||||
/* Interrupt Entry Cache Invalidation Descriptor: VT-d 6.5.2.7. */
|
||||
struct VTDInvDescIEC {
|
||||
#if HOST_BIG_ENDIAN
|
||||
uint64_t reserved_2:16;
|
||||
uint64_t index:16; /* Start index to invalidate */
|
||||
uint64_t index_mask:5; /* 2^N for continuous int invalidation */
|
||||
uint64_t resved_1:22;
|
||||
uint64_t granularity:1; /* If set, it's global IR invalidation */
|
||||
uint64_t type:4; /* Should always be 0x4 */
|
||||
#else
|
||||
uint32_t type:4; /* Should always be 0x4 */
|
||||
uint32_t granularity:1; /* If set, it's global IR invalidation */
|
||||
uint32_t resved_1:22;
|
||||
uint32_t index_mask:5; /* 2^N for continuous int invalidation */
|
||||
uint32_t index:16; /* Start index to invalidate */
|
||||
uint32_t reserved_2:16;
|
||||
#endif
|
||||
};
|
||||
typedef struct VTDInvDescIEC VTDInvDescIEC;
|
||||
|
||||
|
||||
@@ -1587,7 +1587,7 @@ static int allocate_pirq(XenEvtchnState *s, int type, int gsi)
|
||||
found:
|
||||
pirq_inuse_word(s, pirq) |= pirq_inuse_bit(pirq);
|
||||
if (gsi >= 0) {
|
||||
assert(gsi <= IOAPIC_NUM_PINS);
|
||||
assert(gsi < IOAPIC_NUM_PINS);
|
||||
s->gsi_pirq[gsi] = pirq;
|
||||
}
|
||||
s->pirq[pirq].gsi = gsi;
|
||||
@@ -1601,7 +1601,7 @@ bool xen_evtchn_set_gsi(int gsi, int level)
|
||||
|
||||
assert(qemu_mutex_iothread_locked());
|
||||
|
||||
if (!s || gsi < 0 || gsi > IOAPIC_NUM_PINS) {
|
||||
if (!s || gsi < 0 || gsi >= IOAPIC_NUM_PINS) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1688,7 +1688,7 @@ static struct qemu_xs_handle *xs_be_open(void)
|
||||
XenXenstoreState *s = xen_xenstore_singleton;
|
||||
struct qemu_xs_handle *h;
|
||||
|
||||
if (!s && !s->impl) {
|
||||
if (!s || !s->impl) {
|
||||
errno = -ENOSYS;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
+1
-1
@@ -63,7 +63,7 @@ void x86_iommu_irq_to_msi_message(X86IOMMUIrq *irq, MSIMessage *msg_out)
|
||||
msg.redir_hint = irq->redir_hint;
|
||||
msg.dest = irq->dest;
|
||||
msg.__addr_hi = irq->dest & 0xffffff00;
|
||||
msg.__addr_head = cpu_to_le32(0xfee);
|
||||
msg.__addr_head = 0xfee;
|
||||
/* Keep this from original MSI address bits */
|
||||
msg.__not_used = irq->msi_addr_last_bits;
|
||||
|
||||
|
||||
+1
-1
@@ -118,7 +118,7 @@ static void piix_ide_reset(DeviceState *dev)
|
||||
pci_set_word(pci_conf + PCI_COMMAND, 0x0000);
|
||||
pci_set_word(pci_conf + PCI_STATUS,
|
||||
PCI_STATUS_DEVSEL_MEDIUM | PCI_STATUS_FAST_BACK);
|
||||
pci_set_byte(pci_conf + 0x20, 0x01); /* BMIBA: 20-23h */
|
||||
pci_set_long(pci_conf + 0x20, 0x1); /* BMIBA: 20-23h */
|
||||
}
|
||||
|
||||
static bool pci_piix_init_bus(PCIIDEState *d, unsigned i, Error **errp)
|
||||
|
||||
@@ -51,7 +51,7 @@ static void aw_a10_pic_set_irq(void *opaque, int irq, int level)
|
||||
AwA10PICState *s = opaque;
|
||||
uint32_t *pending_reg = &s->irq_pending[irq / 32];
|
||||
|
||||
*pending_reg = deposit32(*pending_reg, irq % 32, 1, level);
|
||||
*pending_reg = deposit32(*pending_reg, irq % 32, 1, !!level);
|
||||
aw_a10_pic_update(s);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
#include "target/loongarch/cpu.h"
|
||||
#include "hw/acpi/acpi-defs.h"
|
||||
#include "hw/acpi/acpi.h"
|
||||
#include "hw/acpi/acpi_aml_interface.h"
|
||||
#include "hw/nvram/fw_cfg.h"
|
||||
#include "hw/acpi/bios-linker-loader.h"
|
||||
#include "migration/vmstate.h"
|
||||
@@ -298,6 +297,41 @@ static void build_flash_aml(Aml *scope, LoongArchMachineState *lams)
|
||||
aml_append(scope, dev);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_TPM
|
||||
static void acpi_dsdt_add_tpm(Aml *scope, LoongArchMachineState *vms)
|
||||
{
|
||||
PlatformBusDevice *pbus = PLATFORM_BUS_DEVICE(vms->platform_bus_dev);
|
||||
hwaddr pbus_base = VIRT_PLATFORM_BUS_BASEADDRESS;
|
||||
SysBusDevice *sbdev = SYS_BUS_DEVICE(tpm_find());
|
||||
MemoryRegion *sbdev_mr;
|
||||
hwaddr tpm_base;
|
||||
|
||||
if (!sbdev) {
|
||||
return;
|
||||
}
|
||||
|
||||
tpm_base = platform_bus_get_mmio_addr(pbus, sbdev, 0);
|
||||
assert(tpm_base != -1);
|
||||
|
||||
tpm_base += pbus_base;
|
||||
|
||||
sbdev_mr = sysbus_mmio_get_region(sbdev, 0);
|
||||
|
||||
Aml *dev = aml_device("TPM0");
|
||||
aml_append(dev, aml_name_decl("_HID", aml_string("MSFT0101")));
|
||||
aml_append(dev, aml_name_decl("_STR", aml_string("TPM 2.0 Device")));
|
||||
aml_append(dev, aml_name_decl("_UID", aml_int(0)));
|
||||
|
||||
Aml *crs = aml_resource_template();
|
||||
aml_append(crs,
|
||||
aml_memory32_fixed(tpm_base,
|
||||
(uint32_t)memory_region_size(sbdev_mr),
|
||||
AML_READ_WRITE));
|
||||
aml_append(dev, aml_name_decl("_CRS", crs));
|
||||
aml_append(scope, dev);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* build DSDT */
|
||||
static void
|
||||
build_dsdt(GArray *table_data, BIOSLinker *linker, MachineState *machine)
|
||||
@@ -314,7 +348,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, MachineState *machine)
|
||||
build_la_ged_aml(dsdt, machine);
|
||||
build_flash_aml(dsdt, lams);
|
||||
#ifdef CONFIG_TPM
|
||||
call_dev_aml_func(DEVICE(tpm_find()), dsdt);
|
||||
acpi_dsdt_add_tpm(dsdt, lams);
|
||||
#endif
|
||||
/* System State Package */
|
||||
scope = aml_scope("\\");
|
||||
|
||||
@@ -988,37 +988,6 @@ static void virt_mem_plug(HotplugHandler *hotplug_dev,
|
||||
dev, &error_abort);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_TPM
|
||||
static void virt_tpm_plug(LoongArchMachineState *lams, TPMIf *tpmif)
|
||||
{
|
||||
PlatformBusDevice *pbus = PLATFORM_BUS_DEVICE(lams->platform_bus_dev);
|
||||
hwaddr pbus_base = VIRT_PLATFORM_BUS_BASEADDRESS;
|
||||
SysBusDevice *sbdev = SYS_BUS_DEVICE(tpmif);
|
||||
MemoryRegion *sbdev_mr;
|
||||
hwaddr tpm_base;
|
||||
uint64_t tpm_size;
|
||||
|
||||
if (!sbdev || !object_dynamic_cast(OBJECT(sbdev), TYPE_SYS_BUS_DEVICE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
tpm_base = platform_bus_get_mmio_addr(pbus, sbdev, 0);
|
||||
assert(tpm_base != -1);
|
||||
|
||||
tpm_base += pbus_base;
|
||||
|
||||
sbdev_mr = sysbus_mmio_get_region(sbdev, 0);
|
||||
tpm_size = memory_region_size(sbdev_mr);
|
||||
|
||||
if (object_property_find(OBJECT(sbdev), "baseaddr")) {
|
||||
object_property_set_uint(OBJECT(sbdev), "baseaddr", tpm_base, NULL);
|
||||
}
|
||||
if (object_property_find(OBJECT(sbdev), "size")) {
|
||||
object_property_set_uint(OBJECT(sbdev), "size", tpm_size, NULL);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static void loongarch_machine_device_plug_cb(HotplugHandler *hotplug_dev,
|
||||
DeviceState *dev, Error **errp)
|
||||
{
|
||||
@@ -1033,12 +1002,6 @@ static void loongarch_machine_device_plug_cb(HotplugHandler *hotplug_dev,
|
||||
} else if (memhp_type_supported(dev)) {
|
||||
virt_mem_plug(hotplug_dev, dev, errp);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_TPM
|
||||
if (object_dynamic_cast(OBJECT(dev), TYPE_TPM_IF)) {
|
||||
virt_tpm_plug(lams, TPM_IF(dev));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static HotplugHandler *virt_machine_get_hotplug_handler(MachineState *machine,
|
||||
@@ -1083,7 +1046,6 @@ static void loongarch_class_init(ObjectClass *oc, void *data)
|
||||
machine_class_allow_dynamic_sysbus_dev(mc, TYPE_RAMFB_DEVICE);
|
||||
#ifdef CONFIG_TPM
|
||||
machine_class_allow_dynamic_sysbus_dev(mc, TYPE_TPM_TIS_SYSBUS);
|
||||
machine_class_allow_dynamic_sysbus_dev(mc, TYPE_TPM_CRB_SYSBUS);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -629,9 +629,9 @@ static void bl_setup_gt64120_jump_kernel(void **p, uint64_t run_addr,
|
||||
|
||||
/* Bus endianess is always reversed */
|
||||
#if TARGET_BIG_ENDIAN
|
||||
#define cpu_to_gt32 cpu_to_le32
|
||||
#define cpu_to_gt32(x) (x)
|
||||
#else
|
||||
#define cpu_to_gt32 cpu_to_be32
|
||||
#define cpu_to_gt32(x) bswap32(x)
|
||||
#endif
|
||||
|
||||
/* setup MEM-to-PCI0 mapping as done by YAMON */
|
||||
|
||||
@@ -189,7 +189,7 @@ static void do_hash_operation(AspeedHACEState *s, int algo, bool sg_mode,
|
||||
bool acc_mode)
|
||||
{
|
||||
struct iovec iov[ASPEED_HACE_MAX_SG];
|
||||
g_autofree uint8_t *digest_buf;
|
||||
g_autofree uint8_t *digest_buf = NULL;
|
||||
size_t digest_len = 0;
|
||||
int niov = 0;
|
||||
int i;
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
#include "hw/misc/macio/macio.h"
|
||||
#include "hw/intc/heathrow_pic.h"
|
||||
#include "trace.h"
|
||||
#include "include/hw/audio/screamer.h"
|
||||
|
||||
#define ESCC_CLOCK 3686400
|
||||
|
||||
@@ -102,17 +101,6 @@ static bool macio_common_realize(PCIDevice *d, Error **errp)
|
||||
sbd = SYS_BUS_DEVICE(&s->dbdma);
|
||||
memory_region_add_subregion(&s->bar, 0x08000,
|
||||
sysbus_mmio_get_region(sbd, 0));
|
||||
if (!qdev_realize(DEVICE(&s->screamer), BUS(&s->macio_bus), errp)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Add the screamer sound chip */
|
||||
sbd = SYS_BUS_DEVICE(&s->screamer);
|
||||
const int offset = 0x14000; /* Offset from base address register (bar) */
|
||||
const int region_number = 0; /* which memory region to use */
|
||||
memory_region_add_subregion(&s->bar, offset,
|
||||
sysbus_mmio_get_region(sbd,
|
||||
region_number));
|
||||
|
||||
qdev_prop_set_uint32(DEVICE(&s->escc), "disabled", 0);
|
||||
qdev_prop_set_uint32(DEVICE(&s->escc), "frequency", ESCC_CLOCK);
|
||||
@@ -353,19 +341,6 @@ static void macio_newworld_realize(PCIDevice *d, Error **errp)
|
||||
memory_region_add_subregion(&s->bar, 0x16000,
|
||||
sysbus_mmio_get_region(sbd, 0));
|
||||
}
|
||||
|
||||
/* Screamer Sound Chip */
|
||||
const int gpio_0 = 0;
|
||||
const int gpio_1 = 1;
|
||||
const int transmit_channel = 0x10;
|
||||
const int receive_channel = 0x12;
|
||||
sbd = SYS_BUS_DEVICE(&s->screamer);
|
||||
sysbus_connect_irq(sbd, gpio_0, qdev_get_gpio_in(pic_dev,
|
||||
NEWWORLD_SCREAMER_IRQ));
|
||||
sysbus_connect_irq(sbd, gpio_1, qdev_get_gpio_in(pic_dev,
|
||||
NEWWORLD_SCREAMER_DMA_IRQ));
|
||||
screamer_register_dma_functions(SCREAMER(sbd), &s->dbdma,
|
||||
transmit_channel, receive_channel);
|
||||
}
|
||||
|
||||
static void macio_newworld_init(Object *obj)
|
||||
@@ -395,9 +370,6 @@ static void macio_instance_init(Object *obj)
|
||||
object_initialize_child(obj, "dbdma", &s->dbdma, TYPE_MAC_DBDMA);
|
||||
|
||||
object_initialize_child(obj, "escc", &s->escc, TYPE_ESCC);
|
||||
|
||||
object_initialize_child(obj, SOUND_CHIP_NAME, &s->screamer,
|
||||
TYPE_SCREAMER);
|
||||
}
|
||||
|
||||
static const VMStateDescription vmstate_macio_oldworld = {
|
||||
|
||||
+3
-2
@@ -3629,12 +3629,12 @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp)
|
||||
}
|
||||
|
||||
if (n->net_conf.tx_queue_size < VIRTIO_NET_TX_QUEUE_MIN_SIZE ||
|
||||
n->net_conf.tx_queue_size > VIRTQUEUE_MAX_SIZE ||
|
||||
n->net_conf.tx_queue_size > virtio_net_max_tx_queue_size(n) ||
|
||||
!is_power_of_2(n->net_conf.tx_queue_size)) {
|
||||
error_setg(errp, "Invalid tx_queue_size (= %" PRIu16 "), "
|
||||
"must be a power of 2 between %d and %d",
|
||||
n->net_conf.tx_queue_size, VIRTIO_NET_TX_QUEUE_MIN_SIZE,
|
||||
VIRTQUEUE_MAX_SIZE);
|
||||
virtio_net_max_tx_queue_size(n));
|
||||
virtio_cleanup(vdev);
|
||||
return;
|
||||
}
|
||||
@@ -3950,6 +3950,7 @@ static void virtio_net_class_init(ObjectClass *klass, void *data)
|
||||
vdc->vmsd = &vmstate_virtio_net_device;
|
||||
vdc->primary_unplug_pending = primary_unplug_pending;
|
||||
vdc->get_vhost = virtio_net_get_vhost;
|
||||
vdc->toggle_device_iotlb = vhost_toggle_device_iotlb;
|
||||
}
|
||||
|
||||
static const TypeInfo virtio_net_info = {
|
||||
|
||||
+13
-5
@@ -6767,6 +6767,7 @@ static uint16_t nvme_dbbuf_config(NvmeCtrl *n, const NvmeRequest *req)
|
||||
PCIDevice *pci = PCI_DEVICE(n);
|
||||
uint64_t dbs_addr = le64_to_cpu(req->cmd.dptr.prp1);
|
||||
uint64_t eis_addr = le64_to_cpu(req->cmd.dptr.prp2);
|
||||
uint32_t v;
|
||||
int i;
|
||||
|
||||
/* Address should be page aligned */
|
||||
@@ -6784,6 +6785,8 @@ static uint16_t nvme_dbbuf_config(NvmeCtrl *n, const NvmeRequest *req)
|
||||
NvmeCQueue *cq = n->cq[i];
|
||||
|
||||
if (sq) {
|
||||
v = cpu_to_le32(sq->tail);
|
||||
|
||||
/*
|
||||
* CAP.DSTRD is 0, so offset of ith sq db_addr is (i<<3)
|
||||
* nvme_process_db() uses this hard-coded way to calculate
|
||||
@@ -6791,7 +6794,7 @@ static uint16_t nvme_dbbuf_config(NvmeCtrl *n, const NvmeRequest *req)
|
||||
*/
|
||||
sq->db_addr = dbs_addr + (i << 3);
|
||||
sq->ei_addr = eis_addr + (i << 3);
|
||||
pci_dma_write(pci, sq->db_addr, &sq->tail, sizeof(sq->tail));
|
||||
pci_dma_write(pci, sq->db_addr, &v, sizeof(sq->tail));
|
||||
|
||||
if (n->params.ioeventfd && sq->sqid != 0) {
|
||||
if (!nvme_init_sq_ioeventfd(sq)) {
|
||||
@@ -6801,10 +6804,12 @@ static uint16_t nvme_dbbuf_config(NvmeCtrl *n, const NvmeRequest *req)
|
||||
}
|
||||
|
||||
if (cq) {
|
||||
v = cpu_to_le32(cq->head);
|
||||
|
||||
/* CAP.DSTRD is 0, so offset of ith cq db_addr is (i<<3)+(1<<2) */
|
||||
cq->db_addr = dbs_addr + (i << 3) + (1 << 2);
|
||||
cq->ei_addr = eis_addr + (i << 3) + (1 << 2);
|
||||
pci_dma_write(pci, cq->db_addr, &cq->head, sizeof(cq->head));
|
||||
pci_dma_write(pci, cq->db_addr, &v, sizeof(cq->head));
|
||||
|
||||
if (n->params.ioeventfd && cq->cqid != 0) {
|
||||
if (!nvme_init_cq_ioeventfd(cq)) {
|
||||
@@ -7555,7 +7560,7 @@ static uint64_t nvme_mmio_read(void *opaque, hwaddr addr, unsigned size)
|
||||
static void nvme_process_db(NvmeCtrl *n, hwaddr addr, int val)
|
||||
{
|
||||
PCIDevice *pci = PCI_DEVICE(n);
|
||||
uint32_t qid;
|
||||
uint32_t qid, v;
|
||||
|
||||
if (unlikely(addr & ((1 << 2) - 1))) {
|
||||
NVME_GUEST_ERR(pci_nvme_ub_db_wr_misaligned,
|
||||
@@ -7622,7 +7627,8 @@ static void nvme_process_db(NvmeCtrl *n, hwaddr addr, int val)
|
||||
start_sqs = nvme_cq_full(cq) ? 1 : 0;
|
||||
cq->head = new_head;
|
||||
if (!qid && n->dbbuf_enabled) {
|
||||
pci_dma_write(pci, cq->db_addr, &cq->head, sizeof(cq->head));
|
||||
v = cpu_to_le32(cq->head);
|
||||
pci_dma_write(pci, cq->db_addr, &v, sizeof(cq->head));
|
||||
}
|
||||
if (start_sqs) {
|
||||
NvmeSQueue *sq;
|
||||
@@ -7682,6 +7688,8 @@ static void nvme_process_db(NvmeCtrl *n, hwaddr addr, int val)
|
||||
|
||||
sq->tail = new_tail;
|
||||
if (!qid && n->dbbuf_enabled) {
|
||||
v = cpu_to_le32(sq->tail);
|
||||
|
||||
/*
|
||||
* The spec states "the host shall also update the controller's
|
||||
* corresponding doorbell property to match the value of that entry
|
||||
@@ -7695,7 +7703,7 @@ static void nvme_process_db(NvmeCtrl *n, hwaddr addr, int val)
|
||||
* including ones that run on Linux, are not updating Admin Queues,
|
||||
* so we can't trust reading it for an appropriate sq tail.
|
||||
*/
|
||||
pci_dma_write(pci, sq->db_addr, &sq->tail, sizeof(sq->tail));
|
||||
pci_dma_write(pci, sq->db_addr, &v, sizeof(sq->tail));
|
||||
}
|
||||
|
||||
qemu_bh_schedule(sq->bh);
|
||||
|
||||
+13
-2
@@ -62,6 +62,17 @@ static void pci_adjust_config_limit(PCIBus *bus, uint32_t *limit)
|
||||
}
|
||||
}
|
||||
|
||||
static bool is_pci_dev_ejected(PCIDevice *pci_dev)
|
||||
{
|
||||
/*
|
||||
* device unplug was requested and the guest acked it,
|
||||
* so we stop responding config accesses even if the
|
||||
* device is not deleted (failover flow)
|
||||
*/
|
||||
return pci_dev && pci_dev->partially_hotplugged &&
|
||||
!pci_dev->qdev.pending_deleted_event;
|
||||
}
|
||||
|
||||
void pci_host_config_write_common(PCIDevice *pci_dev, uint32_t addr,
|
||||
uint32_t limit, uint32_t val, uint32_t len)
|
||||
{
|
||||
@@ -75,7 +86,7 @@ void pci_host_config_write_common(PCIDevice *pci_dev, uint32_t addr,
|
||||
* allowing direct removal of unexposed functions.
|
||||
*/
|
||||
if ((pci_dev->qdev.hotplugged && !pci_get_function_0(pci_dev)) ||
|
||||
!pci_dev->has_power) {
|
||||
!pci_dev->has_power || is_pci_dev_ejected(pci_dev)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -100,7 +111,7 @@ uint32_t pci_host_config_read_common(PCIDevice *pci_dev, uint32_t addr,
|
||||
* allowing direct removal of unexposed functions.
|
||||
*/
|
||||
if ((pci_dev->qdev.hotplugged && !pci_get_function_0(pci_dev)) ||
|
||||
!pci_dev->has_power) {
|
||||
!pci_dev->has_power || is_pci_dev_ejected(pci_dev)) {
|
||||
return ~0x0;
|
||||
}
|
||||
|
||||
|
||||
@@ -115,7 +115,6 @@ config MAC_NEWWORLD
|
||||
select MAC_PMU
|
||||
select UNIN_PCI
|
||||
select FW_CFG_PPC
|
||||
select SCREAMER
|
||||
|
||||
config E500
|
||||
bool
|
||||
|
||||
+19
-16
@@ -535,23 +535,24 @@ static inline void cpu_ppc_store_tb(ppc_tb_t *tb_env, uint64_t vmclk,
|
||||
void cpu_ppc_store_tbl (CPUPPCState *env, uint32_t value)
|
||||
{
|
||||
ppc_tb_t *tb_env = env->tb_env;
|
||||
int64_t clock = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
|
||||
uint64_t tb;
|
||||
|
||||
tb = cpu_ppc_get_tb(tb_env, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL), tb_env->tb_offset);
|
||||
tb = cpu_ppc_get_tb(tb_env, clock, tb_env->tb_offset);
|
||||
tb &= 0xFFFFFFFF00000000ULL;
|
||||
cpu_ppc_store_tb(tb_env, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL),
|
||||
&tb_env->tb_offset, tb | (uint64_t)value);
|
||||
cpu_ppc_store_tb(tb_env, clock, &tb_env->tb_offset, tb | (uint64_t)value);
|
||||
}
|
||||
|
||||
static inline void _cpu_ppc_store_tbu(CPUPPCState *env, uint32_t value)
|
||||
{
|
||||
ppc_tb_t *tb_env = env->tb_env;
|
||||
int64_t clock = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
|
||||
uint64_t tb;
|
||||
|
||||
tb = cpu_ppc_get_tb(tb_env, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL), tb_env->tb_offset);
|
||||
tb = cpu_ppc_get_tb(tb_env, clock, tb_env->tb_offset);
|
||||
tb &= 0x00000000FFFFFFFFULL;
|
||||
cpu_ppc_store_tb(tb_env, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL),
|
||||
&tb_env->tb_offset, ((uint64_t)value << 32) | tb);
|
||||
cpu_ppc_store_tb(tb_env, clock, &tb_env->tb_offset,
|
||||
((uint64_t)value << 32) | tb);
|
||||
}
|
||||
|
||||
void cpu_ppc_store_tbu (CPUPPCState *env, uint32_t value)
|
||||
@@ -584,23 +585,24 @@ uint32_t cpu_ppc_load_atbu (CPUPPCState *env)
|
||||
void cpu_ppc_store_atbl (CPUPPCState *env, uint32_t value)
|
||||
{
|
||||
ppc_tb_t *tb_env = env->tb_env;
|
||||
int64_t clock = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
|
||||
uint64_t tb;
|
||||
|
||||
tb = cpu_ppc_get_tb(tb_env, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL), tb_env->atb_offset);
|
||||
tb = cpu_ppc_get_tb(tb_env, clock, tb_env->atb_offset);
|
||||
tb &= 0xFFFFFFFF00000000ULL;
|
||||
cpu_ppc_store_tb(tb_env, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL),
|
||||
&tb_env->atb_offset, tb | (uint64_t)value);
|
||||
cpu_ppc_store_tb(tb_env, clock, &tb_env->atb_offset, tb | (uint64_t)value);
|
||||
}
|
||||
|
||||
void cpu_ppc_store_atbu (CPUPPCState *env, uint32_t value)
|
||||
{
|
||||
ppc_tb_t *tb_env = env->tb_env;
|
||||
int64_t clock = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
|
||||
uint64_t tb;
|
||||
|
||||
tb = cpu_ppc_get_tb(tb_env, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL), tb_env->atb_offset);
|
||||
tb = cpu_ppc_get_tb(tb_env, clock, tb_env->atb_offset);
|
||||
tb &= 0x00000000FFFFFFFFULL;
|
||||
cpu_ppc_store_tb(tb_env, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL),
|
||||
&tb_env->atb_offset, ((uint64_t)value << 32) | tb);
|
||||
cpu_ppc_store_tb(tb_env, clock, &tb_env->atb_offset,
|
||||
((uint64_t)value << 32) | tb);
|
||||
}
|
||||
|
||||
uint64_t cpu_ppc_load_vtb(CPUPPCState *env)
|
||||
@@ -622,14 +624,13 @@ void cpu_ppc_store_vtb(CPUPPCState *env, uint64_t value)
|
||||
void cpu_ppc_store_tbu40(CPUPPCState *env, uint64_t value)
|
||||
{
|
||||
ppc_tb_t *tb_env = env->tb_env;
|
||||
int64_t clock = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
|
||||
uint64_t tb;
|
||||
|
||||
tb = cpu_ppc_get_tb(tb_env, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL),
|
||||
tb_env->tb_offset);
|
||||
tb = cpu_ppc_get_tb(tb_env, clock, tb_env->tb_offset);
|
||||
tb &= 0xFFFFFFUL;
|
||||
tb |= (value & ~0xFFFFFFUL);
|
||||
cpu_ppc_store_tb(tb_env, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL),
|
||||
&tb_env->tb_offset, tb);
|
||||
cpu_ppc_store_tb(tb_env, clock, &tb_env->tb_offset, tb);
|
||||
}
|
||||
|
||||
static void cpu_ppc_tb_stop (CPUPPCState *env)
|
||||
@@ -798,6 +799,8 @@ static void __cpu_ppc_store_decr(PowerPCCPU *cpu, uint64_t *nextp,
|
||||
int64_t signed_decr;
|
||||
|
||||
/* Truncate value to decr_width and sign extend for simplicity */
|
||||
value = extract64(value, 0, nr_bits);
|
||||
decr = extract64(decr, 0, nr_bits);
|
||||
signed_value = sextract64(value, 0, nr_bits);
|
||||
signed_decr = sextract64(decr, 0, nr_bits);
|
||||
|
||||
|
||||
+3
-1
@@ -270,9 +270,11 @@ static void ibm_40p_init(MachineState *machine)
|
||||
}
|
||||
|
||||
/* PCI -> ISA bridge */
|
||||
i82378_dev = DEVICE(pci_create_simple(pci_bus, PCI_DEVFN(11, 0), "i82378"));
|
||||
i82378_dev = DEVICE(pci_new(PCI_DEVFN(11, 0), "i82378"));
|
||||
qdev_connect_gpio_out(i82378_dev, 0,
|
||||
qdev_get_gpio_in(DEVICE(cpu), PPC6xx_INPUT_INT));
|
||||
qdev_realize_and_unref(i82378_dev, BUS(pci_bus), &error_fatal);
|
||||
|
||||
sysbus_connect_irq(pcihost, 0, qdev_get_gpio_in(i82378_dev, 15));
|
||||
isa_bus = ISA_BUS(qdev_get_child_bus(i82378_dev, "isa.0"));
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@ mpqemu_recv_io_error(int cmd, int size, int nfds) "failed to receive %d size %d,
|
||||
|
||||
# vfio-user-obj.c
|
||||
vfu_prop(const char *prop, const char *val) "vfu: setting %s as %s"
|
||||
vfu_cfg_read(uint32_t offset, uint32_t val) "vfu: cfg: 0x%u -> 0x%x"
|
||||
vfu_cfg_write(uint32_t offset, uint32_t val) "vfu: cfg: 0x%u <- 0x%x"
|
||||
vfu_cfg_read(uint32_t offset, uint32_t val) "vfu: cfg: 0x%x -> 0x%x"
|
||||
vfu_cfg_write(uint32_t offset, uint32_t val) "vfu: cfg: 0x%x <- 0x%x"
|
||||
vfu_dma_register(uint64_t gpa, size_t len) "vfu: registering GPA 0x%"PRIx64", %zu bytes"
|
||||
vfu_dma_unregister(uint64_t gpa) "vfu: unregistering GPA 0x%"PRIx64""
|
||||
vfu_bar_register(int i, uint64_t addr, uint64_t size) "vfu: BAR %d: addr 0x%"PRIx64" size 0x%"PRIx64""
|
||||
|
||||
@@ -29,7 +29,6 @@ config RISCV_VIRT
|
||||
imply PCI_DEVICES
|
||||
imply VIRTIO_VGA
|
||||
imply TEST_DEVICES
|
||||
imply TPM_CRB_SYSBUS
|
||||
imply TPM_TIS_SYSBUS
|
||||
select RISCV_NUMA
|
||||
select GOLDFISH_RTC
|
||||
|
||||
@@ -207,6 +207,12 @@ int64_t riscv_numa_get_default_cpu_node_id(const MachineState *ms, int idx)
|
||||
{
|
||||
int64_t nidx = 0;
|
||||
|
||||
if (ms->numa_state->num_nodes > ms->smp.cpus) {
|
||||
error_report("Number of NUMA nodes (%d)"
|
||||
" cannot exceed the number of available CPUs (%d).",
|
||||
ms->numa_state->num_nodes, ms->smp.max_cpus);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if (ms->numa_state->num_nodes) {
|
||||
nidx = idx / (ms->smp.cpus / ms->numa_state->num_nodes);
|
||||
if (ms->numa_state->num_nodes <= nidx) {
|
||||
|
||||
@@ -1687,7 +1687,6 @@ static void virt_machine_class_init(ObjectClass *oc, void *data)
|
||||
machine_class_allow_dynamic_sysbus_dev(mc, TYPE_RAMFB_DEVICE);
|
||||
#ifdef CONFIG_TPM
|
||||
machine_class_allow_dynamic_sysbus_dev(mc, TYPE_TPM_TIS_SYSBUS);
|
||||
machine_class_allow_dynamic_sysbus_dev(mc, TYPE_TPM_CRB_SYSBUS);
|
||||
#endif
|
||||
|
||||
object_class_property_add_bool(oc, "aclint", virt_get_aclint,
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
*/
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
#include "block/block_int-common.h"
|
||||
#include "qemu/units.h"
|
||||
#include "cpu.h"
|
||||
#include "hw/boards.h"
|
||||
@@ -143,9 +144,10 @@ static void niagara_init(MachineState *machine)
|
||||
memory_region_add_subregion(get_system_memory(),
|
||||
NIAGARA_VDISK_BASE, &s->vdisk_ram);
|
||||
dinfo->is_default = 1;
|
||||
rom_add_file_fixed(blk_name(blk), NIAGARA_VDISK_BASE, -1);
|
||||
rom_add_file_fixed(blk_bs(blk)->filename, NIAGARA_VDISK_BASE, -1);
|
||||
} else {
|
||||
error_report("could not load ram disk '%s'", blk_name(blk));
|
||||
error_report("could not load ram disk '%s'",
|
||||
blk_bs(blk)->filename);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,12 @@ static uint32_t update_counter(NRF51TimerState *s, int64_t now)
|
||||
uint32_t ticks = ns_to_ticks(s, now - s->update_counter_ns);
|
||||
|
||||
s->counter = (s->counter + ticks) % BIT(bitwidths[s->bitmode]);
|
||||
s->update_counter_ns = now;
|
||||
/*
|
||||
* Only advance the sync time to the timestamp of the last tick,
|
||||
* not all the way to 'now', so we don't lose time if we do
|
||||
* multiple resyncs in a single tick.
|
||||
*/
|
||||
s->update_counter_ns += ticks_to_ns(s, ticks);
|
||||
return ticks;
|
||||
}
|
||||
|
||||
|
||||
+1
-6
@@ -15,12 +15,7 @@ config TPM_TIS
|
||||
|
||||
config TPM_CRB
|
||||
bool
|
||||
depends on TPM && ISA_BUS
|
||||
select TPM_BACKEND
|
||||
|
||||
config TPM_CRB_SYSBUS
|
||||
bool
|
||||
depends on TPM
|
||||
depends on TPM && PC
|
||||
select TPM_BACKEND
|
||||
|
||||
config TPM_SPAPR
|
||||
|
||||
@@ -2,9 +2,6 @@ softmmu_ss.add(when: 'CONFIG_TPM_TIS', if_true: files('tpm_tis_common.c'))
|
||||
softmmu_ss.add(when: 'CONFIG_TPM_TIS_ISA', if_true: files('tpm_tis_isa.c'))
|
||||
softmmu_ss.add(when: 'CONFIG_TPM_TIS_SYSBUS', if_true: files('tpm_tis_sysbus.c'))
|
||||
softmmu_ss.add(when: 'CONFIG_TPM_CRB', if_true: files('tpm_crb.c'))
|
||||
softmmu_ss.add(when: 'CONFIG_TPM_CRB', if_true: files('tpm_crb_common.c'))
|
||||
softmmu_ss.add(when: 'CONFIG_TPM_CRB_SYSBUS', if_true: files('tpm_crb_sysbus.c'))
|
||||
softmmu_ss.add(when: 'CONFIG_TPM_CRB_SYSBUS', if_true: files('tpm_crb_common.c'))
|
||||
softmmu_ss.add(when: 'CONFIG_TPM_TIS', if_true: files('tpm_ppi.c'))
|
||||
softmmu_ss.add(when: 'CONFIG_TPM_CRB', if_true: files('tpm_ppi.c'))
|
||||
|
||||
|
||||
+240
-67
@@ -19,12 +19,9 @@
|
||||
#include "qemu/module.h"
|
||||
#include "qapi/error.h"
|
||||
#include "exec/address-spaces.h"
|
||||
#include "hw/acpi/acpi_aml_interface.h"
|
||||
#include "hw/acpi/tpm.h"
|
||||
#include "hw/qdev-properties.h"
|
||||
#include "hw/pci/pci_ids.h"
|
||||
#include "hw/acpi/tpm.h"
|
||||
#include "hw/isa/isa.h"
|
||||
#include "migration/vmstate.h"
|
||||
#include "sysemu/tpm_backend.h"
|
||||
#include "sysemu/tpm_util.h"
|
||||
@@ -34,61 +31,257 @@
|
||||
#include "tpm_ppi.h"
|
||||
#include "trace.h"
|
||||
#include "qom/object.h"
|
||||
#include "tpm_crb.h"
|
||||
|
||||
struct CRBState {
|
||||
ISADevice parent_obj;
|
||||
DeviceState parent_obj;
|
||||
|
||||
TPMCRBState state;
|
||||
TPMBackend *tpmbe;
|
||||
TPMBackendCmd cmd;
|
||||
uint32_t regs[TPM_CRB_R_MAX];
|
||||
MemoryRegion mmio;
|
||||
MemoryRegion cmdmem;
|
||||
|
||||
size_t be_buffer_size;
|
||||
|
||||
bool ppi_enabled;
|
||||
TPMPPI ppi;
|
||||
};
|
||||
typedef struct CRBState CRBState;
|
||||
|
||||
DECLARE_INSTANCE_CHECKER(CRBState, CRB,
|
||||
TYPE_TPM_CRB)
|
||||
|
||||
static void tpm_crb_isa_request_completed(TPMIf *ti, int ret)
|
||||
#define CRB_INTF_TYPE_CRB_ACTIVE 0b1
|
||||
#define CRB_INTF_VERSION_CRB 0b1
|
||||
#define CRB_INTF_CAP_LOCALITY_0_ONLY 0b0
|
||||
#define CRB_INTF_CAP_IDLE_FAST 0b0
|
||||
#define CRB_INTF_CAP_XFER_SIZE_64 0b11
|
||||
#define CRB_INTF_CAP_FIFO_NOT_SUPPORTED 0b0
|
||||
#define CRB_INTF_CAP_CRB_SUPPORTED 0b1
|
||||
#define CRB_INTF_IF_SELECTOR_CRB 0b1
|
||||
|
||||
#define CRB_CTRL_CMD_SIZE (TPM_CRB_ADDR_SIZE - A_CRB_DATA_BUFFER)
|
||||
|
||||
enum crb_loc_ctrl {
|
||||
CRB_LOC_CTRL_REQUEST_ACCESS = BIT(0),
|
||||
CRB_LOC_CTRL_RELINQUISH = BIT(1),
|
||||
CRB_LOC_CTRL_SEIZE = BIT(2),
|
||||
CRB_LOC_CTRL_RESET_ESTABLISHMENT_BIT = BIT(3),
|
||||
};
|
||||
|
||||
enum crb_ctrl_req {
|
||||
CRB_CTRL_REQ_CMD_READY = BIT(0),
|
||||
CRB_CTRL_REQ_GO_IDLE = BIT(1),
|
||||
};
|
||||
|
||||
enum crb_start {
|
||||
CRB_START_INVOKE = BIT(0),
|
||||
};
|
||||
|
||||
enum crb_cancel {
|
||||
CRB_CANCEL_INVOKE = BIT(0),
|
||||
};
|
||||
|
||||
#define TPM_CRB_NO_LOCALITY 0xff
|
||||
|
||||
static uint64_t tpm_crb_mmio_read(void *opaque, hwaddr addr,
|
||||
unsigned size)
|
||||
{
|
||||
CRBState *s = CRB(opaque);
|
||||
void *regs = (void *)&s->regs + (addr & ~3);
|
||||
unsigned offset = addr & 3;
|
||||
uint32_t val = *(uint32_t *)regs >> (8 * offset);
|
||||
|
||||
switch (addr) {
|
||||
case A_CRB_LOC_STATE:
|
||||
val |= !tpm_backend_get_tpm_established_flag(s->tpmbe);
|
||||
break;
|
||||
}
|
||||
|
||||
trace_tpm_crb_mmio_read(addr, size, val);
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
static uint8_t tpm_crb_get_active_locty(CRBState *s)
|
||||
{
|
||||
if (!ARRAY_FIELD_EX32(s->regs, CRB_LOC_STATE, locAssigned)) {
|
||||
return TPM_CRB_NO_LOCALITY;
|
||||
}
|
||||
return ARRAY_FIELD_EX32(s->regs, CRB_LOC_STATE, activeLocality);
|
||||
}
|
||||
|
||||
static void tpm_crb_mmio_write(void *opaque, hwaddr addr,
|
||||
uint64_t val, unsigned size)
|
||||
{
|
||||
CRBState *s = CRB(opaque);
|
||||
uint8_t locty = addr >> 12;
|
||||
|
||||
trace_tpm_crb_mmio_write(addr, size, val);
|
||||
|
||||
switch (addr) {
|
||||
case A_CRB_CTRL_REQ:
|
||||
switch (val) {
|
||||
case CRB_CTRL_REQ_CMD_READY:
|
||||
ARRAY_FIELD_DP32(s->regs, CRB_CTRL_STS,
|
||||
tpmIdle, 0);
|
||||
break;
|
||||
case CRB_CTRL_REQ_GO_IDLE:
|
||||
ARRAY_FIELD_DP32(s->regs, CRB_CTRL_STS,
|
||||
tpmIdle, 1);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case A_CRB_CTRL_CANCEL:
|
||||
if (val == CRB_CANCEL_INVOKE &&
|
||||
s->regs[R_CRB_CTRL_START] & CRB_START_INVOKE) {
|
||||
tpm_backend_cancel_cmd(s->tpmbe);
|
||||
}
|
||||
break;
|
||||
case A_CRB_CTRL_START:
|
||||
if (val == CRB_START_INVOKE &&
|
||||
!(s->regs[R_CRB_CTRL_START] & CRB_START_INVOKE) &&
|
||||
tpm_crb_get_active_locty(s) == locty) {
|
||||
void *mem = memory_region_get_ram_ptr(&s->cmdmem);
|
||||
|
||||
s->regs[R_CRB_CTRL_START] |= CRB_START_INVOKE;
|
||||
s->cmd = (TPMBackendCmd) {
|
||||
.in = mem,
|
||||
.in_len = MIN(tpm_cmd_get_size(mem), s->be_buffer_size),
|
||||
.out = mem,
|
||||
.out_len = s->be_buffer_size,
|
||||
};
|
||||
|
||||
tpm_backend_deliver_request(s->tpmbe, &s->cmd);
|
||||
}
|
||||
break;
|
||||
case A_CRB_LOC_CTRL:
|
||||
switch (val) {
|
||||
case CRB_LOC_CTRL_RESET_ESTABLISHMENT_BIT:
|
||||
/* not loc 3 or 4 */
|
||||
break;
|
||||
case CRB_LOC_CTRL_RELINQUISH:
|
||||
ARRAY_FIELD_DP32(s->regs, CRB_LOC_STATE,
|
||||
locAssigned, 0);
|
||||
ARRAY_FIELD_DP32(s->regs, CRB_LOC_STS,
|
||||
Granted, 0);
|
||||
break;
|
||||
case CRB_LOC_CTRL_REQUEST_ACCESS:
|
||||
ARRAY_FIELD_DP32(s->regs, CRB_LOC_STS,
|
||||
Granted, 1);
|
||||
ARRAY_FIELD_DP32(s->regs, CRB_LOC_STS,
|
||||
beenSeized, 0);
|
||||
ARRAY_FIELD_DP32(s->regs, CRB_LOC_STATE,
|
||||
locAssigned, 1);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static const MemoryRegionOps tpm_crb_memory_ops = {
|
||||
.read = tpm_crb_mmio_read,
|
||||
.write = tpm_crb_mmio_write,
|
||||
.endianness = DEVICE_LITTLE_ENDIAN,
|
||||
.valid = {
|
||||
.min_access_size = 1,
|
||||
.max_access_size = 4,
|
||||
},
|
||||
};
|
||||
|
||||
static void tpm_crb_request_completed(TPMIf *ti, int ret)
|
||||
{
|
||||
CRBState *s = CRB(ti);
|
||||
|
||||
tpm_crb_request_completed(&s->state, ret);
|
||||
s->regs[R_CRB_CTRL_START] &= ~CRB_START_INVOKE;
|
||||
if (ret != 0) {
|
||||
ARRAY_FIELD_DP32(s->regs, CRB_CTRL_STS,
|
||||
tpmSts, 1); /* fatal error */
|
||||
}
|
||||
memory_region_set_dirty(&s->cmdmem, 0, CRB_CTRL_CMD_SIZE);
|
||||
}
|
||||
|
||||
static enum TPMVersion tpm_crb_isa_get_version(TPMIf *ti)
|
||||
static enum TPMVersion tpm_crb_get_version(TPMIf *ti)
|
||||
{
|
||||
CRBState *s = CRB(ti);
|
||||
|
||||
return tpm_crb_get_version(&s->state);
|
||||
return tpm_backend_get_tpm_version(s->tpmbe);
|
||||
}
|
||||
|
||||
static int tpm_crb_isa_pre_save(void *opaque)
|
||||
static int tpm_crb_pre_save(void *opaque)
|
||||
{
|
||||
CRBState *s = opaque;
|
||||
|
||||
return tpm_crb_pre_save(&s->state);
|
||||
tpm_backend_finish_sync(s->tpmbe);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const VMStateDescription vmstate_tpm_crb_isa = {
|
||||
static const VMStateDescription vmstate_tpm_crb = {
|
||||
.name = "tpm-crb",
|
||||
.pre_save = tpm_crb_isa_pre_save,
|
||||
.pre_save = tpm_crb_pre_save,
|
||||
.fields = (VMStateField[]) {
|
||||
VMSTATE_UINT32_ARRAY(regs, CRBState, TPM_CRB_R_MAX),
|
||||
VMSTATE_END_OF_LIST(),
|
||||
}
|
||||
};
|
||||
|
||||
static Property tpm_crb_isa_properties[] = {
|
||||
DEFINE_PROP_TPMBE("tpmdev", CRBState, state.tpmbe),
|
||||
DEFINE_PROP_BOOL("ppi", CRBState, state.ppi_enabled, true),
|
||||
static Property tpm_crb_properties[] = {
|
||||
DEFINE_PROP_TPMBE("tpmdev", CRBState, tpmbe),
|
||||
DEFINE_PROP_BOOL("ppi", CRBState, ppi_enabled, true),
|
||||
DEFINE_PROP_END_OF_LIST(),
|
||||
};
|
||||
|
||||
static void tpm_crb_isa_reset(void *dev)
|
||||
static void tpm_crb_reset(void *dev)
|
||||
{
|
||||
CRBState *s = CRB(dev);
|
||||
|
||||
return tpm_crb_reset(&s->state, TPM_CRB_ADDR_BASE);
|
||||
if (s->ppi_enabled) {
|
||||
tpm_ppi_reset(&s->ppi);
|
||||
}
|
||||
tpm_backend_reset(s->tpmbe);
|
||||
|
||||
memset(s->regs, 0, sizeof(s->regs));
|
||||
|
||||
ARRAY_FIELD_DP32(s->regs, CRB_LOC_STATE,
|
||||
tpmRegValidSts, 1);
|
||||
ARRAY_FIELD_DP32(s->regs, CRB_CTRL_STS,
|
||||
tpmIdle, 1);
|
||||
ARRAY_FIELD_DP32(s->regs, CRB_INTF_ID,
|
||||
InterfaceType, CRB_INTF_TYPE_CRB_ACTIVE);
|
||||
ARRAY_FIELD_DP32(s->regs, CRB_INTF_ID,
|
||||
InterfaceVersion, CRB_INTF_VERSION_CRB);
|
||||
ARRAY_FIELD_DP32(s->regs, CRB_INTF_ID,
|
||||
CapLocality, CRB_INTF_CAP_LOCALITY_0_ONLY);
|
||||
ARRAY_FIELD_DP32(s->regs, CRB_INTF_ID,
|
||||
CapCRBIdleBypass, CRB_INTF_CAP_IDLE_FAST);
|
||||
ARRAY_FIELD_DP32(s->regs, CRB_INTF_ID,
|
||||
CapDataXferSizeSupport, CRB_INTF_CAP_XFER_SIZE_64);
|
||||
ARRAY_FIELD_DP32(s->regs, CRB_INTF_ID,
|
||||
CapFIFO, CRB_INTF_CAP_FIFO_NOT_SUPPORTED);
|
||||
ARRAY_FIELD_DP32(s->regs, CRB_INTF_ID,
|
||||
CapCRB, CRB_INTF_CAP_CRB_SUPPORTED);
|
||||
ARRAY_FIELD_DP32(s->regs, CRB_INTF_ID,
|
||||
InterfaceSelector, CRB_INTF_IF_SELECTOR_CRB);
|
||||
ARRAY_FIELD_DP32(s->regs, CRB_INTF_ID,
|
||||
RID, 0b0000);
|
||||
ARRAY_FIELD_DP32(s->regs, CRB_INTF_ID2,
|
||||
VID, PCI_VENDOR_ID_IBM);
|
||||
|
||||
s->regs[R_CRB_CTRL_CMD_SIZE] = CRB_CTRL_CMD_SIZE;
|
||||
s->regs[R_CRB_CTRL_CMD_LADDR] = TPM_CRB_ADDR_BASE + A_CRB_DATA_BUFFER;
|
||||
s->regs[R_CRB_CTRL_RSP_SIZE] = CRB_CTRL_CMD_SIZE;
|
||||
s->regs[R_CRB_CTRL_RSP_ADDR] = TPM_CRB_ADDR_BASE + A_CRB_DATA_BUFFER;
|
||||
|
||||
s->be_buffer_size = MIN(tpm_backend_get_buffer_size(s->tpmbe),
|
||||
CRB_CTRL_CMD_SIZE);
|
||||
|
||||
if (tpm_backend_startup_tpm(s->tpmbe, s->be_buffer_size) < 0) {
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
static void tpm_crb_isa_realize(DeviceState *dev, Error **errp)
|
||||
static void tpm_crb_realize(DeviceState *dev, Error **errp)
|
||||
{
|
||||
CRBState *s = CRB(dev);
|
||||
|
||||
@@ -96,84 +289,64 @@ static void tpm_crb_isa_realize(DeviceState *dev, Error **errp)
|
||||
error_setg(errp, "at most one TPM device is permitted");
|
||||
return;
|
||||
}
|
||||
if (!s->state.tpmbe) {
|
||||
if (!s->tpmbe) {
|
||||
error_setg(errp, "'tpmdev' property is required");
|
||||
return;
|
||||
}
|
||||
|
||||
tpm_crb_init_memory(OBJECT(s), &s->state, errp);
|
||||
memory_region_init_io(&s->mmio, OBJECT(s), &tpm_crb_memory_ops, s,
|
||||
"tpm-crb-mmio", sizeof(s->regs));
|
||||
memory_region_init_ram(&s->cmdmem, OBJECT(s),
|
||||
"tpm-crb-cmd", CRB_CTRL_CMD_SIZE, errp);
|
||||
|
||||
memory_region_add_subregion(isa_address_space(ISA_DEVICE(dev)),
|
||||
TPM_CRB_ADDR_BASE, &s->state.mmio);
|
||||
memory_region_add_subregion(get_system_memory(),
|
||||
TPM_CRB_ADDR_BASE, &s->mmio);
|
||||
memory_region_add_subregion(get_system_memory(),
|
||||
TPM_CRB_ADDR_BASE + sizeof(s->regs), &s->cmdmem);
|
||||
|
||||
if (s->state.ppi_enabled) {
|
||||
memory_region_add_subregion(isa_address_space(ISA_DEVICE(dev)),
|
||||
TPM_PPI_ADDR_BASE, &s->state.ppi.ram);
|
||||
if (s->ppi_enabled) {
|
||||
tpm_ppi_init(&s->ppi, get_system_memory(),
|
||||
TPM_PPI_ADDR_BASE, OBJECT(s));
|
||||
}
|
||||
|
||||
if (xen_enabled()) {
|
||||
tpm_crb_isa_reset(dev);
|
||||
tpm_crb_reset(dev);
|
||||
} else {
|
||||
qemu_register_reset(tpm_crb_isa_reset, dev);
|
||||
qemu_register_reset(tpm_crb_reset, dev);
|
||||
}
|
||||
}
|
||||
|
||||
static void build_tpm_crb_isa_aml(AcpiDevAmlIf *adev, Aml *scope)
|
||||
{
|
||||
Aml *dev, *crs;
|
||||
CRBState *s = CRB(adev);
|
||||
TPMIf *ti = TPM_IF(s);
|
||||
|
||||
dev = aml_device("TPM");
|
||||
if (tpm_crb_isa_get_version(ti) == TPM_VERSION_2_0) {
|
||||
aml_append(dev, aml_name_decl("_HID", aml_string("MSFT0101")));
|
||||
aml_append(dev, aml_name_decl("_STR", aml_string("TPM 2.0 Device")));
|
||||
} else {
|
||||
aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C31")));
|
||||
}
|
||||
aml_append(dev, aml_name_decl("_UID", aml_int(1)));
|
||||
aml_append(dev, aml_name_decl("_STA", aml_int(0xF)));
|
||||
crs = aml_resource_template();
|
||||
aml_append(crs, aml_memory32_fixed(TPM_CRB_ADDR_BASE, TPM_CRB_ADDR_SIZE,
|
||||
AML_READ_WRITE));
|
||||
aml_append(dev, aml_name_decl("_CRS", crs));
|
||||
tpm_build_ppi_acpi(ti, dev);
|
||||
aml_append(scope, dev);
|
||||
}
|
||||
|
||||
static void tpm_crb_isa_class_init(ObjectClass *klass, void *data)
|
||||
static void tpm_crb_class_init(ObjectClass *klass, void *data)
|
||||
{
|
||||
DeviceClass *dc = DEVICE_CLASS(klass);
|
||||
TPMIfClass *tc = TPM_IF_CLASS(klass);
|
||||
AcpiDevAmlIfClass *adevc = ACPI_DEV_AML_IF_CLASS(klass);
|
||||
|
||||
dc->realize = tpm_crb_isa_realize;
|
||||
device_class_set_props(dc, tpm_crb_isa_properties);
|
||||
dc->vmsd = &vmstate_tpm_crb_isa;
|
||||
dc->realize = tpm_crb_realize;
|
||||
device_class_set_props(dc, tpm_crb_properties);
|
||||
dc->vmsd = &vmstate_tpm_crb;
|
||||
dc->user_creatable = true;
|
||||
tc->model = TPM_MODEL_TPM_CRB;
|
||||
tc->get_version = tpm_crb_isa_get_version;
|
||||
tc->request_completed = tpm_crb_isa_request_completed;
|
||||
adevc->build_dev_aml = build_tpm_crb_isa_aml;
|
||||
tc->get_version = tpm_crb_get_version;
|
||||
tc->request_completed = tpm_crb_request_completed;
|
||||
|
||||
set_bit(DEVICE_CATEGORY_MISC, dc->categories);
|
||||
}
|
||||
|
||||
static const TypeInfo tpm_crb_isa_info = {
|
||||
static const TypeInfo tpm_crb_info = {
|
||||
.name = TYPE_TPM_CRB,
|
||||
.parent = TYPE_ISA_DEVICE,
|
||||
/* could be TYPE_SYS_BUS_DEVICE (or LPC etc) */
|
||||
.parent = TYPE_DEVICE,
|
||||
.instance_size = sizeof(CRBState),
|
||||
.class_init = tpm_crb_isa_class_init,
|
||||
.class_init = tpm_crb_class_init,
|
||||
.interfaces = (InterfaceInfo[]) {
|
||||
{ TYPE_TPM_IF },
|
||||
{ TYPE_ACPI_DEV_AML_IF },
|
||||
{ }
|
||||
}
|
||||
};
|
||||
|
||||
static void tpm_crb_isa_register(void)
|
||||
static void tpm_crb_register(void)
|
||||
{
|
||||
type_register_static(&tpm_crb_isa_info);
|
||||
type_register_static(&tpm_crb_info);
|
||||
}
|
||||
|
||||
type_init(tpm_crb_isa_register)
|
||||
type_init(tpm_crb_register)
|
||||
@@ -1,74 +0,0 @@
|
||||
/*
|
||||
* tpm_crb.h - QEMU's TPM CRB interface emulator
|
||||
*
|
||||
* Copyright (c) 2018 Red Hat, Inc.
|
||||
*
|
||||
* Authors:
|
||||
* Marc-André Lureau <marcandre.lureau@redhat.com>
|
||||
*
|
||||
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
||||
* See the COPYING file in the top-level directory.
|
||||
*
|
||||
* tpm_crb is a device for TPM 2.0 Command Response Buffer (CRB) Interface
|
||||
* as defined in TCG PC Client Platform TPM Profile (PTP) Specification
|
||||
* Family “2.0” Level 00 Revision 01.03 v22
|
||||
*/
|
||||
#ifndef TPM_TPM_CRB_H
|
||||
#define TPM_TPM_CRB_H
|
||||
|
||||
#include "exec/memory.h"
|
||||
#include "hw/acpi/tpm.h"
|
||||
#include "sysemu/tpm_backend.h"
|
||||
#include "tpm_ppi.h"
|
||||
|
||||
#define CRB_CTRL_CMD_SIZE (TPM_CRB_ADDR_SIZE - A_CRB_DATA_BUFFER)
|
||||
|
||||
typedef struct TPMCRBState {
|
||||
TPMBackend *tpmbe;
|
||||
TPMBackendCmd cmd;
|
||||
MemoryRegion mmio;
|
||||
|
||||
size_t be_buffer_size;
|
||||
|
||||
bool ppi_enabled;
|
||||
TPMPPI ppi;
|
||||
} TPMCRBState;
|
||||
|
||||
#define CRB_INTF_TYPE_CRB_ACTIVE 0b1
|
||||
#define CRB_INTF_VERSION_CRB 0b1
|
||||
#define CRB_INTF_CAP_LOCALITY_0_ONLY 0b0
|
||||
#define CRB_INTF_CAP_IDLE_FAST 0b0
|
||||
#define CRB_INTF_CAP_XFER_SIZE_64 0b11
|
||||
#define CRB_INTF_CAP_FIFO_NOT_SUPPORTED 0b0
|
||||
#define CRB_INTF_CAP_CRB_SUPPORTED 0b1
|
||||
#define CRB_INTF_IF_SELECTOR_CRB 0b1
|
||||
|
||||
enum crb_loc_ctrl {
|
||||
CRB_LOC_CTRL_REQUEST_ACCESS = BIT(0),
|
||||
CRB_LOC_CTRL_RELINQUISH = BIT(1),
|
||||
CRB_LOC_CTRL_SEIZE = BIT(2),
|
||||
CRB_LOC_CTRL_RESET_ESTABLISHMENT_BIT = BIT(3),
|
||||
};
|
||||
|
||||
enum crb_ctrl_req {
|
||||
CRB_CTRL_REQ_CMD_READY = BIT(0),
|
||||
CRB_CTRL_REQ_GO_IDLE = BIT(1),
|
||||
};
|
||||
|
||||
enum crb_start {
|
||||
CRB_START_INVOKE = BIT(0),
|
||||
};
|
||||
|
||||
enum crb_cancel {
|
||||
CRB_CANCEL_INVOKE = BIT(0),
|
||||
};
|
||||
|
||||
#define TPM_CRB_NO_LOCALITY 0xff
|
||||
|
||||
void tpm_crb_request_completed(TPMCRBState *s, int ret);
|
||||
enum TPMVersion tpm_crb_get_version(TPMCRBState *s);
|
||||
int tpm_crb_pre_save(TPMCRBState *s);
|
||||
void tpm_crb_reset(TPMCRBState *s, uint64_t baseaddr);
|
||||
void tpm_crb_init_memory(Object *obj, TPMCRBState *s, Error **errp);
|
||||
|
||||
#endif /* TPM_TPM_CRB_H */
|
||||
@@ -1,226 +0,0 @@
|
||||
/*
|
||||
* tpm_crb.c - QEMU's TPM CRB interface emulator
|
||||
*
|
||||
* Copyright (c) 2018 Red Hat, Inc.
|
||||
*
|
||||
* Authors:
|
||||
* Marc-André Lureau <marcandre.lureau@redhat.com>
|
||||
*
|
||||
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
||||
* See the COPYING file in the top-level directory.
|
||||
*
|
||||
* tpm_crb is a device for TPM 2.0 Command Response Buffer (CRB) Interface
|
||||
* as defined in TCG PC Client Platform TPM Profile (PTP) Specification
|
||||
* Family “2.0” Level 00 Revision 01.03 v22
|
||||
*/
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
|
||||
#include "qemu/module.h"
|
||||
#include "qapi/error.h"
|
||||
#include "exec/address-spaces.h"
|
||||
#include "hw/qdev-properties.h"
|
||||
#include "hw/pci/pci_ids.h"
|
||||
#include "hw/acpi/tpm.h"
|
||||
#include "migration/vmstate.h"
|
||||
#include "sysemu/tpm_backend.h"
|
||||
#include "sysemu/tpm_util.h"
|
||||
#include "sysemu/reset.h"
|
||||
#include "sysemu/xen.h"
|
||||
#include "tpm_prop.h"
|
||||
#include "tpm_ppi.h"
|
||||
#include "trace.h"
|
||||
#include "qom/object.h"
|
||||
#include "tpm_crb.h"
|
||||
|
||||
static uint8_t tpm_crb_get_active_locty(TPMCRBState *s, uint32_t *regs)
|
||||
{
|
||||
if (!ARRAY_FIELD_EX32(regs, CRB_LOC_STATE, locAssigned)) {
|
||||
return TPM_CRB_NO_LOCALITY;
|
||||
}
|
||||
return ARRAY_FIELD_EX32(regs, CRB_LOC_STATE, activeLocality);
|
||||
}
|
||||
|
||||
static void tpm_crb_mmio_write(void *opaque, hwaddr addr,
|
||||
uint64_t val, unsigned size)
|
||||
{
|
||||
TPMCRBState *s = opaque;
|
||||
uint8_t locty = addr >> 12;
|
||||
uint32_t *regs;
|
||||
void *mem;
|
||||
|
||||
trace_tpm_crb_mmio_write(addr, size, val);
|
||||
regs = memory_region_get_ram_ptr(&s->mmio);
|
||||
mem = ®s[R_CRB_DATA_BUFFER];
|
||||
assert(regs);
|
||||
|
||||
if (addr >= A_CRB_DATA_BUFFER) {
|
||||
assert(addr + size <= TPM_CRB_ADDR_SIZE);
|
||||
assert(size <= sizeof(val));
|
||||
memcpy(mem + addr - A_CRB_DATA_BUFFER, &val, size);
|
||||
memory_region_set_dirty(&s->mmio, addr, size);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (addr) {
|
||||
case A_CRB_CTRL_REQ:
|
||||
switch (val) {
|
||||
case CRB_CTRL_REQ_CMD_READY:
|
||||
ARRAY_FIELD_DP32(regs, CRB_CTRL_STS,
|
||||
tpmIdle, 0);
|
||||
break;
|
||||
case CRB_CTRL_REQ_GO_IDLE:
|
||||
ARRAY_FIELD_DP32(regs, CRB_CTRL_STS,
|
||||
tpmIdle, 1);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case A_CRB_CTRL_CANCEL:
|
||||
if (val == CRB_CANCEL_INVOKE &&
|
||||
regs[R_CRB_CTRL_START] & CRB_START_INVOKE) {
|
||||
tpm_backend_cancel_cmd(s->tpmbe);
|
||||
}
|
||||
break;
|
||||
case A_CRB_CTRL_START:
|
||||
if (val == CRB_START_INVOKE &&
|
||||
!(regs[R_CRB_CTRL_START] & CRB_START_INVOKE) &&
|
||||
tpm_crb_get_active_locty(s, regs) == locty) {
|
||||
|
||||
regs[R_CRB_CTRL_START] |= CRB_START_INVOKE;
|
||||
s->cmd = (TPMBackendCmd) {
|
||||
.in = mem,
|
||||
.in_len = MIN(tpm_cmd_get_size(mem), s->be_buffer_size),
|
||||
.out = mem,
|
||||
.out_len = s->be_buffer_size,
|
||||
};
|
||||
|
||||
tpm_backend_deliver_request(s->tpmbe, &s->cmd);
|
||||
}
|
||||
break;
|
||||
case A_CRB_LOC_CTRL:
|
||||
switch (val) {
|
||||
case CRB_LOC_CTRL_RESET_ESTABLISHMENT_BIT:
|
||||
/* not loc 3 or 4 */
|
||||
break;
|
||||
case CRB_LOC_CTRL_RELINQUISH:
|
||||
ARRAY_FIELD_DP32(regs, CRB_LOC_STATE,
|
||||
locAssigned, 0);
|
||||
ARRAY_FIELD_DP32(regs, CRB_LOC_STS,
|
||||
Granted, 0);
|
||||
break;
|
||||
case CRB_LOC_CTRL_REQUEST_ACCESS:
|
||||
ARRAY_FIELD_DP32(regs, CRB_LOC_STS,
|
||||
Granted, 1);
|
||||
ARRAY_FIELD_DP32(regs, CRB_LOC_STS,
|
||||
beenSeized, 0);
|
||||
ARRAY_FIELD_DP32(regs, CRB_LOC_STATE,
|
||||
locAssigned, 1);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
memory_region_set_dirty(&s->mmio, 0, A_CRB_DATA_BUFFER);
|
||||
}
|
||||
|
||||
const MemoryRegionOps tpm_crb_memory_ops = {
|
||||
.write = tpm_crb_mmio_write,
|
||||
.endianness = DEVICE_LITTLE_ENDIAN,
|
||||
.valid = {
|
||||
.min_access_size = 1,
|
||||
.max_access_size = 4,
|
||||
},
|
||||
};
|
||||
|
||||
void tpm_crb_request_completed(TPMCRBState *s, int ret)
|
||||
{
|
||||
uint32_t *regs = memory_region_get_ram_ptr(&s->mmio);
|
||||
|
||||
assert(regs);
|
||||
regs[R_CRB_CTRL_START] &= ~CRB_START_INVOKE;
|
||||
if (ret != 0) {
|
||||
ARRAY_FIELD_DP32(regs, CRB_CTRL_STS,
|
||||
tpmSts, 1); /* fatal error */
|
||||
}
|
||||
|
||||
memory_region_set_dirty(&s->mmio, 0, TPM_CRB_ADDR_SIZE);
|
||||
}
|
||||
|
||||
enum TPMVersion tpm_crb_get_version(TPMCRBState *s)
|
||||
{
|
||||
return tpm_backend_get_tpm_version(s->tpmbe);
|
||||
}
|
||||
|
||||
int tpm_crb_pre_save(TPMCRBState *s)
|
||||
{
|
||||
tpm_backend_finish_sync(s->tpmbe);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void tpm_crb_reset(TPMCRBState *s, uint64_t baseaddr)
|
||||
{
|
||||
uint32_t *regs = memory_region_get_ram_ptr(&s->mmio);
|
||||
|
||||
assert(regs);
|
||||
if (s->ppi_enabled) {
|
||||
tpm_ppi_reset(&s->ppi);
|
||||
}
|
||||
tpm_backend_reset(s->tpmbe);
|
||||
|
||||
memset(regs, 0, TPM_CRB_ADDR_SIZE);
|
||||
|
||||
ARRAY_FIELD_DP32(regs, CRB_LOC_STATE,
|
||||
tpmRegValidSts, 1);
|
||||
ARRAY_FIELD_DP32(regs, CRB_LOC_STATE,
|
||||
tpmEstablished, 1);
|
||||
ARRAY_FIELD_DP32(regs, CRB_CTRL_STS,
|
||||
tpmIdle, 1);
|
||||
ARRAY_FIELD_DP32(regs, CRB_INTF_ID,
|
||||
InterfaceType, CRB_INTF_TYPE_CRB_ACTIVE);
|
||||
ARRAY_FIELD_DP32(regs, CRB_INTF_ID,
|
||||
InterfaceVersion, CRB_INTF_VERSION_CRB);
|
||||
ARRAY_FIELD_DP32(regs, CRB_INTF_ID,
|
||||
CapLocality, CRB_INTF_CAP_LOCALITY_0_ONLY);
|
||||
ARRAY_FIELD_DP32(regs, CRB_INTF_ID,
|
||||
CapCRBIdleBypass, CRB_INTF_CAP_IDLE_FAST);
|
||||
ARRAY_FIELD_DP32(regs, CRB_INTF_ID,
|
||||
CapDataXferSizeSupport, CRB_INTF_CAP_XFER_SIZE_64);
|
||||
ARRAY_FIELD_DP32(regs, CRB_INTF_ID,
|
||||
CapFIFO, CRB_INTF_CAP_FIFO_NOT_SUPPORTED);
|
||||
ARRAY_FIELD_DP32(regs, CRB_INTF_ID,
|
||||
CapCRB, CRB_INTF_CAP_CRB_SUPPORTED);
|
||||
ARRAY_FIELD_DP32(regs, CRB_INTF_ID,
|
||||
InterfaceSelector, CRB_INTF_IF_SELECTOR_CRB);
|
||||
ARRAY_FIELD_DP32(regs, CRB_INTF_ID,
|
||||
RID, 0b0000);
|
||||
ARRAY_FIELD_DP32(regs, CRB_INTF_ID2,
|
||||
VID, PCI_VENDOR_ID_IBM);
|
||||
|
||||
baseaddr += A_CRB_DATA_BUFFER;
|
||||
regs[R_CRB_CTRL_CMD_SIZE] = CRB_CTRL_CMD_SIZE;
|
||||
regs[R_CRB_CTRL_CMD_LADDR] = (uint32_t)baseaddr;
|
||||
regs[R_CRB_CTRL_CMD_HADDR] = (uint32_t)(baseaddr >> 32);
|
||||
regs[R_CRB_CTRL_RSP_SIZE] = CRB_CTRL_CMD_SIZE;
|
||||
regs[R_CRB_CTRL_RSP_LADDR] = (uint32_t)baseaddr;
|
||||
regs[R_CRB_CTRL_RSP_HADDR] = (uint32_t)(baseaddr >> 32);
|
||||
|
||||
s->be_buffer_size = MIN(tpm_backend_get_buffer_size(s->tpmbe),
|
||||
CRB_CTRL_CMD_SIZE);
|
||||
|
||||
if (tpm_backend_startup_tpm(s->tpmbe, s->be_buffer_size) < 0) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
memory_region_rom_device_set_romd(&s->mmio, true);
|
||||
memory_region_set_dirty(&s->mmio, 0, TPM_CRB_ADDR_SIZE);
|
||||
}
|
||||
|
||||
void tpm_crb_init_memory(Object *obj, TPMCRBState *s, Error **errp)
|
||||
{
|
||||
memory_region_init_rom_device(&s->mmio, obj, &tpm_crb_memory_ops, s,
|
||||
"tpm-crb-mmio", ROUND_UP(TPM_CRB_ADDR_SIZE, qemu_host_page_size), errp);
|
||||
if (s->ppi_enabled) {
|
||||
tpm_ppi_init_memory(&s->ppi, obj);
|
||||
}
|
||||
}
|
||||
@@ -1,178 +0,0 @@
|
||||
/*
|
||||
* tpm_crb_sysbus.c - QEMU's TPM CRB interface emulator
|
||||
*
|
||||
* Copyright (c) 2018 Red Hat, Inc.
|
||||
*
|
||||
* Authors:
|
||||
* Marc-André Lureau <marcandre.lureau@redhat.com>
|
||||
*
|
||||
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
||||
* See the COPYING file in the top-level directory.
|
||||
*
|
||||
* tpm_crb is a device for TPM 2.0 Command Response Buffer (CRB) Interface
|
||||
* as defined in TCG PC Client Platform TPM Profile (PTP) Specification
|
||||
* Family “2.0” Level 00 Revision 01.03 v22
|
||||
*/
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
#include "hw/acpi/acpi_aml_interface.h"
|
||||
#include "hw/acpi/tpm.h"
|
||||
#include "hw/qdev-properties.h"
|
||||
#include "migration/vmstate.h"
|
||||
#include "tpm_prop.h"
|
||||
#include "hw/pci/pci_ids.h"
|
||||
#include "hw/sysbus.h"
|
||||
#include "qapi/visitor.h"
|
||||
#include "qom/object.h"
|
||||
#include "sysemu/tpm_util.h"
|
||||
#include "trace.h"
|
||||
#include "tpm_crb.h"
|
||||
|
||||
struct TPMCRBStateSysBus {
|
||||
/*< private >*/
|
||||
SysBusDevice parent_obj;
|
||||
|
||||
/*< public >*/
|
||||
TPMCRBState state;
|
||||
uint64_t baseaddr;
|
||||
uint64_t size;
|
||||
};
|
||||
|
||||
OBJECT_DECLARE_SIMPLE_TYPE(TPMCRBStateSysBus, TPM_CRB_SYSBUS)
|
||||
|
||||
static void tpm_crb_sysbus_request_completed(TPMIf *ti, int ret)
|
||||
{
|
||||
TPMCRBStateSysBus *s = TPM_CRB_SYSBUS(ti);
|
||||
|
||||
return tpm_crb_request_completed(&s->state, ret);
|
||||
}
|
||||
|
||||
static enum TPMVersion tpm_crb_sysbus_get_tpm_version(TPMIf *ti)
|
||||
{
|
||||
TPMCRBStateSysBus *s = TPM_CRB_SYSBUS(ti);
|
||||
|
||||
return tpm_crb_get_version(&s->state);
|
||||
}
|
||||
|
||||
static int tpm_crb_sysbus_pre_save(void *opaque)
|
||||
{
|
||||
TPMCRBStateSysBus *s = opaque;
|
||||
|
||||
return tpm_crb_pre_save(&s->state);
|
||||
}
|
||||
|
||||
static const VMStateDescription vmstate_tpm_crb_sysbus = {
|
||||
.name = "tpm-crb-sysbus",
|
||||
.pre_save = tpm_crb_sysbus_pre_save,
|
||||
.fields = (VMStateField[]) {
|
||||
VMSTATE_END_OF_LIST(),
|
||||
}
|
||||
};
|
||||
|
||||
static Property tpm_crb_sysbus_properties[] = {
|
||||
DEFINE_PROP_TPMBE("tpmdev", TPMCRBStateSysBus, state.tpmbe),
|
||||
DEFINE_PROP_BOOL("ppi", TPMCRBStateSysBus, state.ppi_enabled, false),
|
||||
DEFINE_PROP_UINT64("baseaddr", TPMCRBStateSysBus,
|
||||
baseaddr, TPM_CRB_ADDR_BASE),
|
||||
DEFINE_PROP_UINT64("size", TPMCRBStateSysBus, size, TPM_CRB_ADDR_SIZE),
|
||||
DEFINE_PROP_END_OF_LIST(),
|
||||
};
|
||||
|
||||
static void tpm_crb_sysbus_initfn(Object *obj)
|
||||
{
|
||||
TPMCRBStateSysBus *s = TPM_CRB_SYSBUS(obj);
|
||||
|
||||
tpm_crb_init_memory(obj, &s->state, NULL);
|
||||
|
||||
sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->state.mmio);
|
||||
}
|
||||
|
||||
static void tpm_crb_sysbus_reset(DeviceState *dev)
|
||||
{
|
||||
TPMCRBStateSysBus *s = TPM_CRB_SYSBUS(dev);
|
||||
|
||||
return tpm_crb_reset(&s->state, s->baseaddr);
|
||||
}
|
||||
|
||||
static void tpm_crb_sysbus_realizefn(DeviceState *dev, Error **errp)
|
||||
{
|
||||
TPMCRBStateSysBus *s = TPM_CRB_SYSBUS(dev);
|
||||
|
||||
if (!tpm_find()) {
|
||||
error_setg(errp, "at most one TPM device is permitted");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!s->state.tpmbe) {
|
||||
error_setg(errp, "'tpmdev' property is required");
|
||||
return;
|
||||
}
|
||||
|
||||
if (s->state.ppi_enabled) {
|
||||
sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->state.ppi.ram);
|
||||
}
|
||||
}
|
||||
|
||||
static void build_tpm_crb_sysbus_aml(AcpiDevAmlIf *adev, Aml *scope)
|
||||
{
|
||||
Aml *dev, *crs;
|
||||
TPMCRBStateSysBus *s = TPM_CRB_SYSBUS(adev);
|
||||
TPMIf *ti = TPM_IF(s);
|
||||
|
||||
dev = aml_device("TPM");
|
||||
if (tpm_crb_sysbus_get_tpm_version(ti) == TPM_VERSION_2_0) {
|
||||
aml_append(dev, aml_name_decl("_HID", aml_string("MSFT0101")));
|
||||
aml_append(dev, aml_name_decl("_STR", aml_string("TPM 2.0 Device")));
|
||||
} else {
|
||||
aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C31")));
|
||||
}
|
||||
aml_append(dev, aml_name_decl("_UID", aml_int(1)));
|
||||
aml_append(dev, aml_name_decl("_STA", aml_int(0xF)));
|
||||
crs = aml_resource_template();
|
||||
aml_append(crs, aml_memory32_fixed(s->baseaddr, s->size,
|
||||
AML_READ_WRITE));
|
||||
aml_append(dev, aml_name_decl("_CRS", crs));
|
||||
/**
|
||||
* FIXME: PPI needs to also get a dynamic address.
|
||||
*/
|
||||
/* tpm_build_ppi_acpi(ti, dev); */
|
||||
aml_append(scope, dev);
|
||||
}
|
||||
|
||||
static void tpm_crb_sysbus_class_init(ObjectClass *klass, void *data)
|
||||
{
|
||||
DeviceClass *dc = DEVICE_CLASS(klass);
|
||||
TPMIfClass *tc = TPM_IF_CLASS(klass);
|
||||
AcpiDevAmlIfClass *adevc = ACPI_DEV_AML_IF_CLASS(klass);
|
||||
|
||||
device_class_set_props(dc, tpm_crb_sysbus_properties);
|
||||
dc->vmsd = &vmstate_tpm_crb_sysbus;
|
||||
tc->model = TPM_MODEL_TPM_CRB;
|
||||
dc->realize = tpm_crb_sysbus_realizefn;
|
||||
dc->user_creatable = true;
|
||||
dc->reset = tpm_crb_sysbus_reset;
|
||||
tc->request_completed = tpm_crb_sysbus_request_completed;
|
||||
tc->get_version = tpm_crb_sysbus_get_tpm_version;
|
||||
set_bit(DEVICE_CATEGORY_MISC, dc->categories);
|
||||
adevc->build_dev_aml = build_tpm_crb_sysbus_aml;
|
||||
}
|
||||
|
||||
static const TypeInfo tpm_crb_sysbus_info = {
|
||||
.name = TYPE_TPM_CRB_SYSBUS,
|
||||
.parent = TYPE_SYS_BUS_DEVICE,
|
||||
.instance_size = sizeof(TPMCRBStateSysBus),
|
||||
.instance_init = tpm_crb_sysbus_initfn,
|
||||
.class_init = tpm_crb_sysbus_class_init,
|
||||
.interfaces = (InterfaceInfo[]) {
|
||||
{ TYPE_TPM_IF },
|
||||
{ TYPE_ACPI_DEV_AML_IF },
|
||||
{ }
|
||||
}
|
||||
};
|
||||
|
||||
static void tpm_crb_sysbus_register(void)
|
||||
{
|
||||
type_register_static(&tpm_crb_sysbus_info);
|
||||
}
|
||||
|
||||
type_init(tpm_crb_sysbus_register)
|
||||
+4
-1
@@ -44,11 +44,14 @@ void tpm_ppi_reset(TPMPPI *tpmppi)
|
||||
}
|
||||
}
|
||||
|
||||
void tpm_ppi_init_memory(TPMPPI *tpmppi, Object *obj)
|
||||
void tpm_ppi_init(TPMPPI *tpmppi, MemoryRegion *m,
|
||||
hwaddr addr, Object *obj)
|
||||
{
|
||||
tpmppi->buf = qemu_memalign(qemu_real_host_page_size(),
|
||||
HOST_PAGE_ALIGN(TPM_PPI_ADDR_SIZE));
|
||||
memory_region_init_ram_device_ptr(&tpmppi->ram, obj, "tpm-ppi",
|
||||
TPM_PPI_ADDR_SIZE, tpmppi->buf);
|
||||
vmstate_register_ram(&tpmppi->ram, DEVICE(obj));
|
||||
|
||||
memory_region_add_subregion(m, addr, &tpmppi->ram);
|
||||
}
|
||||
+7
-3
@@ -20,13 +20,17 @@ typedef struct TPMPPI {
|
||||
} TPMPPI;
|
||||
|
||||
/**
|
||||
* tpm_ppi_init_memory:
|
||||
* tpm_ppi_init:
|
||||
* @tpmppi: a TPMPPI
|
||||
* @m: the address-space / MemoryRegion to use
|
||||
* @addr: the address of the PPI region
|
||||
* @obj: the owner object
|
||||
*
|
||||
* Creates the TPM PPI memory region.
|
||||
* Register the TPM PPI memory region at @addr on the given address
|
||||
* space for the object @obj.
|
||||
**/
|
||||
void tpm_ppi_init_memory(TPMPPI *tpmppi, Object *obj);
|
||||
void tpm_ppi_init(TPMPPI *tpmppi, MemoryRegion *m,
|
||||
hwaddr addr, Object *obj);
|
||||
|
||||
/**
|
||||
* tpm_ppi_reset:
|
||||
|
||||
@@ -134,9 +134,8 @@ static void tpm_tis_isa_realizefn(DeviceState *dev, Error **errp)
|
||||
TPM_TIS_ADDR_BASE, &s->mmio);
|
||||
|
||||
if (s->ppi_enabled) {
|
||||
tpm_ppi_init_memory(&s->ppi, OBJECT(dev));
|
||||
memory_region_add_subregion(isa_address_space(ISA_DEVICE(dev)),
|
||||
TPM_PPI_ADDR_BASE, &s->ppi.ram);
|
||||
tpm_ppi_init(&s->ppi, isa_address_space(ISA_DEVICE(dev)),
|
||||
TPM_PPI_ADDR_BASE, OBJECT(dev));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
#include "hw/sysbus.h"
|
||||
#include "tpm_tis.h"
|
||||
#include "qom/object.h"
|
||||
#include "hw/acpi/acpi_aml_interface.h"
|
||||
|
||||
struct TPMStateSysBus {
|
||||
/*< private >*/
|
||||
@@ -38,8 +37,6 @@ struct TPMStateSysBus {
|
||||
|
||||
/*< public >*/
|
||||
TPMState state; /* not a QOM object */
|
||||
uint64_t baseaddr;
|
||||
uint64_t size;
|
||||
};
|
||||
|
||||
OBJECT_DECLARE_SIMPLE_TYPE(TPMStateSysBus, TPM_TIS_SYSBUS)
|
||||
@@ -97,8 +94,6 @@ static Property tpm_tis_sysbus_properties[] = {
|
||||
DEFINE_PROP_UINT32("irq", TPMStateSysBus, state.irq_num, TPM_TIS_IRQ),
|
||||
DEFINE_PROP_TPMBE("tpmdev", TPMStateSysBus, state.be_driver),
|
||||
DEFINE_PROP_BOOL("ppi", TPMStateSysBus, state.ppi_enabled, false),
|
||||
DEFINE_PROP_UINT64("baseaddr", TPMStateSysBus, baseaddr, TPM_TIS_ADDR_BASE),
|
||||
DEFINE_PROP_UINT64("size", TPMStateSysBus, size, TPM_TIS_ADDR_SIZE),
|
||||
DEFINE_PROP_END_OF_LIST(),
|
||||
};
|
||||
|
||||
@@ -129,48 +124,12 @@ static void tpm_tis_sysbus_realizefn(DeviceState *dev, Error **errp)
|
||||
error_setg(errp, "'tpmdev' property is required");
|
||||
return;
|
||||
}
|
||||
|
||||
if (s->ppi_enabled) {
|
||||
sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->ppi.ram);
|
||||
}
|
||||
}
|
||||
|
||||
static void build_tpm_tis_sysbus_aml(AcpiDevAmlIf *adev, Aml *scope)
|
||||
{
|
||||
Aml *dev, *crs;
|
||||
TPMStateSysBus *sbdev = TPM_TIS_SYSBUS(adev);
|
||||
TPMIf *ti = TPM_IF(sbdev);
|
||||
|
||||
dev = aml_device("TPM");
|
||||
if (tpm_tis_sysbus_get_tpm_version(ti) == TPM_VERSION_2_0) {
|
||||
aml_append(dev, aml_name_decl("_HID", aml_string("MSFT0101")));
|
||||
aml_append(dev, aml_name_decl("_STR", aml_string("TPM 2.0 Device")));
|
||||
} else {
|
||||
aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C31")));
|
||||
}
|
||||
aml_append(dev, aml_name_decl("_UID", aml_int(1)));
|
||||
aml_append(dev, aml_name_decl("_STA", aml_int(0xF)));
|
||||
crs = aml_resource_template();
|
||||
aml_append(crs, aml_memory32_fixed(sbdev->baseaddr, sbdev->size,
|
||||
AML_READ_WRITE));
|
||||
/*
|
||||
* FIXME: TPM_TIS_IRQ=5 conflicts with PNP0C0F irqs,
|
||||
* fix default TPM_TIS_IRQ value there to use some unused IRQ
|
||||
*/
|
||||
/* aml_append(crs, aml_irq_no_flags(sbdev->state.irq_num)); */
|
||||
aml_append(dev, aml_name_decl("_CRS", crs));
|
||||
/**
|
||||
* FIXME: PPI needs to also get a dynamic address.
|
||||
*/
|
||||
/* tpm_build_ppi_acpi(ti, dev); */
|
||||
aml_append(scope, dev);
|
||||
}
|
||||
|
||||
static void tpm_tis_sysbus_class_init(ObjectClass *klass, void *data)
|
||||
{
|
||||
DeviceClass *dc = DEVICE_CLASS(klass);
|
||||
TPMIfClass *tc = TPM_IF_CLASS(klass);
|
||||
AcpiDevAmlIfClass *adevc = ACPI_DEV_AML_IF_CLASS(klass);
|
||||
|
||||
device_class_set_props(dc, tpm_tis_sysbus_properties);
|
||||
dc->vmsd = &vmstate_tpm_tis_sysbus;
|
||||
@@ -181,7 +140,6 @@ static void tpm_tis_sysbus_class_init(ObjectClass *klass, void *data)
|
||||
tc->request_completed = tpm_tis_sysbus_request_completed;
|
||||
tc->get_version = tpm_tis_sysbus_get_tpm_version;
|
||||
set_bit(DEVICE_CATEGORY_MISC, dc->categories);
|
||||
adevc->build_dev_aml = build_tpm_tis_sysbus_aml;
|
||||
}
|
||||
|
||||
static const TypeInfo tpm_tis_sysbus_info = {
|
||||
@@ -192,7 +150,6 @@ static const TypeInfo tpm_tis_sysbus_info = {
|
||||
.class_init = tpm_tis_sysbus_class_init,
|
||||
.interfaces = (InterfaceInfo[]) {
|
||||
{ TYPE_TPM_IF },
|
||||
{ TYPE_ACPI_DEV_AML_IF },
|
||||
{ }
|
||||
}
|
||||
};
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
# See docs/devel/tracing.rst for syntax documentation.
|
||||
|
||||
# tpm_crb_common.c
|
||||
# tpm_crb.c
|
||||
tpm_crb_mmio_read(uint64_t addr, unsigned size, uint32_t val) "CRB read 0x%016" PRIx64 " len:%u val: 0x%" PRIx32
|
||||
tpm_crb_mmio_write(uint64_t addr, unsigned size, uint32_t val) "CRB write 0x%016" PRIx64 " len:%u val: 0x%" PRIx32
|
||||
|
||||
|
||||
+1
-2
@@ -1280,8 +1280,7 @@ static void usbredir_create_parser(USBRedirDevice *dev)
|
||||
}
|
||||
#endif
|
||||
|
||||
if (runstate_check(RUN_STATE_INMIGRATE) ||
|
||||
runstate_check(RUN_STATE_RESTORE_VM)) {
|
||||
if (runstate_check(RUN_STATE_INMIGRATE)) {
|
||||
flags |= usbredirparser_fl_no_hello;
|
||||
}
|
||||
usbredirparser_init(dev->parser, VERSION, caps, USB_REDIR_CAPS_SIZE,
|
||||
|
||||
+11
-4
@@ -663,6 +663,8 @@ static void vfio_msi_enable(VFIOPCIDevice *vdev)
|
||||
|
||||
vfio_disable_interrupts(vdev);
|
||||
|
||||
vdev->nr_vectors = msi_nr_vectors_allocated(&vdev->pdev);
|
||||
retry:
|
||||
/*
|
||||
* Setting vector notifiers needs to enable route for each vector.
|
||||
* Deferring to commit the KVM routes once rather than per vector
|
||||
@@ -670,8 +672,6 @@ static void vfio_msi_enable(VFIOPCIDevice *vdev)
|
||||
*/
|
||||
vfio_prepare_kvm_msi_virq_batch(vdev);
|
||||
|
||||
vdev->nr_vectors = msi_nr_vectors_allocated(&vdev->pdev);
|
||||
retry:
|
||||
vdev->msi_vectors = g_new0(VFIOMSIVector, vdev->nr_vectors);
|
||||
|
||||
for (i = 0; i < vdev->nr_vectors; i++) {
|
||||
@@ -1752,9 +1752,11 @@ static void vfio_bars_finalize(VFIOPCIDevice *vdev)
|
||||
|
||||
vfio_bar_quirk_finalize(vdev, i);
|
||||
vfio_region_finalize(&bar->region);
|
||||
if (bar->size) {
|
||||
if (bar->mr) {
|
||||
assert(bar->size);
|
||||
object_unparent(OBJECT(bar->mr));
|
||||
g_free(bar->mr);
|
||||
bar->mr = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3158,8 +3160,13 @@ static void vfio_realize(PCIDevice *pdev, Error **errp)
|
||||
return;
|
||||
|
||||
out_deregister:
|
||||
if (vdev->interrupt == VFIO_INT_INTx) {
|
||||
vfio_intx_disable(vdev);
|
||||
}
|
||||
pci_device_set_intx_routing_notifier(&vdev->pdev, NULL);
|
||||
kvm_irqchip_remove_change_notifier(&vdev->irqchip_change_notifier);
|
||||
if (vdev->irqchip_change_notifier.notify) {
|
||||
kvm_irqchip_remove_change_notifier(&vdev->irqchip_change_notifier);
|
||||
}
|
||||
out_teardown:
|
||||
vfio_teardown_msi(vdev);
|
||||
vfio_bars_exit(vdev);
|
||||
|
||||
@@ -15,3 +15,7 @@ bool vhost_user_init(VhostUserState *user, CharBackend *chr, Error **errp)
|
||||
void vhost_user_cleanup(VhostUserState *user)
|
||||
{
|
||||
}
|
||||
|
||||
void vhost_toggle_device_iotlb(VirtIODevice *vdev)
|
||||
{
|
||||
}
|
||||
+69
-42
@@ -781,7 +781,6 @@ static void vhost_iommu_region_add(MemoryListener *listener,
|
||||
Int128 end;
|
||||
int iommu_idx;
|
||||
IOMMUMemoryRegion *iommu_mr;
|
||||
int ret;
|
||||
|
||||
if (!memory_region_is_iommu(section->mr)) {
|
||||
return;
|
||||
@@ -796,7 +795,9 @@ static void vhost_iommu_region_add(MemoryListener *listener,
|
||||
iommu_idx = memory_region_iommu_attrs_to_index(iommu_mr,
|
||||
MEMTXATTRS_UNSPECIFIED);
|
||||
iommu_notifier_init(&iommu->n, vhost_iommu_unmap_notify,
|
||||
IOMMU_NOTIFIER_DEVIOTLB_UNMAP,
|
||||
dev->vdev->device_iotlb_enabled ?
|
||||
IOMMU_NOTIFIER_DEVIOTLB_UNMAP :
|
||||
IOMMU_NOTIFIER_UNMAP,
|
||||
section->offset_within_region,
|
||||
int128_get64(end),
|
||||
iommu_idx);
|
||||
@@ -804,16 +805,8 @@ static void vhost_iommu_region_add(MemoryListener *listener,
|
||||
iommu->iommu_offset = section->offset_within_address_space -
|
||||
section->offset_within_region;
|
||||
iommu->hdev = dev;
|
||||
ret = memory_region_register_iommu_notifier(section->mr, &iommu->n, NULL);
|
||||
if (ret) {
|
||||
/*
|
||||
* Some vIOMMUs do not support dev-iotlb yet. If so, try to use the
|
||||
* UNMAP legacy message
|
||||
*/
|
||||
iommu->n.notifier_flags = IOMMU_NOTIFIER_UNMAP;
|
||||
memory_region_register_iommu_notifier(section->mr, &iommu->n,
|
||||
&error_fatal);
|
||||
}
|
||||
memory_region_register_iommu_notifier(section->mr, &iommu->n,
|
||||
&error_fatal);
|
||||
QLIST_INSERT_HEAD(&dev->iommu_list, iommu, iommu_next);
|
||||
/* TODO: can replay help performance here? */
|
||||
}
|
||||
@@ -841,6 +834,27 @@ static void vhost_iommu_region_del(MemoryListener *listener,
|
||||
}
|
||||
}
|
||||
|
||||
void vhost_toggle_device_iotlb(VirtIODevice *vdev)
|
||||
{
|
||||
VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(vdev);
|
||||
struct vhost_dev *dev;
|
||||
struct vhost_iommu *iommu;
|
||||
|
||||
if (vdev->vhost_started) {
|
||||
dev = vdc->get_vhost(vdev);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
QLIST_FOREACH(iommu, &dev->iommu_list, iommu_next) {
|
||||
memory_region_unregister_iommu_notifier(iommu->mr, &iommu->n);
|
||||
iommu->n.notifier_flags = vdev->device_iotlb_enabled ?
|
||||
IOMMU_NOTIFIER_DEVIOTLB_UNMAP : IOMMU_NOTIFIER_UNMAP;
|
||||
memory_region_register_iommu_notifier(iommu->mr, &iommu->n,
|
||||
&error_fatal);
|
||||
}
|
||||
}
|
||||
|
||||
static int vhost_virtqueue_set_addr(struct vhost_dev *dev,
|
||||
struct vhost_virtqueue *vq,
|
||||
unsigned idx, bool enable_log)
|
||||
@@ -1545,6 +1559,40 @@ void vhost_dev_cleanup(struct vhost_dev *hdev)
|
||||
memset(hdev, 0, sizeof(struct vhost_dev));
|
||||
}
|
||||
|
||||
static void vhost_dev_disable_notifiers_nvqs(struct vhost_dev *hdev,
|
||||
VirtIODevice *vdev,
|
||||
unsigned int nvqs)
|
||||
{
|
||||
BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev)));
|
||||
int i, r;
|
||||
|
||||
/*
|
||||
* Batch all the host notifiers in a single transaction to avoid
|
||||
* quadratic time complexity in address_space_update_ioeventfds().
|
||||
*/
|
||||
memory_region_transaction_begin();
|
||||
|
||||
for (i = 0; i < nvqs; ++i) {
|
||||
r = virtio_bus_set_host_notifier(VIRTIO_BUS(qbus), hdev->vq_index + i,
|
||||
false);
|
||||
if (r < 0) {
|
||||
error_report("vhost VQ %d notifier cleanup failed: %d", i, -r);
|
||||
}
|
||||
assert(r >= 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* The transaction expects the ioeventfds to be open when it
|
||||
* commits. Do it now, before the cleanup loop.
|
||||
*/
|
||||
memory_region_transaction_commit();
|
||||
|
||||
for (i = 0; i < nvqs; ++i) {
|
||||
virtio_bus_cleanup_host_notifier(VIRTIO_BUS(qbus), hdev->vq_index + i);
|
||||
}
|
||||
virtio_device_release_ioeventfd(vdev);
|
||||
}
|
||||
|
||||
/* Stop processing guest IO notifications in qemu.
|
||||
* Start processing them in vhost in kernel.
|
||||
*/
|
||||
@@ -1574,7 +1622,7 @@ int vhost_dev_enable_notifiers(struct vhost_dev *hdev, VirtIODevice *vdev)
|
||||
if (r < 0) {
|
||||
error_report("vhost VQ %d notifier binding failed: %d", i, -r);
|
||||
memory_region_transaction_commit();
|
||||
vhost_dev_disable_notifiers(hdev, vdev);
|
||||
vhost_dev_disable_notifiers_nvqs(hdev, vdev, i);
|
||||
return r;
|
||||
}
|
||||
}
|
||||
@@ -1591,34 +1639,7 @@ int vhost_dev_enable_notifiers(struct vhost_dev *hdev, VirtIODevice *vdev)
|
||||
*/
|
||||
void vhost_dev_disable_notifiers(struct vhost_dev *hdev, VirtIODevice *vdev)
|
||||
{
|
||||
BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev)));
|
||||
int i, r;
|
||||
|
||||
/*
|
||||
* Batch all the host notifiers in a single transaction to avoid
|
||||
* quadratic time complexity in address_space_update_ioeventfds().
|
||||
*/
|
||||
memory_region_transaction_begin();
|
||||
|
||||
for (i = 0; i < hdev->nvqs; ++i) {
|
||||
r = virtio_bus_set_host_notifier(VIRTIO_BUS(qbus), hdev->vq_index + i,
|
||||
false);
|
||||
if (r < 0) {
|
||||
error_report("vhost VQ %d notifier cleanup failed: %d", i, -r);
|
||||
}
|
||||
assert (r >= 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* The transaction expects the ioeventfds to be open when it
|
||||
* commits. Do it now, before the cleanup loop.
|
||||
*/
|
||||
memory_region_transaction_commit();
|
||||
|
||||
for (i = 0; i < hdev->nvqs; ++i) {
|
||||
virtio_bus_cleanup_host_notifier(VIRTIO_BUS(qbus), hdev->vq_index + i);
|
||||
}
|
||||
virtio_device_release_ioeventfd(vdev);
|
||||
vhost_dev_disable_notifiers_nvqs(hdev, vdev, hdev->nvqs);
|
||||
}
|
||||
|
||||
/* Test and clear event pending status.
|
||||
@@ -1956,7 +1977,8 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev, bool vrings)
|
||||
r = event_notifier_init(
|
||||
&hdev->vqs[VHOST_QUEUE_NUM_CONFIG_INR].masked_config_notifier, 0);
|
||||
if (r < 0) {
|
||||
return r;
|
||||
VHOST_OPS_DEBUG(r, "event_notifier_init failed");
|
||||
goto fail_vq;
|
||||
}
|
||||
event_notifier_test_and_clear(
|
||||
&hdev->vqs[VHOST_QUEUE_NUM_CONFIG_INR].masked_config_notifier);
|
||||
@@ -2018,6 +2040,9 @@ fail_vq:
|
||||
}
|
||||
|
||||
fail_mem:
|
||||
if (vhost_dev_has_iommu(hdev)) {
|
||||
memory_listener_unregister(&hdev->iommu_listener);
|
||||
}
|
||||
fail_features:
|
||||
vdev->vhost_started = false;
|
||||
hdev->started = false;
|
||||
@@ -2034,6 +2059,8 @@ void vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev, bool vrings)
|
||||
event_notifier_test_and_clear(
|
||||
&hdev->vqs[VHOST_QUEUE_NUM_CONFIG_INR].masked_config_notifier);
|
||||
event_notifier_test_and_clear(&vdev->config_notifier);
|
||||
event_notifier_cleanup(
|
||||
&hdev->vqs[VHOST_QUEUE_NUM_CONFIG_INR].masked_config_notifier);
|
||||
|
||||
trace_vhost_dev_stop(hdev, vdev->name, vrings);
|
||||
|
||||
|
||||
@@ -635,6 +635,11 @@ virtio_crypto_sym_op_helper(VirtIODevice *vdev,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (unlikely(src_len != dst_len)) {
|
||||
virtio_error(vdev, "sym request src len is different from dst len");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
max_len = (uint64_t)iv_len + aad_len + src_len + dst_len + hash_result_len;
|
||||
if (unlikely(max_len > vcrypto->conf.max_size)) {
|
||||
virtio_error(vdev, "virtio-crypto too big length");
|
||||
|
||||
@@ -727,13 +727,15 @@ static void virtio_iommu_handle_command(VirtIODevice *vdev, VirtQueue *vq)
|
||||
VirtIOIOMMU *s = VIRTIO_IOMMU(vdev);
|
||||
struct virtio_iommu_req_head head;
|
||||
struct virtio_iommu_req_tail tail = {};
|
||||
size_t output_size = sizeof(tail), sz;
|
||||
VirtQueueElement *elem;
|
||||
unsigned int iov_cnt;
|
||||
struct iovec *iov;
|
||||
void *buf = NULL;
|
||||
size_t sz;
|
||||
|
||||
for (;;) {
|
||||
size_t output_size = sizeof(tail);
|
||||
|
||||
elem = virtqueue_pop(vq, sizeof(VirtQueueElement));
|
||||
if (!elem) {
|
||||
return;
|
||||
|
||||
@@ -716,6 +716,38 @@ virtio_address_space_read(VirtIOPCIProxy *proxy, hwaddr addr,
|
||||
}
|
||||
}
|
||||
|
||||
static void virtio_pci_ats_ctrl_trigger(PCIDevice *pci_dev, bool enable)
|
||||
{
|
||||
VirtIOPCIProxy *proxy = VIRTIO_PCI(pci_dev);
|
||||
VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
|
||||
VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
|
||||
|
||||
vdev->device_iotlb_enabled = enable;
|
||||
|
||||
if (k->toggle_device_iotlb) {
|
||||
k->toggle_device_iotlb(vdev);
|
||||
}
|
||||
}
|
||||
|
||||
static void pcie_ats_config_write(PCIDevice *dev, uint32_t address,
|
||||
uint32_t val, int len)
|
||||
{
|
||||
uint32_t off;
|
||||
uint16_t ats_cap = dev->exp.ats_cap;
|
||||
|
||||
if (!ats_cap || address < ats_cap) {
|
||||
return;
|
||||
}
|
||||
off = address - ats_cap;
|
||||
if (off >= PCI_EXT_CAP_ATS_SIZEOF) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (range_covers_byte(off, len, PCI_ATS_CTRL + 1)) {
|
||||
virtio_pci_ats_ctrl_trigger(dev, !!(val & PCI_ATS_CTRL_ENABLE));
|
||||
}
|
||||
}
|
||||
|
||||
static void virtio_write_config(PCIDevice *pci_dev, uint32_t address,
|
||||
uint32_t val, int len)
|
||||
{
|
||||
@@ -729,6 +761,10 @@ static void virtio_write_config(PCIDevice *pci_dev, uint32_t address,
|
||||
pcie_cap_flr_write_config(pci_dev, address, val, len);
|
||||
}
|
||||
|
||||
if (proxy->flags & VIRTIO_PCI_FLAG_ATS) {
|
||||
pcie_ats_config_write(pci_dev, address, val, len);
|
||||
}
|
||||
|
||||
if (range_covers_byte(address, len, PCI_COMMAND)) {
|
||||
if (!(pci_dev->config[PCI_COMMAND] & PCI_COMMAND_MASTER)) {
|
||||
virtio_set_disabled(vdev, true);
|
||||
|
||||
@@ -287,7 +287,7 @@ static void watch_event(void *opaque)
|
||||
static struct qemu_xs_handle *libxenstore_open(void)
|
||||
{
|
||||
struct xs_handle *xsh = xs_open(0);
|
||||
struct qemu_xs_handle *h = g_new0(struct qemu_xs_handle, 1);
|
||||
struct qemu_xs_handle *h;
|
||||
|
||||
if (!xsh) {
|
||||
return NULL;
|
||||
|
||||
@@ -412,7 +412,6 @@ typedef struct disassemble_info {
|
||||
typedef int (*disassembler_ftype) (bfd_vma, disassemble_info *);
|
||||
|
||||
int print_insn_tci(bfd_vma, disassemble_info*);
|
||||
int print_insn_tcti(bfd_vma, disassemble_info*);
|
||||
int print_insn_big_mips (bfd_vma, disassemble_info*);
|
||||
int print_insn_little_mips (bfd_vma, disassemble_info*);
|
||||
int print_insn_nanomips (bfd_vma, disassemble_info*);
|
||||
|
||||
@@ -685,11 +685,7 @@ void tb_set_jmp_target(TranslationBlock *tb, int n, uintptr_t addr);
|
||||
#if defined(CONFIG_TCG_INTERPRETER)
|
||||
extern __thread uintptr_t tci_tb_ptr;
|
||||
# define GETPC() tci_tb_ptr
|
||||
#elif defined(CONFIG_TCG_THREADED_INTERPRETER)
|
||||
extern __thread uintptr_t tcti_call_return_address;
|
||||
# define GETPC() tcti_call_return_address
|
||||
#else
|
||||
/* Note that this is correct for TCTI also; whose gadget behaves like native code. */
|
||||
# define GETPC() \
|
||||
((uintptr_t)__builtin_extract_return_addr(__builtin_return_address(0)))
|
||||
#endif
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
#include "hw/acpi/acpi-defs.h"
|
||||
#include "hw/acpi/bios-linker-loader.h"
|
||||
#include "exec/hwaddr.h"
|
||||
|
||||
#define ACPI_BUILD_APPNAME6 "BOCHS "
|
||||
#define ACPI_BUILD_APPNAME8 "BXPC "
|
||||
|
||||
@@ -173,8 +173,7 @@ REG32(CRB_CTRL_CMD_SIZE, 0x58)
|
||||
REG32(CRB_CTRL_CMD_LADDR, 0x5C)
|
||||
REG32(CRB_CTRL_CMD_HADDR, 0x60)
|
||||
REG32(CRB_CTRL_RSP_SIZE, 0x64)
|
||||
REG32(CRB_CTRL_RSP_LADDR, 0x68)
|
||||
REG32(CRB_CTRL_RSP_HADDR, 0x6C)
|
||||
REG32(CRB_CTRL_RSP_ADDR, 0x68)
|
||||
REG32(CRB_DATA_BUFFER, 0x80)
|
||||
|
||||
#define TPM_CRB_ADDR_BASE 0xFED40000
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
* File: screamer.h
|
||||
* Description: header file to the hw/audio/screamer.c file
|
||||
*/
|
||||
|
||||
#ifndef screamer_h
|
||||
#define screamer_h
|
||||
|
||||
#include <inttypes.h>
|
||||
#include "audio/audio.h"
|
||||
#include "hw/ppc/mac_dbdma.h"
|
||||
|
||||
#define TYPE_SCREAMER "screamer"
|
||||
#define SCREAMER(obj) OBJECT_CHECK(ScreamerState, (obj), TYPE_SCREAMER)
|
||||
#define SOUND_CHIP_NAME "Screamer Sound Chip"
|
||||
#define MAX_BUFFER_SIZE (128 * 64)
|
||||
|
||||
typedef struct ScreamerState {
|
||||
SysBusDevice parent_obj;
|
||||
uint16_t awacs[8]; /* Shadow/awacs registers */
|
||||
uint32_t sound_control;
|
||||
uint32_t codec_control;
|
||||
uint32_t codec_status;
|
||||
uint32_t clip_count;
|
||||
uint32_t byte_swap;
|
||||
uint32_t frame_count;
|
||||
SWVoiceOut *speaker_voice;
|
||||
DBDMAState *dbdma;
|
||||
qemu_irq dma_send_irq;
|
||||
qemu_irq dma_receive_irq;
|
||||
qemu_irq irq;
|
||||
QEMUSoundCard card;
|
||||
MemoryRegion io_memory_region;
|
||||
uint8_t spk_buffer[MAX_BUFFER_SIZE];
|
||||
uint16_t spk_buffer_position, spk_play_position;
|
||||
DBDMA_io dma_io;
|
||||
} ScreamerState;
|
||||
|
||||
void screamer_register_dma_functions(ScreamerState *s, void *dbdma,
|
||||
int send_channel, int receive_channel);
|
||||
|
||||
#endif /* screamer_h */
|
||||
@@ -178,37 +178,39 @@ enum {
|
||||
union VTD_IR_TableEntry {
|
||||
struct {
|
||||
#if HOST_BIG_ENDIAN
|
||||
uint32_t __reserved_1:8; /* Reserved 1 */
|
||||
uint32_t vector:8; /* Interrupt Vector */
|
||||
uint32_t irte_mode:1; /* IRTE Mode */
|
||||
uint32_t __reserved_0:3; /* Reserved 0 */
|
||||
uint32_t __avail:4; /* Available spaces for software */
|
||||
uint32_t delivery_mode:3; /* Delivery Mode */
|
||||
uint32_t trigger_mode:1; /* Trigger Mode */
|
||||
uint32_t redir_hint:1; /* Redirection Hint */
|
||||
uint32_t dest_mode:1; /* Destination Mode */
|
||||
uint32_t fault_disable:1; /* Fault Processing Disable */
|
||||
uint32_t present:1; /* Whether entry present/available */
|
||||
uint64_t dest_id:32; /* Destination ID */
|
||||
uint64_t __reserved_1:8; /* Reserved 1 */
|
||||
uint64_t vector:8; /* Interrupt Vector */
|
||||
uint64_t irte_mode:1; /* IRTE Mode */
|
||||
uint64_t __reserved_0:3; /* Reserved 0 */
|
||||
uint64_t __avail:4; /* Available spaces for software */
|
||||
uint64_t delivery_mode:3; /* Delivery Mode */
|
||||
uint64_t trigger_mode:1; /* Trigger Mode */
|
||||
uint64_t redir_hint:1; /* Redirection Hint */
|
||||
uint64_t dest_mode:1; /* Destination Mode */
|
||||
uint64_t fault_disable:1; /* Fault Processing Disable */
|
||||
uint64_t present:1; /* Whether entry present/available */
|
||||
#else
|
||||
uint32_t present:1; /* Whether entry present/available */
|
||||
uint32_t fault_disable:1; /* Fault Processing Disable */
|
||||
uint32_t dest_mode:1; /* Destination Mode */
|
||||
uint32_t redir_hint:1; /* Redirection Hint */
|
||||
uint32_t trigger_mode:1; /* Trigger Mode */
|
||||
uint32_t delivery_mode:3; /* Delivery Mode */
|
||||
uint32_t __avail:4; /* Available spaces for software */
|
||||
uint32_t __reserved_0:3; /* Reserved 0 */
|
||||
uint32_t irte_mode:1; /* IRTE Mode */
|
||||
uint32_t vector:8; /* Interrupt Vector */
|
||||
uint32_t __reserved_1:8; /* Reserved 1 */
|
||||
uint64_t present:1; /* Whether entry present/available */
|
||||
uint64_t fault_disable:1; /* Fault Processing Disable */
|
||||
uint64_t dest_mode:1; /* Destination Mode */
|
||||
uint64_t redir_hint:1; /* Redirection Hint */
|
||||
uint64_t trigger_mode:1; /* Trigger Mode */
|
||||
uint64_t delivery_mode:3; /* Delivery Mode */
|
||||
uint64_t __avail:4; /* Available spaces for software */
|
||||
uint64_t __reserved_0:3; /* Reserved 0 */
|
||||
uint64_t irte_mode:1; /* IRTE Mode */
|
||||
uint64_t vector:8; /* Interrupt Vector */
|
||||
uint64_t __reserved_1:8; /* Reserved 1 */
|
||||
uint64_t dest_id:32; /* Destination ID */
|
||||
#endif
|
||||
uint32_t dest_id; /* Destination ID */
|
||||
uint16_t source_id; /* Source-ID */
|
||||
#if HOST_BIG_ENDIAN
|
||||
uint64_t __reserved_2:44; /* Reserved 2 */
|
||||
uint64_t sid_vtype:2; /* Source-ID Validation Type */
|
||||
uint64_t sid_q:2; /* Source-ID Qualifier */
|
||||
uint64_t source_id:16; /* Source-ID */
|
||||
#else
|
||||
uint64_t source_id:16; /* Source-ID */
|
||||
uint64_t sid_q:2; /* Source-ID Qualifier */
|
||||
uint64_t sid_vtype:2; /* Source-ID Validation Type */
|
||||
uint64_t __reserved_2:44; /* Reserved 2 */
|
||||
|
||||
+26
-24
@@ -87,40 +87,42 @@ struct X86IOMMU_MSIMessage {
|
||||
union {
|
||||
struct {
|
||||
#if HOST_BIG_ENDIAN
|
||||
uint32_t __addr_head:12; /* 0xfee */
|
||||
uint32_t dest:8;
|
||||
uint32_t __reserved:8;
|
||||
uint32_t redir_hint:1;
|
||||
uint32_t dest_mode:1;
|
||||
uint32_t __not_used:2;
|
||||
uint64_t __addr_hi:32;
|
||||
uint64_t __addr_head:12; /* 0xfee */
|
||||
uint64_t dest:8;
|
||||
uint64_t __reserved:8;
|
||||
uint64_t redir_hint:1;
|
||||
uint64_t dest_mode:1;
|
||||
uint64_t __not_used:2;
|
||||
#else
|
||||
uint32_t __not_used:2;
|
||||
uint32_t dest_mode:1;
|
||||
uint32_t redir_hint:1;
|
||||
uint32_t __reserved:8;
|
||||
uint32_t dest:8;
|
||||
uint32_t __addr_head:12; /* 0xfee */
|
||||
uint64_t __not_used:2;
|
||||
uint64_t dest_mode:1;
|
||||
uint64_t redir_hint:1;
|
||||
uint64_t __reserved:8;
|
||||
uint64_t dest:8;
|
||||
uint64_t __addr_head:12; /* 0xfee */
|
||||
uint64_t __addr_hi:32;
|
||||
#endif
|
||||
uint32_t __addr_hi;
|
||||
} QEMU_PACKED;
|
||||
uint64_t msi_addr;
|
||||
};
|
||||
union {
|
||||
struct {
|
||||
#if HOST_BIG_ENDIAN
|
||||
uint16_t trigger_mode:1;
|
||||
uint16_t level:1;
|
||||
uint16_t __resved:3;
|
||||
uint16_t delivery_mode:3;
|
||||
uint16_t vector:8;
|
||||
uint32_t __resved1:16;
|
||||
uint32_t trigger_mode:1;
|
||||
uint32_t level:1;
|
||||
uint32_t __resved:3;
|
||||
uint32_t delivery_mode:3;
|
||||
uint32_t vector:8;
|
||||
#else
|
||||
uint16_t vector:8;
|
||||
uint16_t delivery_mode:3;
|
||||
uint16_t __resved:3;
|
||||
uint16_t level:1;
|
||||
uint16_t trigger_mode:1;
|
||||
uint32_t vector:8;
|
||||
uint32_t delivery_mode:3;
|
||||
uint32_t __resved:3;
|
||||
uint32_t level:1;
|
||||
uint32_t trigger_mode:1;
|
||||
uint32_t __resved1:16;
|
||||
#endif
|
||||
uint16_t __resved1;
|
||||
} QEMU_PACKED;
|
||||
uint32_t msi_data;
|
||||
};
|
||||
|
||||
@@ -36,7 +36,6 @@
|
||||
#include "hw/nvram/mac_nvram.h"
|
||||
#include "hw/ppc/mac_dbdma.h"
|
||||
#include "hw/ppc/openpic.h"
|
||||
#include "hw/audio/screamer.h"
|
||||
#include "qom/object.h"
|
||||
|
||||
/* Old World IRQs */
|
||||
@@ -59,9 +58,6 @@
|
||||
#define NEWWORLD_IDE1_DMA_IRQ 0x3
|
||||
#define NEWWORLD_EXTING_GPIO1 0x2f
|
||||
#define NEWWORLD_EXTING_GPIO9 0x37
|
||||
#define NEWWORLD_SCREAMER_IRQ 0x18
|
||||
#define NEWWORLD_SCREAMER_DMA_IRQ 0x9
|
||||
#define NEWWORLD_SCREAMER_RX_IRQ 0xa
|
||||
|
||||
/* MacIO virtual bus */
|
||||
#define TYPE_MACIO_BUS "macio-bus"
|
||||
@@ -113,7 +109,6 @@ struct MacIOState {
|
||||
PMUState pmu;
|
||||
DBDMAState dbdma;
|
||||
ESCCState escc;
|
||||
ScreamerState screamer;
|
||||
uint64_t frequency;
|
||||
};
|
||||
|
||||
|
||||
@@ -320,6 +320,7 @@ bool vhost_has_free_slot(void);
|
||||
int vhost_net_set_backend(struct vhost_dev *hdev,
|
||||
struct vhost_vring_file *file);
|
||||
|
||||
void vhost_toggle_device_iotlb(VirtIODevice *vdev);
|
||||
int vhost_device_iotlb_miss(struct vhost_dev *dev, uint64_t iova, int write);
|
||||
|
||||
int vhost_virtqueue_start(struct vhost_dev *dev, struct VirtIODevice *vdev,
|
||||
|
||||
@@ -155,6 +155,7 @@ struct VirtIODevice
|
||||
QLIST_HEAD(, VirtQueue) *vector_queues;
|
||||
QTAILQ_ENTRY(VirtIODevice) next;
|
||||
EventNotifier config_notifier;
|
||||
bool device_iotlb_enabled;
|
||||
};
|
||||
|
||||
struct VirtioDeviceClass {
|
||||
@@ -212,6 +213,7 @@ struct VirtioDeviceClass {
|
||||
const VMStateDescription *vmsd;
|
||||
bool (*primary_unplug_pending)(void *opaque);
|
||||
struct vhost_dev *(*get_vhost)(VirtIODevice *vdev);
|
||||
void (*toggle_device_iotlb)(VirtIODevice *vdev);
|
||||
};
|
||||
|
||||
void virtio_instance_init_common(Object *proxy_obj, void *data,
|
||||
|
||||
@@ -48,6 +48,7 @@ struct QIOChannelTLS {
|
||||
QIOChannel *master;
|
||||
QCryptoTLSSession *session;
|
||||
QIOChannelShutdown shutdown;
|
||||
guint hs_ioc_tag;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -184,4 +184,17 @@
|
||||
#define QEMU_DISABLE_CFI
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Apple clang version 14 has a bug in its __builtin_subcll(); define
|
||||
* BUILTIN_SUBCLL_BROKEN for the offending versions so we can avoid it.
|
||||
* When a version of Apple clang which has this bug fixed is released
|
||||
* we can add an upper bound to this check.
|
||||
* See https://gitlab.com/qemu-project/qemu/-/issues/1631
|
||||
* and https://gitlab.com/qemu-project/qemu/-/issues/1659 for details.
|
||||
* The bug never made it into any upstream LLVM releases, only Apple ones.
|
||||
*/
|
||||
#if defined(__apple_build_version__) && __clang_major__ >= 14
|
||||
#define BUILTIN_SUBCLL_BROKEN
|
||||
#endif
|
||||
|
||||
#endif /* COMPILER_H */
|
||||
@@ -595,7 +595,7 @@ static inline uint64_t uadd64_carry(uint64_t x, uint64_t y, bool *pcarry)
|
||||
*/
|
||||
static inline uint64_t usub64_borrow(uint64_t x, uint64_t y, bool *pborrow)
|
||||
{
|
||||
#if __has_builtin(__builtin_subcll)
|
||||
#if __has_builtin(__builtin_subcll) && !defined(BUILTIN_SUBCLL_BROKEN)
|
||||
unsigned long long b = *pborrow;
|
||||
x = __builtin_subcll(x, y, b, &b);
|
||||
*pborrow = b & 1;
|
||||
|
||||
+21
-1
@@ -720,10 +720,30 @@ int qemu_msync(void *addr, size_t length, int fd);
|
||||
*/
|
||||
size_t qemu_get_host_physmem(void);
|
||||
|
||||
/*
|
||||
* Toggle write/execute on the pages marked MAP_JIT
|
||||
* for the current thread.
|
||||
*/
|
||||
#if defined(MAC_OS_VERSION_11_0) && \
|
||||
MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_VERSION_11_0
|
||||
static inline void qemu_thread_jit_execute(void)
|
||||
{
|
||||
pthread_jit_write_protect_np(true);
|
||||
}
|
||||
|
||||
static inline void qemu_thread_jit_write(void)
|
||||
{
|
||||
pthread_jit_write_protect_np(false);
|
||||
}
|
||||
#else
|
||||
static inline void qemu_thread_jit_write(void) {}
|
||||
static inline void qemu_thread_jit_execute(void) {}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Platforms which do not support system() return ENOSYS
|
||||
*/
|
||||
#if !defined(HAVE_SYSTEM_FUNCTION) || defined(CONFIG_IOS)
|
||||
#ifndef HAVE_SYSTEM_FUNCTION
|
||||
#define system platform_does_not_support_system
|
||||
static inline int platform_does_not_support_system(const char *command)
|
||||
{
|
||||
|
||||
@@ -17,15 +17,6 @@
|
||||
#include <Hypervisor/hv.h>
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_HVF_PRIVATE) && defined(__aarch64__)
|
||||
extern hv_return_t _hv_vm_config_set_isa(hv_vm_config_t config, uint32_t isa);
|
||||
extern hv_return_t _hv_vcpu_get_actlr(hv_vcpu_t vcpu, uint64_t* value);
|
||||
extern hv_return_t _hv_vcpu_set_actlr(hv_vcpu_t vcpu, uint64_t value);
|
||||
|
||||
#define HV_VM_CONFIG_ISA_PRIVATE (3)
|
||||
#define ACTLR_EL1_TSO_ENABLE_MASK ((1 << 1) | (1 << 9))
|
||||
#endif
|
||||
|
||||
/* hvf_slot flags */
|
||||
#define HVF_SLOT_LOG (1 << 0)
|
||||
|
||||
@@ -54,9 +45,6 @@ struct HVFState {
|
||||
|
||||
hvf_vcpu_caps *hvf_caps;
|
||||
uint64_t vtimer_offset;
|
||||
#if defined(CONFIG_HVF_PRIVATE) && defined(__aarch64__)
|
||||
bool tso_mode;
|
||||
#endif
|
||||
};
|
||||
extern HVFState *hvf_state;
|
||||
|
||||
@@ -68,7 +56,6 @@ struct hvf_vcpu_state {
|
||||
};
|
||||
|
||||
void assert_hvf_ok(hv_return_t ret);
|
||||
hv_return_t hvf_arch_vm_create(HVFState *s);
|
||||
int hvf_arch_init(void);
|
||||
int hvf_arch_init_vcpu(CPUState *cpu);
|
||||
void hvf_arch_vcpu_destroy(CPUState *cpu);
|
||||
|
||||
@@ -47,7 +47,6 @@ struct TPMIfClass {
|
||||
#define TYPE_TPM_TIS_ISA "tpm-tis"
|
||||
#define TYPE_TPM_TIS_SYSBUS "tpm-tis-device"
|
||||
#define TYPE_TPM_CRB "tpm-crb"
|
||||
#define TYPE_TPM_CRB_SYSBUS "tpm-crb-device"
|
||||
#define TYPE_TPM_SPAPR "tpm-spapr"
|
||||
|
||||
#define TPM_IS_TIS_ISA(chr) \
|
||||
@@ -56,8 +55,6 @@ struct TPMIfClass {
|
||||
object_dynamic_cast(OBJECT(chr), TYPE_TPM_TIS_SYSBUS)
|
||||
#define TPM_IS_CRB(chr) \
|
||||
object_dynamic_cast(OBJECT(chr), TYPE_TPM_CRB)
|
||||
#define TPM_IS_CRB_SYSBUS(chr) \
|
||||
object_dynamic_cast(OBJECT(chr), TYPE_TPM_CRB_SYSBUS)
|
||||
#define TPM_IS_SPAPR(chr) \
|
||||
object_dynamic_cast(OBJECT(chr), TYPE_TPM_SPAPR)
|
||||
|
||||
|
||||
Loaded 100 of 228 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user