From 4cc055039fc1c1ab18f172fa791aa3d48d7d20aa Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Thu, 28 Nov 2024 13:21:13 +0100 Subject: clock: clear callback on unparent Signed-off-by: Paolo Bonzini --- include/hw/clock.h | 8 -------- 1 file changed, 8 deletions(-) (limited to 'include') diff --git a/include/hw/clock.h b/include/hw/clock.h index eb58599..a279bd4 100644 --- a/include/hw/clock.h +++ b/include/hw/clock.h @@ -142,14 +142,6 @@ void clock_set_callback(Clock *clk, ClockCallback *cb, void *opaque, unsigned int events); /** - * clock_clear_callback: - * @clk: the clock to delete the callback from - * - * Unregister the callback registered with clock_set_callback. - */ -void clock_clear_callback(Clock *clk); - -/** * clock_set_source: * @clk: the clock. * @src: the source clock -- cgit v1.1 From 81b69b502e3f67d357766ad42ae9a3f8bd675ad2 Mon Sep 17 00:00:00 2001 From: Zhao Liu Date: Tue, 29 Oct 2024 16:59:28 +0800 Subject: i386: Replace type_register() with type_register_static() Replace type_register() with type_register_static() because type_register() will be deprecated. Signed-off-by: Zhao Liu Signed-off-by: Paolo Bonzini Link: https://lore.kernel.org/r/20241029085934.2799066-11-zhao1.liu@intel.com --- include/hw/i386/pc.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 14ee062..b3477ad 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -316,7 +316,7 @@ extern const size_t pc_compat_2_3_len; }; \ static void pc_machine_init_##suffix(void) \ { \ - type_register(&pc_machine_type_##suffix); \ + type_register_static(&pc_machine_type_##suffix); \ } \ type_init(pc_machine_init_##suffix) @@ -344,7 +344,7 @@ extern const size_t pc_compat_2_3_len; static void MACHINE_VER_SYM(register, namesym, __VA_ARGS__)(void) \ { \ MACHINE_VER_DELETION(__VA_ARGS__); \ - type_register(&MACHINE_VER_SYM(info, namesym, __VA_ARGS__)); \ + type_register_static(&MACHINE_VER_SYM(info, namesym, __VA_ARGS__)); \ } \ type_init(MACHINE_VER_SYM(register, namesym, __VA_ARGS__)); -- cgit v1.1 From 281305d3e08ac7330dfe7cf7b3978c119a888bad Mon Sep 17 00:00:00 2001 From: Zhao Liu Date: Tue, 29 Oct 2024 16:59:34 +0800 Subject: qom/object: Remove type_register() At present, type_register() and type_register_static() are identical, although their documentation expects the *_static variant to accept the Typeinfo with the strings that have the static lifetime. However, the code implementation doesn't have any check or guarantee for static lifetime. In fact, this is unnecessary because type_new() duplicates all strings, thereby taking ownership of them. Therefore, type_register() and type_register_static() are redundant, so one of them should be removed. Since the changes required to remove type_register() were smaller, type_register() was replaced with type_register_static() throughout the code base. Drop its definition, and delete the requirement about string lifetime from the documentation. Signed-off-by: Zhao Liu Signed-off-by: Paolo Bonzini Link: https://lore.kernel.org/r/20241029085934.2799066-17-zhao1.liu@intel.com --- include/qom/object.h | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'include') diff --git a/include/qom/object.h b/include/qom/object.h index 43c1359..a201c97 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -880,25 +880,11 @@ const char *object_get_typename(const Object *obj); * type_register_static: * @info: The #TypeInfo of the new type. * - * @info and all of the strings it points to should exist for the life time - * that the type is registered. - * * Returns: the new #Type. */ Type type_register_static(const TypeInfo *info); /** - * type_register: - * @info: The #TypeInfo of the new type - * - * Unlike type_register_static(), this call does not require @info or its - * string members to continue to exist after the call returns. - * - * Returns: the new #Type. - */ -Type type_register(const TypeInfo *info); - -/** * type_register_static_array: * @infos: The array of the new type #TypeInfo structures. * @nr_infos: number of entries in @infos -- cgit v1.1 From 37fb26601dd156369ebb84096c2ecfbe89f0a83b Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 6 Nov 2024 08:59:07 +0100 Subject: bql: check that the BQL is not dropped within marked sections The Big QEMU Lock (BQL) is used to provide interior mutability to Rust code. While BqlCell performs indivisible accesses, an equivalent of RefCell will allow the borrower to hold to the interior content for a long time. If the BQL is dropped, another thread could come and mutate the data from C code (Rust code would panic on borrow_mut() instead). In order to prevent this, add a new BQL primitive that can mark BQL-atomic sections and aborts if the BQL is dropped within them. Signed-off-by: Paolo Bonzini --- include/qemu/main-loop.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'include') diff --git a/include/qemu/main-loop.h b/include/qemu/main-loop.h index 5764db1..646306c 100644 --- a/include/qemu/main-loop.h +++ b/include/qemu/main-loop.h @@ -263,6 +263,21 @@ AioContext *iohandler_get_aio_context(void); bool bql_locked(void); /** + * bql_block: Allow/deny releasing the BQL + * + * The Big QEMU Lock (BQL) is used to provide interior mutability to + * Rust code, but this only works if other threads cannot run while + * the Rust code has an active borrow. This is because C code in + * other threads could come in and mutate data under the Rust code's + * feet. + * + * @increase: Whether to increase or decrease the blocking counter. + * Releasing the BQL while the counter is nonzero triggers + * an assertion failure. + */ +void bql_block_unlock(bool increase); + +/** * qemu_in_main_thread: return whether it's possible to safely access * the global state of the block layer. * -- cgit v1.1