All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: Xiaoyao Li <xiaoyao.li@intel.com>
Cc: "Philippe Mathieu-Daudé" <philmd@linaro.org>,
	qemu-devel@nongnu.org, "Zhao Liu" <zhao1.liu@intel.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Pierrick Bouvier" <pierrick.bouvier@linaro.org>,
	"Peter Xu" <peterx@redhat.com>,
	"David Hildenbrand" <david@redhat.com>
Subject: Re: [PATCH v6 02/39] system/memory: Restrict eventfd dispatch_write() to emulators
Date: Fri, 04 Jul 2025 12:34:28 +0100	[thread overview]
Message-ID: <871pqwb35n.fsf@draig.linaro.org> (raw)
In-Reply-To: <4d57f96b-ee72-484f-a1f5-dadbf773ef64@intel.com> (Xiaoyao Li's message of "Fri, 4 Jul 2025 11:32:18 +0800")

Xiaoyao Li <xiaoyao.li@intel.com> writes:

> On 7/4/2025 1:32 AM, Philippe Mathieu-Daudé wrote:
>> Commit 8c56c1a592b ("memory: emulate ioeventfd") added a !KVM
>> check because the only accelerator available back then were TCG,
>> QTest and KVM. Then commit 126e7f78036 ("kvm: require
>> KVM_CAP_IOEVENTFD and KVM_CAP_IOEVENTFD_ANY_LENGTH") suggested
>> '!KVM' check should be '(TCG || QTest)'. Later more accelerator
>> were added. Implement the suggestion as a safety measure, not
>> dispatching to eventfd when hardware accelerator is used.
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
>> ---
>>   system/memory.c | 9 ++-------
>>   1 file changed, 2 insertions(+), 7 deletions(-)
>> diff --git a/system/memory.c b/system/memory.c
>> index 76b44b8220f..4f713889a8e 100644
>> --- a/system/memory.c
>> +++ b/system/memory.c
>> @@ -25,7 +25,7 @@
>>   #include "qom/object.h"
>>   #include "trace.h"
>>   #include "system/ram_addr.h"
>> -#include "system/kvm.h"
>> +#include "system/qtest.h"
>>   #include "system/runstate.h"
>>   #include "system/tcg.h"
>>   #include "qemu/accel.h"
>> @@ -1530,12 +1530,7 @@ MemTxResult memory_region_dispatch_write(MemoryRegion *mr,
>>         adjust_endianness(mr, &data, op);
>>   -    /*
>> -     * FIXME: it's not clear why under KVM the write would be processed
>> -     * directly, instead of going through eventfd.  This probably should
>> -     * test "tcg_enabled() || qtest_enabled()", or should just go away.
>> -     */
>> -    if (!kvm_enabled() &&
>> +    if ((tcg_enabled() || qtest_enabled()) &&
>
> The FIXME provides two options:
> 1. change to "tcg_enabled() || qtest_enabled()"
> 2. remove !kvm_enabled()
>
> And as the FIXME said, it's not clear why under KVM the write would be
> processed directly. Now, the question becomes why under hardware
> accelerator is used the write would be processed directly instead of
> going through eventfd. I think it needs to answer this question when
> we do such change, and it's better to put the answer as the comment in
> the code.

Under KVM the eventfd notifications are sent directly from the kernel to
the relevant fd. There is no reason why under KVM you couldn't inject
the eventfds from QEMU but it would be a weird and sub-optimal setup.
KVM is perfectly capable of trapping the MMIO accesses in kernel.

I don't think eventfd's can be supported for HVF because I don't think
it has such a concept. For vhost-user devices they would then rely on
VHOST_USER_VRING_KICK over the socket instead.

>
>>           memory_region_dispatch_write_eventfds(mr, addr, data, size, attrs)) {
>>           return MEMTX_OK;
>>       }

-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro


  reply	other threads:[~2025-07-04 11:35 UTC|newest]

Thread overview: 114+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-03 17:32 [PATCH v6 00/39] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
2025-07-03 17:32 ` [PATCH v6 01/39] hw/core/machine: Display CPU model name in 'info cpus' command Philippe Mathieu-Daudé
2025-07-04  3:10   ` Xiaoyao Li
2025-07-04  4:59   ` Markus Armbruster
2025-07-15  8:48     ` Philippe Mathieu-Daudé
2025-07-03 17:32 ` [PATCH v6 02/39] system/memory: Restrict eventfd dispatch_write() to emulators Philippe Mathieu-Daudé
2025-07-04  3:32   ` Xiaoyao Li
2025-07-04 11:34     ` Alex Bennée [this message]
2025-07-03 17:32 ` [PATCH v6 03/39] system/runstate: Document qemu_add_vm_change_state_handler() Philippe Mathieu-Daudé
2025-07-04  3:40   ` Xiaoyao Li
2025-07-15  9:02     ` Alex Bennée
2025-07-15  9:34       ` Xiaoyao Li
2025-07-04  9:31   ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 04/39] system/cpus: Assert interrupt handling is done with BQL locked Philippe Mathieu-Daudé
2025-07-04  4:07   ` Xiaoyao Li
2025-07-04  9:32   ` Zhao Liu
2025-10-07 14:21   ` Alex Bennée
2025-07-03 17:32 ` [PATCH v6 05/39] accel/kvm: Remove kvm_init_cpu_signals() stub Philippe Mathieu-Daudé
2025-07-04  4:13   ` Xiaoyao Li
2025-07-04  8:24     ` Philippe Mathieu-Daudé
2025-07-04 11:49   ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 06/39] accel/kvm: Reduce kvm_create_vcpu() declaration scope Philippe Mathieu-Daudé
2025-07-04  4:15   ` Xiaoyao Li
2025-07-04  9:33   ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 07/39] accel/tcg: Remove 'info opcount' and @x-query-opcount Philippe Mathieu-Daudé
2025-07-04  4:23   ` Xiaoyao Li
2025-07-04  4:50   ` Markus Armbruster
2025-07-04  9:36   ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 08/39] accel/tcg: Remove profiler leftover Philippe Mathieu-Daudé
2025-07-04  4:24   ` Xiaoyao Li
2025-07-04  9:37   ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 09/39] accel/tcg: Factor tcg_dump_flush_info() out Philippe Mathieu-Daudé
2025-07-04  4:27   ` Xiaoyao Li
2025-07-04  4:33     ` Xiaoyao Li
2025-07-04  9:38   ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 10/39] accel/tcg: Factor tcg_dump_stats() out for re-use Philippe Mathieu-Daudé
2025-07-04  9:39   ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 11/39] accel/tcg: Extract statistic related code to tcg-stats.c Philippe Mathieu-Daudé
2025-07-04  8:44   ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 12/39] accel: Move supports_guest_debug() declaration to AccelClass Philippe Mathieu-Daudé
2025-07-04  5:25   ` Xiaoyao Li
2025-07-04  9:42   ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 13/39] accel: Move cpus_are_resettable() " Philippe Mathieu-Daudé
2025-07-04  5:36   ` Xiaoyao Li
2025-10-06 15:14     ` Philippe Mathieu-Daudé
2025-07-04  9:44   ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 14/39] accel/hvf: Restrict internal declarations Philippe Mathieu-Daudé
2025-07-04  5:39   ` Xiaoyao Li
2025-07-04  9:45   ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 15/39] accel/hvf: Move per-cpu method declarations to hvf-accel-ops.c Philippe Mathieu-Daudé
2025-07-04  9:46   ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 16/39] accel/hvf: Move generic method declarations to hvf-all.c Philippe Mathieu-Daudé
2025-07-04  9:50   ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 17/39] cpus: Document CPUState::vcpu_dirty field Philippe Mathieu-Daudé
2025-07-04  5:52   ` Xiaoyao Li
2025-07-03 17:32 ` [PATCH v6 18/39] accel/hvf: Replace @dirty field by generic " Philippe Mathieu-Daudé
2025-07-04  5:54   ` Xiaoyao Li
2025-07-04 10:07   ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 19/39] accel/nvmm: " Philippe Mathieu-Daudé
2025-07-04  5:55   ` Xiaoyao Li
2025-07-04 10:08   ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 20/39] accel/whpx: " Philippe Mathieu-Daudé
2025-07-04  5:55   ` Xiaoyao Li
2025-07-04 10:11   ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 21/39] accel/kvm: Remove kvm_cpu_synchronize_state() stub Philippe Mathieu-Daudé
2025-07-04  6:02   ` Xiaoyao Li
2025-07-04  8:21     ` Philippe Mathieu-Daudé
2025-07-04 10:15   ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 22/39] accel/system: Document cpu_synchronize_state() Philippe Mathieu-Daudé
2025-07-04 10:17   ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 23/39] accel/system: Document cpu_synchronize_state_post_init/reset() Philippe Mathieu-Daudé
2025-07-04 10:19   ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 24/39] accel/nvmm: Expose nvmm_enabled() to common code Philippe Mathieu-Daudé
2025-07-04  8:32   ` Philippe Mathieu-Daudé
2025-07-04 10:26   ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 25/39] accel/whpx: Expose whpx_enabled() " Philippe Mathieu-Daudé
2025-07-04 10:36   ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 26/39] accel/dummy: Extract 'dummy-cpus.h' header from 'system/cpus.h' Philippe Mathieu-Daudé
2025-07-04  6:16   ` Xiaoyao Li
2025-07-04 10:44   ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 27/39] accel: Pass old/new interrupt mask to handle_interrupt() handler Philippe Mathieu-Daudé
2025-07-04  6:32   ` Xiaoyao Li
2025-07-04 10:59   ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 28/39] accel: Expose and register generic_handle_interrupt() Philippe Mathieu-Daudé
2025-07-04  6:38   ` Xiaoyao Li
2025-07-04  8:27     ` Philippe Mathieu-Daudé
2025-07-03 17:32 ` [PATCH v6 29/39] accel: Keep reference to AccelOpsClass in AccelClass Philippe Mathieu-Daudé
2025-07-04 11:01   ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 30/39] accel: Propagate AccelState to AccelClass::init_machine() Philippe Mathieu-Daudé
2025-07-04 11:33   ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 31/39] accel/kvm: Prefer local AccelState over global MachineState::accel Philippe Mathieu-Daudé
2025-07-04 11:33   ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 32/39] accel/tcg: Prefer local AccelState over global current_accel() Philippe Mathieu-Daudé
2025-07-04 11:34   ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 33/39] accel: Directly pass AccelState argument to AccelClass::has_memory() Philippe Mathieu-Daudé
2025-07-04 11:35   ` Zhao Liu
2025-07-04 11:46   ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 34/39] accel/kvm: Directly pass KVMState argument to do_kvm_create_vm() Philippe Mathieu-Daudé
2025-07-04 11:37   ` Zhao Liu
2025-07-04 11:46   ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 35/39] accel: Remove unused MachineState argument of AccelClass::setup_post() Philippe Mathieu-Daudé
2025-07-04 11:38   ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 36/39] accel: Pass AccelState argument to gdbstub_supported_sstep_flags() Philippe Mathieu-Daudé
2025-07-04 11:42   ` Zhao Liu
2025-07-03 17:32 ` [PATCH v6 37/39] accel: Rename 'system/accel-ops.h' -> 'accel/accel-cpu-ops.h' Philippe Mathieu-Daudé
2025-07-04  8:52   ` Zhao Liu
2025-07-04 14:01   ` Richard Henderson
2025-07-03 17:32 ` [PATCH v6 38/39] accel: Extract AccelClass definition to 'accel/accel-ops.h' Philippe Mathieu-Daudé
2025-07-04  9:02   ` Zhao Liu
2025-07-04 14:03   ` Richard Henderson
2025-07-03 17:32 ` [PATCH v6 39/39] MAINTAINERS: Add me as reviewer of overall accelerators section Philippe Mathieu-Daudé
2025-07-03 22:42   ` Philippe Mathieu-Daudé
2025-07-04  3:23   ` Richard Henderson
2025-07-04  8:50 ` [PATCH v6 00/39] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=871pqwb35n.fsf@draig.linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=david@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peterx@redhat.com \
    --cc=philmd@linaro.org \
    --cc=pierrick.bouvier@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=xiaoyao.li@intel.com \
    --cc=zhao1.liu@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.