* [PULL v3 00/49] i386, Rust changes for 2025-01-24
@ 2025-01-29 11:27 Paolo Bonzini
2025-01-29 11:27 ` [PULL 42/49] rust: pl011: wrap registers with BqlRefCell Paolo Bonzini
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Paolo Bonzini @ 2025-01-29 11:27 UTC (permalink / raw)
To: qemu-devel
The following changes since commit d6430c17d7113d3c38480dc34e59d00b0504e2f7:
Merge tag 'pull-riscv-to-apply-20250119-1' of https://github.com/alistair23/qemu into staging (2025-01-19 08:55:46 -0500)
are available in the Git repository at:
https://gitlab.com/bonzini/qemu.git tags/for-upstream
for you to fetch changes up to 3b36ee720288ba17962a17b305243ea34100e1f3:
gitlab-ci: include full Rust backtraces in test runs (2025-01-29 09:37:50 +0100)
----------------------------------------------------------------
* target/i386: optimize string instructions
* target/i386: new Sierra Forest and Clearwater Forest models
* rust: type-safe vmstate implementation
* rust: use interior mutability for PL011
* rust: clean ups
* memtxattrs: remove usage of bitfields from MEMTXATTRS_UNSPECIFIED
* gitlab-ci: enable Rust backtraces
----------------------------------------------------------------
v2->v3: drop PL011Registers borrow before calling PL011State::update()
include full Rust backtraces in test runs
Paolo Bonzini (38):
rust: pl011: fix repr(C) for PL011Class
target/i386: inline gen_jcc into sole caller
target/i386: remove trailing 1 from gen_{j, cmov, set}cc1
target/i386: unify REP and REPZ/REPNZ generation
target/i386: unify choice between single and repeated string instructions
target/i386: reorganize ops emitted by do_gen_rep, drop repz_opt
target/i386: tcg: move gen_set/reset_* earlier in the file
target/i386: fix RF handling for string instructions
target/i386: make cc_op handling more explicit for repeated string instructions.
target/i386: do not use gen_op_jz_ecx for repeated string operations
target/i386: optimize CX handling in repeated string operations
target/i386: execute multiple REP/REPZ iterations without leaving TB
target/i386: pull computation of string update value out of loop
target/i386: extract common bits of gen_repz/gen_repz_nz
target/i386: avoid using s->tmp0 for add to implicit registers
rust: vmstate: add new type safe implementation
rust: vmstate: implement VMState for non-leaf types
rust: vmstate: add varray support to vmstate_of!
rust: vmstate: implement Zeroable for VMStateField
rust: vmstate: implement VMState for scalar types
rust: vmstate: add public utility macros to implement VMState
rust: qemu_api: add vmstate_struct
rust: pl011: switch vmstate to new-style macros
rust: vmstate: remove translation of C vmstate macros
rust: vmstate: make order of parameters consistent in vmstate_clock
rust: prefer NonNull::new to assertions
rust: pl011: remove unnecessary "extern crate"
rust: pl011: hide unnecessarily "pub" items from outside pl011::device
rust: pl011: extract conversion to RegisterOffset
rust: pl011: extract CharBackend receive logic into a separate function
rust: pl011: pull interrupt updates out of read/write ops
rust: pl011: extract PL011Registers
rust: pl011: wrap registers with BqlRefCell
rust: pl011: remove duplicate definitions
rust: pl011: pull device-specific code out of MemoryRegionOps callbacks
rust: pl011: drop use of ControlFlow
rust: qdev: make reset take a shared reference
gitlab-ci: include full Rust backtraces in test runs
Tao Su (4):
target/i386: Introduce SierraForest-v2 model
target/i386: Export BHI_NO bit to guests
target/i386: Add new CPU model ClearwaterForest
docs: Add GNR, SRF and CWF CPU models
Zhao Liu (7):
stub: Fix build failure with --enable-user --disable-system --enable-tools
rust/qdev: Make REALIZE safe
rust/pl011: Avoid bindings::*
memattrs: Convert unspecified member to bool
memattrs: Check the size of MemTxAttrs
rust/zeroable: Implement Zeroable with const_zero macro
rust: qemu-api: add sub-subclass to the integration tests
docs/system/cpu-models-x86.rst.inc | 50 ++-
include/exec/memattrs.h | 21 +-
target/i386/cpu.h | 33 +-
target/i386/cpu.c | 156 +++++++-
target/i386/tcg/translate.c | 363 ++++++++++-------
target/i386/tcg/emit.c.inc | 55 +--
.gitlab-ci.d/buildtest-template.yml | 1 +
rust/hw/char/pl011/src/device.rs | 515 +++++++++++++-----------
rust/hw/char/pl011/src/device_class.rs | 73 ++--
rust/hw/char/pl011/src/lib.rs | 69 ++--
rust/hw/char/pl011/src/memory_ops.rs | 25 +-
rust/qemu-api/src/prelude.rs | 2 +
rust/qemu-api/src/qdev.rs | 16 +-
rust/qemu-api/src/qom.rs | 21 +-
rust/qemu-api/src/vmstate.rs | 700 +++++++++++++++++++++------------
rust/qemu-api/src/zeroable.rs | 118 +++---
rust/qemu-api/tests/tests.rs | 56 ++-
stubs/meson.build | 4 +-
18 files changed, 1423 insertions(+), 855 deletions(-)
--
2.48.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PULL 42/49] rust: pl011: wrap registers with BqlRefCell
2025-01-29 11:27 [PULL v3 00/49] i386, Rust changes for 2025-01-24 Paolo Bonzini
@ 2025-01-29 11:27 ` Paolo Bonzini
2025-01-29 11:27 ` [PULL 49/49] gitlab-ci: include full Rust backtraces in test runs Paolo Bonzini
2025-01-29 19:17 ` [PULL v3 00/49] i386, Rust changes for 2025-01-24 Stefan Hajnoczi
2 siblings, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2025-01-29 11:27 UTC (permalink / raw)
To: qemu-devel
This is a step towards making memory ops use a shared reference to the
device type; it's not yet possible due to the calls to character device
functions.
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
rust/hw/char/pl011/src/device.rs | 46 ++++++++++++++++----------
rust/hw/char/pl011/src/device_class.rs | 8 ++---
2 files changed, 32 insertions(+), 22 deletions(-)
diff --git a/rust/hw/char/pl011/src/device.rs b/rust/hw/char/pl011/src/device.rs
index 91c71d0989a..861b8645b76 100644
--- a/rust/hw/char/pl011/src/device.rs
+++ b/rust/hw/char/pl011/src/device.rs
@@ -109,14 +109,14 @@ pub struct PL011Registers {
}
#[repr(C)]
-#[derive(Debug, qemu_api_macros::Object, qemu_api_macros::offsets)]
+#[derive(qemu_api_macros::Object, qemu_api_macros::offsets)]
/// PL011 Device Model in QEMU
pub struct PL011State {
pub parent_obj: ParentField<SysBusDevice>,
pub iomem: MemoryRegion,
#[doc(alias = "chr")]
pub char_backend: CharBackend,
- pub regs: PL011Registers,
+ pub regs: BqlRefCell<PL011Registers>,
/// QEMU interrupts
///
/// ```text
@@ -528,6 +528,7 @@ fn post_init(&self) {
}
}
+ #[allow(clippy::needless_pass_by_ref_mut)]
pub fn read(&mut self, offset: hwaddr, _size: u32) -> ControlFlow<u64, u64> {
let mut update_irq = false;
let result = match RegisterOffset::try_from(offset) {
@@ -539,7 +540,7 @@ pub fn read(&mut self, offset: hwaddr, _size: u32) -> ControlFlow<u64, u64> {
// qemu_log_mask(LOG_GUEST_ERROR, "pl011_read: Bad offset 0x%x\n", (int)offset);
ControlFlow::Break(0)
}
- Ok(field) => match self.regs.read(field) {
+ Ok(field) => match self.regs.borrow_mut().read(field) {
ControlFlow::Break(value) => ControlFlow::Break(value.into()),
ControlFlow::Continue(value) => {
update_irq = true;
@@ -570,7 +571,10 @@ pub fn write(&mut self, offset: hwaddr, value: u64) {
}
}
- update_irq = self.regs.write(field, value as u32, &mut self.char_backend);
+ update_irq = self
+ .regs
+ .borrow_mut()
+ .write(field, value as u32, &mut self.char_backend);
} else {
eprintln!("write bad offset {offset} value {value}");
}
@@ -581,24 +585,30 @@ pub fn write(&mut self, offset: hwaddr, value: u64) {
pub fn can_receive(&self) -> bool {
// trace_pl011_can_receive(s->lcr, s->read_count, r);
- let regs = &self.regs;
+ let regs = self.regs.borrow();
regs.read_count < regs.fifo_depth()
}
- pub fn receive(&mut self, ch: u32) {
- let regs = &mut self.regs;
+ pub fn receive(&self, ch: u32) {
+ let mut regs = self.regs.borrow_mut();
let update_irq = !regs.loopback_enabled() && regs.put_fifo(ch);
+ // Release the BqlRefCell before calling self.update()
+ drop(regs);
+
if update_irq {
self.update();
}
}
- pub fn event(&mut self, event: QEMUChrEvent) {
+ pub fn event(&self, event: QEMUChrEvent) {
let mut update_irq = false;
- let regs = &mut self.regs;
+ let mut regs = self.regs.borrow_mut();
if event == QEMUChrEvent::CHR_EVENT_BREAK && !regs.loopback_enabled() {
update_irq = regs.put_fifo(registers::Data::BREAK.into());
}
+ // Release the BqlRefCell before calling self.update()
+ drop(regs);
+
if update_irq {
self.update()
}
@@ -622,19 +632,19 @@ pub fn realize(&self) {
}
pub fn reset(&mut self) {
- self.regs.reset();
+ self.regs.borrow_mut().reset();
}
pub fn update(&self) {
- let regs = &self.regs;
+ let regs = self.regs.borrow();
let flags = regs.int_level & regs.int_enabled;
for (irq, i) in self.interrupts.iter().zip(IRQMASK) {
irq.set(flags & i != 0);
}
}
- pub fn post_load(&mut self, _version_id: u32) -> Result<(), ()> {
- self.regs.post_load()
+ pub fn post_load(&self, _version_id: u32) -> Result<(), ()> {
+ self.regs.borrow_mut().post_load()
}
}
@@ -671,11 +681,11 @@ pub fn post_load(&mut self, _version_id: u32) -> Result<(), ()> {
///
/// The buffer and size arguments must also be valid.
pub unsafe extern "C" fn pl011_receive(opaque: *mut c_void, buf: *const u8, size: c_int) {
- let mut state = NonNull::new(opaque).unwrap().cast::<PL011State>();
+ let state = NonNull::new(opaque).unwrap().cast::<PL011State>();
unsafe {
if size > 0 {
debug_assert!(!buf.is_null());
- state.as_mut().receive(u32::from(buf.read_volatile()));
+ state.as_ref().receive(u32::from(buf.read_volatile()));
}
}
}
@@ -686,8 +696,8 @@ pub fn post_load(&mut self, _version_id: u32) -> Result<(), ()> {
/// the same size as [`PL011State`]. We also expect the device is
/// readable/writeable from one thread at any time.
pub unsafe extern "C" fn pl011_event(opaque: *mut c_void, event: QEMUChrEvent) {
- let mut state = NonNull::new(opaque).unwrap().cast::<PL011State>();
- unsafe { state.as_mut().event(event) }
+ let state = NonNull::new(opaque).unwrap().cast::<PL011State>();
+ unsafe { state.as_ref().event(event) }
}
/// # Safety
@@ -712,7 +722,7 @@ pub fn post_load(&mut self, _version_id: u32) -> Result<(), ()> {
}
#[repr(C)]
-#[derive(Debug, qemu_api_macros::Object)]
+#[derive(qemu_api_macros::Object)]
/// PL011 Luminary device model.
pub struct PL011Luminary {
parent_obj: ParentField<PL011State>,
diff --git a/rust/hw/char/pl011/src/device_class.rs b/rust/hw/char/pl011/src/device_class.rs
index d94b98de7bb..8a157a663fb 100644
--- a/rust/hw/char/pl011/src/device_class.rs
+++ b/rust/hw/char/pl011/src/device_class.rs
@@ -6,7 +6,7 @@
use std::os::raw::{c_int, c_void};
use qemu_api::{
- bindings::*, c_str, vmstate_clock, vmstate_fields, vmstate_of, vmstate_struct,
+ bindings::*, c_str, prelude::*, vmstate_clock, vmstate_fields, vmstate_of, vmstate_struct,
vmstate_subsections, vmstate_unused, zeroable::Zeroable,
};
@@ -31,8 +31,8 @@ extern "C" fn pl011_clock_needed(opaque: *mut c_void) -> bool {
};
extern "C" fn pl011_post_load(opaque: *mut c_void, version_id: c_int) -> c_int {
- let mut state = NonNull::new(opaque).unwrap().cast::<PL011State>();
- let result = unsafe { state.as_mut().post_load(version_id as u32) };
+ let state = NonNull::new(opaque).unwrap().cast::<PL011State>();
+ let result = unsafe { state.as_ref().post_load(version_id as u32) };
if result.is_err() {
-1
} else {
@@ -71,7 +71,7 @@ extern "C" fn pl011_post_load(opaque: *mut c_void, version_id: c_int) -> c_int {
post_load: Some(pl011_post_load),
fields: vmstate_fields! {
vmstate_unused!(core::mem::size_of::<u32>()),
- vmstate_struct!(PL011State, regs, &VMSTATE_PL011_REGS, PL011Registers),
+ vmstate_struct!(PL011State, regs, &VMSTATE_PL011_REGS, BqlRefCell<PL011Registers>),
},
subsections: vmstate_subsections! {
VMSTATE_PL011_CLOCK
--
2.48.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PULL 49/49] gitlab-ci: include full Rust backtraces in test runs
2025-01-29 11:27 [PULL v3 00/49] i386, Rust changes for 2025-01-24 Paolo Bonzini
2025-01-29 11:27 ` [PULL 42/49] rust: pl011: wrap registers with BqlRefCell Paolo Bonzini
@ 2025-01-29 11:27 ` Paolo Bonzini
2025-01-29 19:17 ` [PULL v3 00/49] i386, Rust changes for 2025-01-24 Stefan Hajnoczi
2 siblings, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2025-01-29 11:27 UTC (permalink / raw)
To: qemu-devel
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
.gitlab-ci.d/buildtest-template.yml | 1 +
1 file changed, 1 insertion(+)
diff --git a/.gitlab-ci.d/buildtest-template.yml b/.gitlab-ci.d/buildtest-template.yml
index 39da7698b09..4cc19239319 100644
--- a/.gitlab-ci.d/buildtest-template.yml
+++ b/.gitlab-ci.d/buildtest-template.yml
@@ -63,6 +63,7 @@
stage: test
image: $CI_REGISTRY_IMAGE/qemu/$IMAGE:$QEMU_CI_CONTAINER_TAG
script:
+ - export RUST_BACKTRACE=1
- source scripts/ci/gitlab-ci-section
- section_start buildenv "Setting up to run tests"
- scripts/git-submodule.sh update roms/SLOF
--
2.48.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PULL v3 00/49] i386, Rust changes for 2025-01-24
2025-01-29 11:27 [PULL v3 00/49] i386, Rust changes for 2025-01-24 Paolo Bonzini
2025-01-29 11:27 ` [PULL 42/49] rust: pl011: wrap registers with BqlRefCell Paolo Bonzini
2025-01-29 11:27 ` [PULL 49/49] gitlab-ci: include full Rust backtraces in test runs Paolo Bonzini
@ 2025-01-29 19:17 ` Stefan Hajnoczi
2 siblings, 0 replies; 4+ messages in thread
From: Stefan Hajnoczi @ 2025-01-29 19:17 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 116 bytes --]
Applied, thanks.
Please update the changelog at https://wiki.qemu.org/ChangeLog/10.0 for any user-visible changes.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-01-29 20:25 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-29 11:27 [PULL v3 00/49] i386, Rust changes for 2025-01-24 Paolo Bonzini
2025-01-29 11:27 ` [PULL 42/49] rust: pl011: wrap registers with BqlRefCell Paolo Bonzini
2025-01-29 11:27 ` [PULL 49/49] gitlab-ci: include full Rust backtraces in test runs Paolo Bonzini
2025-01-29 19:17 ` [PULL v3 00/49] i386, Rust changes for 2025-01-24 Stefan Hajnoczi
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.