Re: [RFC PATCH 2/2] tests/tcg/mips64el: Run float tests
On 12/26/21 03:25, Jiaxun Yang wrote: > 在2021年12月26日十二月 上午12:19,Philippe Mathieu-Daudé写道: >> Unfortunately this fails: >> >> $ make run-tcg-tests-mips64el-linux-user >> ... >> Files float_convs.out and tests/tcg/mips64el/float_convs.ref differ >> --- float_convs.out 2021-12-26 01:03:48.585973637 +0100 >> +++ tests/tcg/mips64el/float_convs.ref 2021-12-26 00:29:35.804465340 >> +0100 >> @@ -1,40 +1,40 @@ >>### Rounding to nearest >> -from single: f32(nan:0x) >> - to double: f64(nan:0x007ff7) (INVALID) >> - to int32: 2147483647 (INVALID) >> - to int64: 9223372036854775807 (INVALID) >> - to uint32: 2147483647 (INVALID) >> - to uint64: 9223372036854775807 (INVALID) >> make[2]: *** [tests/tcg/multiarch/Makefile.target:32: run-float_convs] >> Error 1 >> >> Signed-off-by: Philippe Mathieu-Daudé >> --- >> tests/tcg/mips64el/Makefile.target | 2 ++ >> 1 file changed, 2 insertions(+) >> create mode 100644 tests/tcg/mips64el/Makefile.target >> >> diff --git a/tests/tcg/mips64el/Makefile.target >> b/tests/tcg/mips64el/Makefile.target >> new file mode 100644 >> index 000..dcb1e9d72ac >> --- /dev/null >> +++ b/tests/tcg/mips64el/Makefile.target >> @@ -0,0 +1,2 @@ >> +float_%: CFLAGS+=-march=loongson3a >> +float_%: QEMU_OPTS+=-cpu Loongson-3A4000 > > Hmm, -march=loongson3a assumed legacy NaN while our -cpu Loongson-3A4000 > assumed IEEE 754-2008 style NaN. > > I guess switch to Loongson-3A1000 can help? Nop, exactly the same error. Also, float_madds fails as: Files float_madds.out and tests/tcg/mips64el/float_madds.ref differ --- float_madds.out 2021-12-26 11:49:06.018532269 +0100 +++ tests/tcg/mips64el/float_madds.ref 2021-12-26 01:16:02.269497182 +0100 @@ -1,16 +1,16 @@ ### Rounding to nearest -op : f32(nan:0x) * f32(nan:0xffbf) + f32(-inf:0xff80) -res: f32(nan:0x7fbf) flags=INVALID (0/0) -op : f32(nan:0xffbf) * f32(-inf:0xff80) + f32(nan:0x) -res: f32(nan:0x7fbf) flags=INVALID (0/1) -op : f32(-inf:0xff80) * f32(nan:0x) + f32(nan:0xffbf) -res: f32(nan:0x7fbf) flags=INVALID (0/2) make[2]: *** [tests/tcg/multiarch/Makefile.target:30: run-float_madds] Error 1
[Bug 1749393] Re: sbrk() not working under qemu-user with a PIE-compiled binary?
i can confirm that focal-proposed package fixes problems for arm64 and armhf on hostarch amd64 note: tried ppa listed here which fixes for arm64 but breaks armhf: https://bugs.launchpad.net/ubuntu/+source/qemu/+bug/1928075/comments/15 steps for installing proposed Package: cat
[PATCH 1/3] jackaudio: use ifdefs to hide unavailable functions
On Windows the jack_set_thread_creator() function and on MacOS the pthread_setname_np() function with a thread pointer paramater is not available. Use #ifdefs to remove the jack_set_thread_creator() function call and the qjack_thread_creator() function in both cases. The qjack_thread_creator() function just sets the name of the created thread for debugging purposes and isn't really necessary. >From the jack_set_thread_creator() documentation: (...) No normal application/client should consider calling this. (...) Resolves: https://gitlab.com/qemu-project/qemu/-/issues/785 Signed-off-by: Volker Rümelin --- audio/jackaudio.c | 4 1 file changed, 4 insertions(+) diff --git a/audio/jackaudio.c b/audio/jackaudio.c index e7de6d5433..317009e936 100644 --- a/audio/jackaudio.c +++ b/audio/jackaudio.c @@ -622,6 +622,7 @@ static void qjack_enable_in(HWVoiceIn *hw, bool enable) ji->c.enabled = enable; } +#if !defined(WIN32) && defined(CONFIG_PTHREAD_SETNAME_NP_W_TID) static int qjack_thread_creator(jack_native_thread_t *thread, const pthread_attr_t *attr, void *(*function)(void *), void *arg) { @@ -635,6 +636,7 @@ static int qjack_thread_creator(jack_native_thread_t *thread, return ret; } +#endif static void *qjack_init(Audiodev *dev) { @@ -687,7 +689,9 @@ static void register_audio_jack(void) { qemu_mutex_init(&qjack_shutdown_lock); audio_driver_register(&jack_driver); +#if !defined(WIN32) && defined(CONFIG_PTHREAD_SETNAME_NP_W_TID) jack_set_thread_creator(qjack_thread_creator); +#endif jack_set_error_function(qjack_error); jack_set_info_function(qjack_info); } -- 2.31.1
[PATCH 2/3] dsoundaudio: fix crackling audio recordings
Audio recordings with the DirectSound backend don't sound right. A look a the Microsoft online documentation tells us why. >From the DirectSound Programming Guide, Capture Buffer Information: 'You can safely copy data from the buffer only up to the read cursor.' Change the code to read up to the read cursor instead of the capture cursor. Signed-off-by: Volker Rümelin --- audio/dsoundaudio.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/audio/dsoundaudio.c b/audio/dsoundaudio.c index cfc79c129e..3dd2c4d4a6 100644 --- a/audio/dsoundaudio.c +++ b/audio/dsoundaudio.c @@ -536,13 +536,12 @@ static void *dsound_get_buffer_in(HWVoiceIn *hw, size_t *size) DSoundVoiceIn *ds = (DSoundVoiceIn *) hw; LPDIRECTSOUNDCAPTUREBUFFER dscb = ds->dsound_capture_buffer; HRESULT hr; -DWORD cpos, rpos, act_size; +DWORD rpos, act_size; size_t req_size; int err; void *ret; -hr = IDirectSoundCaptureBuffer_GetCurrentPosition( -dscb, &cpos, ds->first_time ? &rpos : NULL); +hr = IDirectSoundCaptureBuffer_GetCurrentPosition(dscb, NULL, &rpos); if (FAILED(hr)) { dsound_logerr(hr, "Could not get capture buffer position\n"); *size = 0; @@ -554,7 +553,7 @@ static void *dsound_get_buffer_in(HWVoiceIn *hw, size_t *size) ds->first_time = false; } -req_size = audio_ring_dist(cpos, hw->pos_emul, hw->size_emul); +req_size = audio_ring_dist(rpos, hw->pos_emul, hw->size_emul); req_size = MIN(*size, MIN(req_size, hw->size_emul - hw->pos_emul)); if (req_size == 0) { -- 2.31.1
[PATCH 0/3] misc. audio fixes
Three unrelated audio fixes. The first one is a build fix for the Jack Audio backend on Windows and MacOS. Volker Rümelin (3): jackaudio: use ifdefs to hide unavailable functions dsoundaudio: fix crackling audio recordings hw/audio/intel-hda: fix stream reset audio/dsoundaudio.c | 7 +++ audio/jackaudio.c | 4 hw/audio/intel-hda.c | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) -- 2.31.1
[PATCH 3/3] hw/audio/intel-hda: fix stream reset
Quote from: High Definition Audio Specification 1.0a, section 3.3.35 Offset 80: {IOB}SDnCTL Stream Reset (SRST): Writing a 1 causes the corresponding stream to be reset. The Stream Descriptor registers (except the SRST bit itself) ... are reset. Change the code to reset the Stream Descriptor Control and Status registers except the SRST bit. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/757 Signed-off-by: Volker Rümelin --- hw/audio/intel-hda.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/audio/intel-hda.c b/hw/audio/intel-hda.c index 8ce9df64e3..eed81f9023 100644 --- a/hw/audio/intel-hda.c +++ b/hw/audio/intel-hda.c @@ -578,7 +578,7 @@ static void intel_hda_set_st_ctl(IntelHDAState *d, const IntelHDAReg *reg, uint3 if (st->ctl & 0x01) { /* reset */ dprint(d, 1, "st #%d: reset\n", reg->stream); -st->ctl = SD_STS_FIFO_READY << 24; +st->ctl = SD_STS_FIFO_READY << 24 | SD_CTL_STREAM_RESET; } if ((st->ctl & 0x02) != (old & 0x02)) { uint32_t stnr = (st->ctl >> 20) & 0x0f; -- 2.31.1
Re: [PATCH v10 1/3] migration/dirtyrate: implement vCPU dirtyrate calculation periodically
在 2021/12/23 19:12, Peter Xu 写道: Hi, Yong, On Tue, Dec 14, 2021 at 07:07:32PM +0800, huang...@chinatelecom.cn wrote: From: Hyman Huang(黄勇) Introduce the third method GLOBAL_DIRTY_LIMIT of dirty tracking for calculate dirtyrate periodly for dirty restraint. Implement thread for calculate dirtyrate periodly, which will be used for dirty page limit. Add dirtylimit.h to introduce the util function for dirty limit implementation. Sorry to be late on reading it, my apologies. Never mind :) Signed-off-by: Hyman Huang(黄勇) --- include/exec/memory.h | 5 +- include/sysemu/dirtylimit.h | 51 ++ migration/dirtyrate.c | 160 +--- migration/dirtyrate.h | 2 + 4 files changed, 207 insertions(+), 11 deletions(-) create mode 100644 include/sysemu/dirtylimit.h diff --git a/include/exec/memory.h b/include/exec/memory.h index 20f1b27..606bec8 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -69,7 +69,10 @@ static inline void fuzz_dma_read_cb(size_t addr, /* Dirty tracking enabled because measuring dirty rate */ #define GLOBAL_DIRTY_DIRTY_RATE (1U << 1) -#define GLOBAL_DIRTY_MASK (0x3) +/* Dirty tracking enabled because dirty limit */ +#define GLOBAL_DIRTY_LIMIT (1U << 2) + +#define GLOBAL_DIRTY_MASK (0x7) extern unsigned int global_dirty_tracking; diff --git a/include/sysemu/dirtylimit.h b/include/sysemu/dirtylimit.h new file mode 100644 index 000..34e48f8 --- /dev/null +++ b/include/sysemu/dirtylimit.h @@ -0,0 +1,51 @@ +/* + * dirty limit helper functions + * + * Copyright (c) 2021 CHINA TELECOM CO.,LTD. + * + * Authors: + * Hyman Huang(黄勇) + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ +#ifndef QEMU_DIRTYRLIMIT_H +#define QEMU_DIRTYRLIMIT_H + +#define DIRTYLIMIT_CALC_TIME_MS 1000/* 1000ms */ + +/** + * dirtylimit_calc_current + * + * get current dirty page rate for specified virtual CPU. + */ +int64_t dirtylimit_calc_current(int cpu_index); + +/** + * dirtylimit_calc_start + * + * start dirty page rate calculation thread. + */ +void dirtylimit_calc_start(void); + +/** + * dirtylimit_calc_quit + * + * quit dirty page rate calculation thread. + */ +void dirtylimit_calc_quit(void); + +/** + * dirtylimit_calc_state_init + * + * initialize dirty page rate calculation state. + */ +void dirtylimit_calc_state_init(int max_cpus); + +/** + * dirtylimit_calc_state_finalize + * + * finalize dirty page rate calculation state. + */ +void dirtylimit_calc_state_finalize(void); +#endif Since dirtylimit and dirtyrate looks so alike, not sure it's easier to just reuse dirtyrate.h; after all you reused dirtyrate.c. diff --git a/migration/dirtyrate.c b/migration/dirtyrate.c index d65e744..e8d4e4a 100644 --- a/migration/dirtyrate.c +++ b/migration/dirtyrate.c @@ -27,6 +27,7 @@ #include "qapi/qmp/qdict.h" #include "sysemu/kvm.h" #include "sysemu/runstate.h" +#include "sysemu/dirtylimit.h" #include "exec/memory.h" /* @@ -46,6 +47,155 @@ static struct DirtyRateStat DirtyStat; static DirtyRateMeasureMode dirtyrate_mode = DIRTY_RATE_MEASURE_MODE_PAGE_SAMPLING; +struct { +DirtyRatesData data; +bool quit; +QemuThread thread; +} *dirtylimit_calc_state; + +static void dirtylimit_global_dirty_log_start(void) +{ +qemu_mutex_lock_iothread(); +memory_global_dirty_log_start(GLOBAL_DIRTY_LIMIT); +qemu_mutex_unlock_iothread(); +} + +static void dirtylimit_global_dirty_log_stop(void) +{ +qemu_mutex_lock_iothread(); +memory_global_dirty_log_stop(GLOBAL_DIRTY_LIMIT); +qemu_mutex_unlock_iothread(); +} This is merely dirtyrate_global_dirty_log_start/stop but with a different flag. Let's introduce global_dirty_log_change() with BQL? global_dirty_log_change(flag, onoff) { qemu_mutex_lock_iothread(); if (start) { memory_global_dirty_log_start(flag); } else { memory_global_dirty_log_stop(flag); } qemu_mutex_unlock_iothread(); } Then we merge 4 functions into one. We can also have a BQL-version of global_dirty_log_sync() in the same patch if you think above helpful. This make things simple. + +static inline void record_dirtypages(DirtyPageRecord *dirty_pages, + CPUState *cpu, bool start) +{ +if (start) { +dirty_pages[cpu->cpu_index].start_pages = cpu->dirty_pages; +} else { +dirty_pages[cpu->cpu_index].end_pages = cpu->dirty_pages; +} +} + +static void dirtylimit_calc_func(void) Would you still consider merging this with calculate_dirtyrate_dirty_ring? I still don't see why it can't. Maybe it cannot be directly reused, but the whole logic is really, really similar: alloc an array of DirtyPageRecord, take notes, sleep, take some other notes, calculate per-vcpu dirty rates. There's some trivial details that are differ
Re: [PATCH v10 3/3] cpus-common: implement dirty page limit on virtual CPU
在 2021/12/24 13:14, Peter Xu 写道: On Tue, Dec 14, 2021 at 07:07:34PM +0800, huang...@chinatelecom.cn wrote: +void qmp_vcpu_dirty_limit(bool enable, + bool has_cpu_index, + uint64_t cpu_index, + bool has_dirty_rate, + uint64_t dirty_rate, + Error **errp) +{ +static bool initialized; IMHO this is not needed; if we're with a global state pointer then it's the same to check against that. Sound good, this make code simpler. The rest looks mostly good (besides the last proposal on API design which you got confirmation from Markus).
Re: [RFC v2 00/12] target/ppc: powerpc_excp improvements
Hello Fabiano, On 12/20/21 19:18, Fabiano Rosas wrote: This changed a lot since v1, basically what remains is the idea that we want to have some sort of array of interrupts and some sort of separation between processors. At the end of this series we'll have: - One file with all interrupt implementations (interrupts.c); - Separate files for each major group of CPUs (book3s, booke, 32bits). Only interrupt code for now, but we could bring pieces of cpu_init into them; - Four separate interrupt arrays, one for each of the above groups plus KVM. - powerpc_excp calls into the individual files and from there we dispatch according to what is available in the interrupts array. This is going in the good direction. I think we need more steps for the reviewers, for tests and bisectability. First 4 patches are OK and I hope to merge them ASAP. The powerpc_excp() routine has grown nearly out of control these last years and it is becoming difficult to maintain. The goal is to clarify what it is going on for each CPU or each CPU family. The first step consists basically in duplicating the code and moving the exceptions handlers in specific routines. 1. cleanups should come first as usual. 2. isolate large chunks, like Nick did with ppc_excp_apply_ail(). We could do easily the same for : 2.1 ILE 2.2 unimplemeted ones doing a cpu abort: cpu_abort(cs, " " "is not implemented yet !\n"); 2.3 6x TLBS This should reduce considerably powerpc_excp() without changing too much the execution path. 3. Cleanup the use of excp_model, like in dcbz_common() and kvm. This is not critical but some are shortcuts. 4. Introduce a new powerpc_excp() handler : static void powerpc_excp(PowerPCCPU *cpu, int excp) { switch(env->excp_model) { case POWERPC_EXCP_FOO1: case POWERPC_EXCP_FOO2: powerpc_excp_foo(cpu, excp); break; case POWERPC_EXCP_BAR: powerpc_excp_legacy(cpu, excp); break; default: g_assert_not_reached(); } } and start duplicating code cpu per cpu in specific excp handlers, avoiding as much as possible the use of excp_model in the powerpc_excp_*() routines. That's for the theory. I suppose these can be grouped in the following way : * 405 CPU POWERPC_EXCP_40x, * 6xx CPUs POWERPC_EXCP_601, POWERPC_EXCP_602, POWERPC_EXCP_603, POWERPC_EXCP_G2, POWERPC_EXCP_604, * 7xx CPUs POWERPC_EXCP_7x0, POWERPC_EXCP_7x5, POWERPC_EXCP_74xx, * BOOKE CPUs POWERPC_EXCP_BOOKE, * BOOKS CPUs POWERPC_EXCP_970,/* could be special */ POWERPC_EXCP_POWER7, POWERPC_EXCP_POWER8, POWERPC_EXCP_POWER9, POWERPC_EXCP_POWER10, If not possible, then, we will duplicate more and that's not a problem. I would keep the routines in the same excp_helper.c file for now; we can move the code in different files but I would do it later and with other components in mind and not just the exception models. book3s, booke, 7xx, 6xx, 405 are the different groups. It fits what you did. 5. Once done, get rid of powerpc_excp_legacy() 6. Start looking at refactoring again. There might be a common prologue and epilogue. As a consequence we could change the args passed to powerpc_excp_*(). There could be common handlers and that's why an array of exception handlers looks good. this is what you are trying to address after patch 5 but I would prefer to do the above steps before. Thanks, C.
Re: [PATCH] target/ppc: Fix e6500 boot
On 12/25/21 22:53, BALATON Zoltan wrote: On Sat, 25 Dec 2021, ma...@locati.it wrote: I have tried to launch a freshly compiled qemu from git master on a NXP T2080RDB devkit that has a e6500 CPU in combination with a freshly compiled kernel 5.16-rc6 I have Debian SID ppc64 up and running using such a kernel, and when I launch qemu to run a VM with the same debian sid for ppc64 and the same kernel using --enable-kvm I end up with a kernel panic Thanks for testing, [] Run /sbin/init as init process random: fast init done systemd[1]: illegal instruction (4) at 3fff96562ac8 nip 3fff96562ac8 lr 3fff96562aa8 code 1 in libc-2.32.so[3fff96516000+1f7000] debian ppc64 sid has a glibc 2.33 AFAICT systemd[1]: code: 6000 3866 9122b7e8 4801bead 6000 6000 8122b7e8 2c090004 systemd[1]: code: 40820014 3925 6000 9122b7e8 <> 6000 8122b7e8 2c090005 Looks like it trips on a 0 opcode here in the middle of other values that look like valid code so I wonder how that 0 got there? Did something overwrite it before it tried to execute it? This looks like the abort() routine. If it always happens on the same address maybe you could try attaching gdb and put a watch point on that address to see what writes there, otherwise I don't know how to debug this. Could you deduce the routine name from the nip ? Thanks, C.
[PATCH v2] net/filter: Optimize filter_send to coroutine
This patch is to improve the logic of QEMU main thread sleep code in qemu_chr_write_buffer() where it can be blocked and can't run other coroutines during COLO IO stress test. Our approach is to put filter_send() in a coroutine. In this way, filter_send() will call qemu_coroutine_yield() in qemu_co_sleep_ns(), so that it can be scheduled out and QEMU main thread has opportunity to run other tasks. Signed-off-by: Lei Rao Signed-off-by: Zhang Chen Reviewed-by: Li Zhijian --- net/filter-mirror.c | 66 - 1 file changed, 53 insertions(+), 13 deletions(-) diff --git a/net/filter-mirror.c b/net/filter-mirror.c index f20240cc9f..34a63b5dbb 100644 --- a/net/filter-mirror.c +++ b/net/filter-mirror.c @@ -20,6 +20,7 @@ #include "chardev/char-fe.h" #include "qemu/iov.h" #include "qemu/sockets.h" +#include "block/aio-wait.h" #define TYPE_FILTER_MIRROR "filter-mirror" typedef struct MirrorState MirrorState; @@ -42,20 +43,21 @@ struct MirrorState { bool vnet_hdr; }; -static int filter_send(MirrorState *s, - const struct iovec *iov, - int iovcnt) +typedef struct FilterSendCo { +MirrorState *s; +char *buf; +ssize_t size; +bool done; +int ret; +} FilterSendCo; + +static int _filter_send(MirrorState *s, + char *buf, + ssize_t size) { NetFilterState *nf = NETFILTER(s); int ret = 0; -ssize_t size = 0; uint32_t len = 0; -char *buf; - -size = iov_size(iov, iovcnt); -if (!size) { -return 0; -} len = htonl(size); ret = qemu_chr_fe_write_all(&s->chr_out, (uint8_t *)&len, sizeof(len)); @@ -80,10 +82,7 @@ static int filter_send(MirrorState *s, } } -buf = g_malloc(size); -iov_to_buf(iov, iovcnt, 0, buf, size); ret = qemu_chr_fe_write_all(&s->chr_out, (uint8_t *)buf, size); -g_free(buf); if (ret != size) { goto err; } @@ -94,6 +93,47 @@ err: return ret < 0 ? ret : -EIO; } +static void coroutine_fn filter_send_co(void *opaque) +{ +FilterSendCo *data = opaque; + +data->ret = _filter_send(data->s, data->buf, data->size); +data->done = true; +g_free(data->buf); +aio_wait_kick(); +} + +static int filter_send(MirrorState *s, + const struct iovec *iov, + int iovcnt) +{ +ssize_t size = iov_size(iov, iovcnt); +char *buf = NULL; + +if (!size) { +return 0; +} + +buf = g_malloc(size); +iov_to_buf(iov, iovcnt, 0, buf, size); + +FilterSendCo data = { +.s = s, +.size = size, +.buf = buf, +.ret = 0, +}; + +Coroutine *co = qemu_coroutine_create(filter_send_co, &data); +qemu_coroutine_enter(co); + +while (!data.done) { +aio_poll(qemu_get_aio_context(), true); +} + +return data.ret; +} + static void redirector_to_filter(NetFilterState *nf, const uint8_t *buf, int len) -- 2.32.0
Re: [PATCH v4 2/3] acpi: tpm: Add missing device identification objects
On 2021/12/23 10:23, Stefan Berger wrote: Add missing device identification objects _STR and _UID. They will appear as files 'description' and 'uid' under Linux sysfs. Cc: Shannon Zhao Cc: Michael S. Tsirkin Cc: Igor Mammedov Cc: Ani Sinha Fixes: https://gitlab.com/qemu-project/qemu/-/issues/708 Signed-off-by: Stefan Berger Message-id: 2020133559.3370990-3-stef...@linux.ibm.com --- hw/arm/virt-acpi-build.c | 1 + hw/i386/acpi-build.c | 8 2 files changed, 9 insertions(+) diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index d0f4867fdf..f2514ce77c 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -229,6 +229,7 @@ static void acpi_dsdt_add_tpm(Aml *scope, VirtMachineState *vms) 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))); For ARM part Reviewed-by: Shannon Zhao Aml *crs = aml_resource_template(); diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 8383b83ee3..2fb70847cb 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -1812,11 +1812,15 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, 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"))); } else { dev = aml_device("ISA.TPM"); 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(); @@ -1844,6 +1848,8 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, 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)); @@ -1851,6 +1857,8 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, 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);
RE: [PATCH v2] net/filter: Optimize filter_send to coroutine
> -Original Message- > From: Rao, Lei > Sent: Monday, December 27, 2021 9:20 AM > To: Zhang, Chen ; lizhij...@cn.fujitsu.com; > jasow...@redhat.com > Cc: qemu-devel@nongnu.org; Rao, Lei ; Li Zhijian > > Subject: [PATCH v2] net/filter: Optimize filter_send to coroutine > > This patch is to improve the logic of QEMU main thread sleep code in > qemu_chr_write_buffer() where it can be blocked and can't run other > coroutines during COLO IO stress test. > > Our approach is to put filter_send() in a coroutine. In this way, > filter_send() will call qemu_coroutine_yield() in qemu_co_sleep_ns(), so > that it can be scheduled out and QEMU main thread has opportunity to run > other tasks. > > Signed-off-by: Lei Rao > Signed-off-by: Zhang Chen > Reviewed-by: Li Zhijian Looks good to me. Reviewed-by: Zhang Chen Thanks Chen > --- > net/filter-mirror.c | 66 > - > 1 file changed, 53 insertions(+), 13 deletions(-) > > diff --git a/net/filter-mirror.c b/net/filter-mirror.c index > f20240cc9f..34a63b5dbb 100644 > --- a/net/filter-mirror.c > +++ b/net/filter-mirror.c > @@ -20,6 +20,7 @@ > #include "chardev/char-fe.h" > #include "qemu/iov.h" > #include "qemu/sockets.h" > +#include "block/aio-wait.h" > > #define TYPE_FILTER_MIRROR "filter-mirror" > typedef struct MirrorState MirrorState; @@ -42,20 +43,21 @@ struct > MirrorState { > bool vnet_hdr; > }; > > -static int filter_send(MirrorState *s, > - const struct iovec *iov, > - int iovcnt) > +typedef struct FilterSendCo { > +MirrorState *s; > +char *buf; > +ssize_t size; > +bool done; > +int ret; > +} FilterSendCo; > + > +static int _filter_send(MirrorState *s, > + char *buf, > + ssize_t size) > { > NetFilterState *nf = NETFILTER(s); > int ret = 0; > -ssize_t size = 0; > uint32_t len = 0; > -char *buf; > - > -size = iov_size(iov, iovcnt); > -if (!size) { > -return 0; > -} > > len = htonl(size); > ret = qemu_chr_fe_write_all(&s->chr_out, (uint8_t *)&len, sizeof(len)); > @@ -80,10 +82,7 @@ static int filter_send(MirrorState *s, > } > } > > -buf = g_malloc(size); > -iov_to_buf(iov, iovcnt, 0, buf, size); > ret = qemu_chr_fe_write_all(&s->chr_out, (uint8_t *)buf, size); > -g_free(buf); > if (ret != size) { > goto err; > } > @@ -94,6 +93,47 @@ err: > return ret < 0 ? ret : -EIO; > } > > +static void coroutine_fn filter_send_co(void *opaque) { > +FilterSendCo *data = opaque; > + > +data->ret = _filter_send(data->s, data->buf, data->size); > +data->done = true; > +g_free(data->buf); > +aio_wait_kick(); > +} > + > +static int filter_send(MirrorState *s, > + const struct iovec *iov, > + int iovcnt) > +{ > +ssize_t size = iov_size(iov, iovcnt); > +char *buf = NULL; > + > +if (!size) { > +return 0; > +} > + > +buf = g_malloc(size); > +iov_to_buf(iov, iovcnt, 0, buf, size); > + > +FilterSendCo data = { > +.s = s, > +.size = size, > +.buf = buf, > +.ret = 0, > +}; > + > +Coroutine *co = qemu_coroutine_create(filter_send_co, &data); > +qemu_coroutine_enter(co); > + > +while (!data.done) { > +aio_poll(qemu_get_aio_context(), true); > +} > + > +return data.ret; > +} > + > static void redirector_to_filter(NetFilterState *nf, > const uint8_t *buf, > int len) > -- > 2.32.0
Re: [PATCH] tpm: fixed be_buffer_size size in in tpm_crb
On 12/25/21 07:38, Yuri Konotopov wrote: Trying to boot VM with TPM 2.0 CRB in passthrough mode without this change I got "Requested buffer size of 3968 is smaller than host TPM's fixed buffer size of 4096". I suppose the host has a TIS interface. The reason it gives this message is that the response this TPM may send back could be 4096 bytes in size but the CRB of the VM can only catch 3968 bytes, so there's a mismatch. You may not be able to use the CRB in passthrough mode. I would try to have the VM use the TIS. Stefan Looks like it can not be less than backend buffer size nor less than CRB_CTRL_CMD_SIZE. Signed-off-by: Yuri Konotopov --- hw/tpm/tpm_crb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/tpm/tpm_crb.c b/hw/tpm/tpm_crb.c index 58ebd1469c..8243645453 100644 --- a/hw/tpm/tpm_crb.c +++ b/hw/tpm/tpm_crb.c @@ -270,7 +270,7 @@ static void tpm_crb_reset(void *dev) 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), +s->be_buffer_size = MAX(tpm_backend_get_buffer_size(s->tpmbe), CRB_CTRL_CMD_SIZE); if (tpm_backend_startup_tpm(s->tpmbe, s->be_buffer_size) < 0) {
Re: [PATCH] tpm: fixed be_buffer_size size in in tpm_crb
On 12/26/21 21:24, Stefan Berger wrote: On 12/25/21 07:38, Yuri Konotopov wrote: Trying to boot VM with TPM 2.0 CRB in passthrough mode without this change I got "Requested buffer size of 3968 is smaller than host TPM's fixed buffer size of 4096". I suppose the host has a TIS interface. The reason it gives this message is that the response this TPM may send back could be 4096 bytes in size but the CRB of the VM can only catch 3968 bytes, so there's a mismatch. You may not be able to use the CRB in passthrough mode. I would try to have the VM use the TIS. For TPM passthrough the host TPM's buffer size basically has to match the VM's buffer size so that - apps inside the VM cannot create longer commands than what the host device can accept - apps inside the VM cannot create commands that cause the TPM to return responses that are bigger than what the VM's TPM buffer can accept Stefan
Re: [ PATCH v3 08/10] target/riscv: Add sscofpmf extension support
Atish Patra 於 2021年10月26日 週二 上午3:57寫道: > The Sscofpmf ('Ss' for Privileged arch and Supervisor-level extensions, > and 'cofpmf' for Count OverFlow and Privilege Mode Filtering) > extension allows the perf to handle overflow interrupts and filtering > support. This patch provides a framework for programmable > counters to leverage the extension. As the extension doesn't have any > provision for the overflow bit for fixed counters, the fixed events > can also be monitoring using programmable counters. The underlying > counters for cycle and instruction counters are always running. Thus, > a separate timer device is programmed to handle the overflow. > > Signed-off-by: Atish Patra > --- > target/riscv/cpu.c | 12 ++ > target/riscv/cpu.h | 25 +++ > target/riscv/cpu_bits.h | 55 +++ > target/riscv/csr.c | 150 +- > target/riscv/machine.c | 2 +- > target/riscv/pmu.c | 343 +++- > target/riscv/pmu.h | 9 ++ > 7 files changed, 589 insertions(+), 7 deletions(-) > > diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c > index aec94101a4c0..757c646037bb 100644 > --- a/target/riscv/cpu.c > +++ b/target/riscv/cpu.c > @@ -22,6 +22,7 @@ > #include "qemu/ctype.h" > #include "qemu/log.h" > #include "cpu.h" > +#include "pmu.h" > #include "internals.h" > #include "exec/exec-all.h" > #include "qapi/error.h" > @@ -535,6 +536,16 @@ static void riscv_cpu_realize(DeviceState *dev, Error > **errp) > set_misa(env, target_misa); > } > > +if (cpu->cfg.pmu_num) { > +if (!riscv_pmu_init(cpu, cpu->cfg.pmu_num) && cpu->cfg.ext_sscof) > { > +cpu->pmu_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, > + riscv_pmu_timer_cb, cpu); > +if (!cpu->pmu_timer) { > +cpu->cfg.ext_sscof = false; > +} > +} > + } > + > riscv_cpu_register_gdb_regs_for_features(cs); > > qemu_init_vcpu(cs); > @@ -599,6 +610,7 @@ static Property riscv_cpu_properties[] = { > DEFINE_PROP_BOOL("x-h", RISCVCPU, cfg.ext_h, false), > DEFINE_PROP_BOOL("x-v", RISCVCPU, cfg.ext_v, false), > DEFINE_PROP_UINT8("pmu-num", RISCVCPU, cfg.pmu_num, 16), > +DEFINE_PROP_BOOL("sscof", RISCVCPU, cfg.ext_sscof, false), > DEFINE_PROP_BOOL("Zifencei", RISCVCPU, cfg.ext_ifencei, true), > DEFINE_PROP_BOOL("Zicsr", RISCVCPU, cfg.ext_icsr, true), > DEFINE_PROP_STRING("priv_spec", RISCVCPU, cfg.priv_spec), > diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h > index da34614ad788..b66d8acff109 100644 > --- a/target/riscv/cpu.h > +++ b/target/riscv/cpu.h > @@ -123,6 +123,8 @@ struct PMUCTRState { > /* Snapshort value of a counter in RV32 */ > target_ulong mhpmcounterh_prev; > bool started; > +/* Value beyond UINT32_MAX/UINT64_MAX before overflow interrupt > trigger */ > +target_ulong irq_overflow_left; > }; > > struct CPURISCVState { > @@ -241,6 +243,9 @@ struct CPURISCVState { > /* PMU event selector configured values. First three are unused*/ > target_ulong mhpmevent_val[RV_MAX_MHPMEVENTS]; > > +/* PMU event selector configured values for RV32*/ > +target_ulong mhpmeventh_val[RV_MAX_MHPMEVENTS]; > + > target_ulong sscratch; > target_ulong mscratch; > > @@ -320,6 +325,7 @@ struct RISCVCPU { > bool ext_zbs; > bool ext_ifencei; > bool ext_icsr; > +bool ext_sscof; > > uint8_t pmu_num; > char *priv_spec; > @@ -333,6 +339,12 @@ struct RISCVCPU { > bool epmp; > uint64_t resetvec; > } cfg; > + > +QEMUTimer *pmu_timer; > +/* A bitmask of Available programmable counters */ > +uint32_t pmu_avail_ctrs; > +/* Mapping of events to counters */ > +GHashTable *pmu_event_ctr_map; > }; > > static inline int riscv_has_ext(CPURISCVState *env, target_ulong ext) > @@ -528,6 +540,19 @@ enum { > CSR_TABLE_SIZE = 0x1000 > }; > > +/** > + * The event id are encoded based on the encoding specified in the > + * SBI specification v0.3 > + */ > + > +enum riscv_pmu_event_idx { > +RISCV_PMU_EVENT_HW_CPU_CYCLES = 0x01, > +RISCV_PMU_EVENT_HW_INSTRUCTIONS = 0x02, > +RISCV_PMU_EVENT_CACHE_DTLB_READ_MISS = 0x10019, > +RISCV_PMU_EVENT_CACHE_DTLB_WRITE_MISS = 0x1001B, > +RISCV_PMU_EVENT_CACHE_ITLB_PREFETCH_MISS = 0x10021, > +}; > + > /* CSR function table */ > extern riscv_csr_operations csr_ops[CSR_TABLE_SIZE]; > > diff --git a/target/riscv/cpu_bits.h b/target/riscv/cpu_bits.h > index 72b1485e621f..cd6523c1c6ee 100644 > --- a/target/riscv/cpu_bits.h > +++ b/target/riscv/cpu_bits.h > @@ -308,6 +308,37 @@ > #define CSR_MHPMEVENT29 0x33d > #define CSR_MHPMEVENT30 0x33e > #define CSR_MHPMEVENT31 0x33f > + > +#define CSR_MHPMEVENT3H 0x723 > +#define CSR_MHPMEVENT4H 0x724 > +#define CSR_MHPMEVENT5H 0x725 > +#define CSR_MHPMEVENT6H 0x726 > +#define CSR_MHPMEVENT7H 0x727
Re: [PATCH] tpm: fixed be_buffer_size size in in tpm_crb
27.12.2021 06:24, Stefan Berger пишет: I suppose the host has a TIS interface. Hello, Stefan. I do not think so. There is only tpm_crb tpm kernel module compiled in my system # systemd-cryptenroll --tpm2-device=list PATH DEVICE DRIVER /dev/tpmrm0 MSFT0101:00 tpm_crb The reason it gives this message is that the response this TPM may send back could be 4096 bytes in size but the CRB of the VM can only catch 3968 bytes, so there's a mismatch. You may not be able to use the CRB in passthrough mode. I would try to have the VM use the TIS. -- Best regards, Yuri Konotopov