Skip to contentSkip to conversation

some docs (booting, mttcg, icount)

PATCH In review Alex Bennée 4 participants 11 messages Jul 1, 2020 – Jul 3, 2020

lore
Share & tools
lore
#0 lore raw

v2 cover some docs (booting, mttcg, icount)

Hi,

This is the current state of documentation patches. They didn't get much review the first time around so I present them as a series. I Think we should merge them unless anyone want to argue they actively muddy our document situation?

The following have no reviews:

- docs/devel: convert and update MTTCG design document
- docs/booting.rst: start documenting the boot process

Alex Bennée (3):
docs/booting.rst: start documenting the boot process docs/devel: convert and update MTTCG design document docs/devel: add some notes on tcg-icount for developers

 docs/devel/index.rst                          |   2 +
 ...ti-thread-tcg.txt => multi-thread-tcg.rst} |  52 +++---
 docs/devel/tcg-icount.rst                     |  89 ++++++++++
 docs/interop/booting.rst                      | 159 ++++++++++++++++++
 docs/interop/index.rst                        |   1 +
 5 files changed, 284 insertions(+), 19 deletions(-)
 rename docs/devel/{multi-thread-tcg.txt => multi-thread-tcg.rst} (90%)
 create mode 100644 docs/devel/tcg-icount.rst
 create mode 100644 docs/interop/booting.rst
Signature · 1 line
2.20.1
#1 lore raw

PATCH v2 1/3 docs/booting.rst: start documenting the boot process

While working on some test cases I realised there was quite a lot of assumed knowledge about how things boot up. I thought it would be worth gathering this together in a user facing document where we could pour in the details and background to the boot process. As it's quite wordy I thought it should be a separate document to the manual (which can obviously reference this).

The document follows the socratic method and leaves the reader to ask themselves some questions in an effort to elucidate them about any problems they may be having.

Message-Id: <[email protected]>

---
v2
- fix a lot of it's/its
- mention microvm style booting
- add some questions to the end

---
 docs/interop/booting.rst | 159 +++++++++++++++++++++++++++++++++++++++
 docs/interop/index.rst   |   1 +
 2 files changed, 160 insertions(+)
 create mode 100644 docs/interop/booting.rst
docs/interop/booting.rst new file +159 -0
new file mode 100644
index 00000000000..8579a775d04
@@ -0,0 +1,159 @@
+..
+  Copyright (c) 2019-2020 Linaro Ltd.
+
+  This work is licensed under the terms of the GNU GPL, version 2 or
+  later. See the COPYING file in the top-level directory.
+
+=====================================
+Anatomy of a Boot, a QEMU perspective
+=====================================
+
+This document attempts to give an overview of how machines boot and
+how this matters to QEMU. We will discuss firmware and BIOSes and the
+things they do before the OS kernel is loaded and your usable system
+is finally ready.
+
+Firmware
+========
+
+When a CPU is powered up it knows nothing about its environment. The
+internal state, including the program counter (PC), will be reset to a
+defined set of values and it will attempt to fetch the first
+instruction and execute it. It is the job of the firmware to bring a
+CPU up from the initial few instructions to running in a relatively
+sane execution environment. Firmware tends to be specific to the
+hardware in question and is stored on non-volatile memory (memory that
+survives a power off) usually a ROM or flash device on the computers
+main board.
+
+Some examples of what firmware does include:
+
+Early Hardware Setup
+--------------------
+
+Modern hardware often requires configuring before it is usable. For
+example most modern systems won't have working RAM until the memory
+controller has been programmed with the correct timings for whatever
+memory is installed on the system. Processors may boot with a very
+restricted view of the memory map until RAM and other key peripherals
+have been configured to appear in its address space. Some hardware
+may not even appear until some sort of blob has been loaded into it so
+it can start responding to the CPU.
+
+Fortunately for QEMU we don't have to worry too much about this very
+low level configuration. The device model we present to the CPU at
+start-up will generally respond to IO access from processor straight
+away.
+
+BIOS or Firmware Services
+-------------------------
+
+In the early days of the PC era the BIOS or Basic Input/Output System
+provided an abstraction interface to the operating system which
+allowed them to do basic IO operations without having to directly
+drive the hardware. Since then the scope of these firmware services
+have grown as systems become more and more complex.
+
+Modern firmware often follows the Unified Extensible Firmware
+Interface (UEFI) which provides services like secure boot, persistent
+variables and external time-keeping.
+
+There can often be multiple levels of firmware service functions. For
+example systems which support secure execution enclaves generally have
+a firmware component that executes in this secure mode which the
+operating system can call in a defined secure manner to undertake
+security sensitive tasks on its behalf.
+
+Hardware Enumeration
+--------------------
+
+It is easy to assume that modern hardware is built to be discover-able
+and all the operating system needs to do is enumerate the various
+buses on the system to find out what hardware exists. While buses like
+PCI and USB do support discovery there is usually much more on a
+modern system than just these two things.
+
+This process of discovery can take some time as devices usually need
+to be probed and some time allowed for the buses to settle and the
+probe complete. For purely virtual machines operating in on-demand
+cloud environments you may operate with stripped down kernels that
+only support a fixed expected environment so they can boot as fast as
+possible.
+
+In the embedded world it used to be acceptable to have a similar
+custom compiled kernel which knew where everything is meant to be.
+However this was a brittle approach and not very flexible. For example
+a general purpose distribution would have to ship a special kernel for
+each variant of hardware you wanted to run on. If you try and use a
+kernel compiled for one platform that nominally uses the same
+processor as another platform the result will rarely work given a
+processor rarely works in isolation.
+
+The more modern approach is to have a "generic" kernel that has a
+number of different drivers compiled in which are then enabled based
+on a hardware description provided by the firmware. This allows
+flexibility on both sides. The software distribution is less concerned
+about managing lots of different kernels for different pieces of
+hardware. The hardware manufacturer is also able to make small changes
+to the board over time to fix bugs or change minor components.
+
+The two main methods for this are the Advanced Configuration and Power
+Interface (ACPI) and Device Trees. ACPI originated from the PC world
+although it is becoming increasingly common for "enterprise" hardware
+like servers. Device Trees of various forms have existed for a while
+with perhaps the most common being Flattened Device Trees (FDT).
+
+Boot Code
+=========
+
+The line between firmware and boot code is a very blurry one. However
+from a functionality point of view we have moved from ensuring the
+hardware is usable as a computing device to finding and loading a
+kernel which is then going to take over control of the system. Modern
+firmware often has the ability to boot a kernel directly and in some
+systems you might chain through several boot loaders before the final
+kernel takes control.
+
+The boot loader needs to do 3 things:
+
+  - find a kernel and load it into RAM
+  - ensure the CPU is in the correct mode for the kernel to boot
+  - pass any information the kernel may need to boot and can't find itself
+
+Once it has done these things it can jump to the kernel and let it get
+on with things.
+
+Kernel
+======
+
+The Kernel now takes over and will be in charge of the system from now
+on. It will enumerate all the devices on the system (again) and load
+drivers that can control them. It will then locate some sort of
+file-system and eventually start running programs that actually do
+work.
+
+Questions to ask yourself
+=========================
+
+Having given this overview of booting here are some questions you
+should ask when diagnosing boot problems.
+
+Hardware
+~~~~~~~~
+
+ - is the platform fixed or dynamic?
+ - is the platform enumeratable (e.g. PCI/USB)?
+
+Firmware
+~~~~~~~~
+
+ - is the firmware built for the platform your are booting?
+ - does the firmware need storage for variables (boot index etc)?
+ - does the firmware provide a service to kernels (e.g. ACPI/EFI)?
+
+Kernel
+~~~~~~
+
+ - is the kernel platform specific or generic?
+ - how will the kernel enumerate the platform?
+ - can the kernel interface talk to the firmware?
docs/interop/index.rst +1 -0
index 049387ac6de..58d587444b3 100644
@@ -12,6 +12,7 @@ Contents:
 .. toctree::
    :maxdepth: 2
 
+   booting
    bitmaps
    dbus
    dbus-vmstate
Signature · 1 line
2.20.1
Reviewed-by on v2 1/3
#2 lore raw

Re: [PATCH v2 1/3] docs/booting.rst: start documenting the boot process

Quoted 7 lines · Alex Bennée

While working on some test cases I realised there was quite a lot of assumed knowledge about how things boot up. I thought it would be worth gathering this together in a user facing document where we could pour in the details and background to the boot process. As it's quite wordy I thought it should be a separate document to the manual (which can obviously reference this).

Quoted 6 lines

The document follows the socratic method and leaves the reader to ask themselves some questions in an effort to elucidate them about any problems they may be having.

Message-Id: <[email protected]>

r~

#3 lore raw

Re: [PATCH v2 1/3] docs/booting.rst: start documenting the boot process

In reply to Alex Bennée
Quoted 8 lines · Alex Bennée

While working on some test cases I realised there was quite a lot of assumed knowledge about how things boot up. I thought it would be worth gathering this together in a user facing document where we could pour in the details and background to the boot process. As it's quite wordy I thought it should be a separate document to the manual (which can obviously reference this).

Quoted 7 lines

The document follows the socratic method and leaves the reader to ask themselves some questions in an effort to elucidate them about any problems they may be having.

Message-Id: <[email protected]>

I have some typo/grammar nits below, but more significantly:
I don't really see why this is a bit of QEMU's documentation rather than, say, a blog post. It doesn't really say much about QEMU in particular. It's also rather vague about what guest architecture it's talking about, and they can differ significantly both in the real world and in how QEMU handles them. Also, why put it in interop?

Quoted 33 lines

---
v2
- fix a lot of it's/its
- mention microvm style booting
- add some questions to the end

---
 docs/interop/booting.rst | 159 +++++++++++++++++++++++++++++++++++++++
 docs/interop/index.rst   |   1 +
 2 files changed, 160 insertions(+)
 create mode 100644 docs/interop/booting.rst
docs/interop/booting.rst new file +16 -0
new file mode 100644
index 00000000000..8579a775d04
@@ -0,0 +1,159 @@
+..
+  Copyright (c) 2019-2020 Linaro Ltd.
+
+  This work is licensed under the terms of the GNU GPL, version 2 or
+  later. See the COPYING file in the top-level directory.
+
+=====================================
+Anatomy of a Boot, a QEMU perspective
+=====================================
+
+This document attempts to give an overview of how machines boot and
+how this matters to QEMU. We will discuss firmware and BIOSes and the
+things they do before the OS kernel is loaded and your usable system
+is finally ready.
+
+Firmware

docs/interop/booting.rst line 26

Quoted 10 lines
docs/interop/booting.rst new file +10 -0
+========
+
+When a CPU is powered up it knows nothing about its environment. The
+internal state, including the program counter (PC), will be reset to a
+defined set of values and it will attempt to fetch the first
+instruction and execute it. It is the job of the firmware to bring a
+CPU up from the initial few instructions to running in a relatively
+sane execution environment. Firmware tends to be specific to the
+hardware in question and is stored on non-volatile memory (memory that
+survives a power off) usually a ROM or flash device on the computers

", usually"

Quoted 9 lines
docs/interop/booting.rst new file +9 -0
+main board.
+
+Some examples of what firmware does include:
+
+Early Hardware Setup
+--------------------
+
+Modern hardware often requires configuring before it is usable. For
+example most modern systems won't have working RAM until the memory

docs/interop/booting.rst line 45

Quoted 10 lines
docs/interop/booting.rst new file +10 -0
+controller has been programmed with the correct timings for whatever
+memory is installed on the system. Processors may boot with a very
+restricted view of the memory map until RAM and other key peripherals
+have been configured to appear in its address space. Some hardware
+may not even appear until some sort of blob has been loaded into it so
+it can start responding to the CPU.
+
+Fortunately for QEMU we don't have to worry too much about this very
+low level configuration. The device model we present to the CPU at
+start-up will generally respond to IO access from processor straight

"the processor"

docs/interop/booting.rst line 53

Quoted 8 lines
docs/interop/booting.rst new file +8 -0
+away.
+
+BIOS or Firmware Services
+-------------------------
+
+In the early days of the PC era the BIOS or Basic Input/Output System
+provided an abstraction interface to the operating system which
+allowed them to do basic IO operations without having to directly

"allowed the OS"

docs/interop/booting.rst line 55

Quoted 2 lines
docs/interop/booting.rst new file +2 -0
+drive the hardware. Since then the scope of these firmware services
+have grown as systems become more and more complex.

"has grown"

Quoted 5 lines
docs/interop/booting.rst new file +5 -0
+
+Modern firmware often follows the Unified Extensible Firmware
+Interface (UEFI) which provides services like secure boot, persistent
+variables and external time-keeping.
+

docs/interop/booting.rst line 70

Quoted 10 lines
docs/interop/booting.rst new file +10 -0
+There can often be multiple levels of firmware service functions. For
+example systems which support secure execution enclaves generally have
+a firmware component that executes in this secure mode which the
+operating system can call in a defined secure manner to undertake
+security sensitive tasks on its behalf.
+
+Hardware Enumeration
+--------------------
+
+It is easy to assume that modern hardware is built to be discover-able

"discoverable"

docs/interop/booting.rst line 78

Quoted 8 lines
docs/interop/booting.rst new file +8 -0
+and all the operating system needs to do is enumerate the various
+buses on the system to find out what hardware exists. While buses like
+PCI and USB do support discovery there is usually much more on a
+modern system than just these two things.
+
+This process of discovery can take some time as devices usually need
+to be probed and some time allowed for the buses to settle and the
+probe complete. For purely virtual machines operating in on-demand

"probe to complete".

docs/interop/booting.rst line 90

Quoted 12 lines
docs/interop/booting.rst new file +12 -0
+cloud environments you may operate with stripped down kernels that
+only support a fixed expected environment so they can boot as fast as
+possible.
+
+In the embedded world it used to be acceptable to have a similar
+custom compiled kernel which knew where everything is meant to be.
+However this was a brittle approach and not very flexible. For example
+a general purpose distribution would have to ship a special kernel for
+each variant of hardware you wanted to run on. If you try and use a
+kernel compiled for one platform that nominally uses the same
+processor as another platform the result will rarely work given a
+processor rarely works in isolation.

"the result will generally not work."

Quoted 42 lines
docs/interop/booting.rst new file +42 -0
+
+The more modern approach is to have a "generic" kernel that has a
+number of different drivers compiled in which are then enabled based
+on a hardware description provided by the firmware. This allows
+flexibility on both sides. The software distribution is less concerned
+about managing lots of different kernels for different pieces of
+hardware. The hardware manufacturer is also able to make small changes
+to the board over time to fix bugs or change minor components.
+
+The two main methods for this are the Advanced Configuration and Power
+Interface (ACPI) and Device Trees. ACPI originated from the PC world
+although it is becoming increasingly common for "enterprise" hardware
+like servers. Device Trees of various forms have existed for a while
+with perhaps the most common being Flattened Device Trees (FDT).
+
+Boot Code
+=========
+
+The line between firmware and boot code is a very blurry one. However
+from a functionality point of view we have moved from ensuring the
+hardware is usable as a computing device to finding and loading a
+kernel which is then going to take over control of the system. Modern
+firmware often has the ability to boot a kernel directly and in some
+systems you might chain through several boot loaders before the final
+kernel takes control.
+
+The boot loader needs to do 3 things:
+
+  - find a kernel and load it into RAM
+  - ensure the CPU is in the correct mode for the kernel to boot
+  - pass any information the kernel may need to boot and can't find itself
+
+Once it has done these things it can jump to the kernel and let it get
+on with things.
+
+Kernel
+======
+
+The Kernel now takes over and will be in charge of the system from now
+on. It will enumerate all the devices on the system (again) and load
+drivers that can control them. It will then locate some sort of
+file-system and eventually start running programs that actually do

docs/interop/booting.rst line 142

Quoted 10 lines
docs/interop/booting.rst new file +10 -0
+work.
+
+Questions to ask yourself
+=========================
+
+Having given this overview of booting here are some questions you
+should ask when diagnosing boot problems.
+
+Hardware
+~~~~~~~~

Previously you used '-----' as the title format for "next level below "====="; Sphinx will complain that you're not being consistent (see the patchew emails).

docs/interop/booting.rst line 150

Quoted 8 lines
docs/interop/booting.rst new file +8 -0
+
+ - is the platform fixed or dynamic?
+ - is the platform enumeratable (e.g. PCI/USB)?
+
+Firmware
+~~~~~~~~
+
+ - is the firmware built for the platform your are booting?

"you are"

Quoted 14 lines
docs/interop/booting.rst new file +9 -0
+ - does the firmware need storage for variables (boot index etc)?
+ - does the firmware provide a service to kernels (e.g. ACPI/EFI)?
+
+Kernel
+~~~~~~
+
+ - is the kernel platform specific or generic?
+ - how will the kernel enumerate the platform?
+ - can the kernel interface talk to the firmware?
docs/interop/index.rst +0 -0
index 049387ac6de..58d587444b3 100644

docs/interop/index.rst Contents:

Quoted 8 lines
docs/interop/index.rst +1 -1
@@ -12,6 +12,7 @@ Contents:
 .. toctree::
    :maxdepth: 2
 
+   booting
    bitmaps
    dbus
    dbus-vmstate
--

thanks
-- PMM

#4 lore raw

Re: [PATCH v2 1/3] docs/booting.rst: start documenting the boot process

Quoted 13 lines · Peter Maydell
Quoted 12 lines · Alex Bennée

While working on some test cases I realised there was quite a lot of assumed knowledge about how things boot up. I thought it would be worth gathering this together in a user facing document where we could pour in the details and background to the boot process. As it's quite wordy I thought it should be a separate document to the manual (which can obviously reference this).

The document follows the socratic method and leaves the reader to ask themselves some questions in an effort to elucidate them about any problems they may be having.

Quoted 7 lines
Quoted 3 lines

Message-Id: <[email protected]>

I have some typo/grammar nits below, but more significantly:
I don't really see why this is a bit of QEMU's documentation rather than, say, a blog post.

The aim was to make it an initial overview so when people ask about why they can't boot their systems they have considered the questions at the end. It does seem to be a repeating topic on the IRC channel.

Quoted 5 lines

It doesn't really say much
about QEMU in particular. It's also rather vague about what guest architecture it's talking about, and they can differ significantly both in the real world and in how QEMU handles them.

Perhaps what we really need is a shorter punchier section offering guidance in the manual itself? It just seemed quite a big topic which is why I ended up with a fairly long explanation without even getting to specifics.

I could certainly see the document being expanded in the future with more concrete examples for various architectures and scenarios.

Quoted 1 line

Also, why put it in interop?

interop being where QEMU interfaces with other things such as kernels and firmwares? It seems too user focused for devel and too long for the manual itself.

Signature · 1 line
Alex Bennée
#5 lore raw

PATCH v2 2/3 docs/devel: convert and update MTTCG design document

In reply to Alex Bennée

Do a light conversion to .rst and clean-up some of the language at the start now MTTCG has been merged for a while.

---
 docs/devel/index.rst                          |  1 +
 ...ti-thread-tcg.txt => multi-thread-tcg.rst} | 52 ++++++++++++-------
 2 files changed, 34 insertions(+), 19 deletions(-)
 rename docs/devel/{multi-thread-tcg.txt => multi-thread-tcg.rst} (90%)
docs/devel/index.rst +1 -0
index bb8238c5d6d..4ecaea3643f 100644
@@ -23,6 +23,7 @@ Contents:
    decodetree
    secure-coding-practices
    tcg
+   multi-thread-tcg
    tcg-plugins
    bitops
    reset
docs/devel/multi-thread-tcg.rst renamed from docs/devel/multi-thread-tcg.txt +33 -19

94 lines not on this page · raw message

Signature · 1 line
2.20.1
Reviewed-by on v2 2/3
#6 lore raw

Re: [PATCH v2 2/3] docs/devel: convert and update MTTCG design document

docs/devel/multi-thread-tcg.rst line 11

Quoted 6 lines · Alex Bennée
docs/devel/multi-thread-tcg.rst renamed from docs/devel/multi-thread-tcg.txt +2 -4
-This document outlines the design for multi-threaded TCG system-mode
-emulation. The current user-mode emulation mirrors the thread
-structure of the translated executable. Some of the work will be
-applicable to both system and linux-user emulation.
+This document outlines the design for multi-threaded TCG (a.k.a MTTCG)
+system-mode emulation. user-mode emulation has always mirrored the

Full stop wants capitalization for the next sentence. Though perhaps em-dash or semicolon would work as well to connect these clauses.

Quoted 1 line

+guest (TCG_GUEST_DEFAULT_MO & ~TCG_TARGET_DEFAULT_MO is zero) and the

Isn't there some markup for code? ... perhaps?

Otherwise,

r~

#7 lore raw

PATCH v2 3/3 docs/devel: add some notes on tcg-icount for developers

In reply to Alex Bennée

This attempts to bring together my understanding of the requirements for icount behaviour into one reference document for our developer notes.

Cc Paolo Bonzini <[email protected]>
Cc Pavel Dovgalyuk <[email protected]>
Cc Peter Maydell <[email protected]>

Message-Id: <[email protected]>

---
v2
- fix copyright date
- it's -> its
- drop mentioned of gen_io_end()
- remove and correct original conjecture
v3
- include link in index

---
 docs/devel/index.rst      |  1 +
 docs/devel/tcg-icount.rst | 89 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 90 insertions(+)
 create mode 100644 docs/devel/tcg-icount.rst
docs/devel/index.rst +1 -0
index 4ecaea3643f..ae6eac7c9c6 100644
@@ -23,6 +23,7 @@ Contents:
    decodetree
    secure-coding-practices
    tcg
+   tcg-icount
    multi-thread-tcg
    tcg-plugins
    bitops
docs/devel/tcg-icount.rst new file +89 -0

89 lines not on this page · raw message

Signature · 1 line
2.20.1
#8 lore raw

Re: [PATCH v2 3/3] docs/devel: add some notes on tcg-icount for developers

Quoted 45 lines · Alex Bennée

This attempts to bring together my understanding of the requirements for icount behaviour into one reference document for our developer notes.

Cc Paolo Bonzini <[email protected]>
Cc Pavel Dovgalyuk <[email protected]>
Cc Peter Maydell <[email protected]>

Message-Id: <[email protected]>

---
v2
- fix copyright date
- it's -> its
- drop mentioned of gen_io_end()
- remove and correct original conjecture
v3
- include link in index

---
 docs/devel/index.rst      |  1 +
 docs/devel/tcg-icount.rst | 89 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 90 insertions(+)
 create mode 100644 docs/devel/tcg-icount.rst
docs/devel/index.rst +1 -0
index 4ecaea3643f..ae6eac7c9c6 100644
@@ -23,6 +23,7 @@ Contents:
    decodetree
    secure-coding-practices
    tcg
+   tcg-icount
    multi-thread-tcg
    tcg-plugins
    bitops
docs/devel/tcg-icount.rst new file +1 -0
new file mode 100644
index 00000000000..cb51cb34dde
@@ -0,0 +1,89 @@
+..

docs/devel/tcg-icount.rst line 11

Quoted 10 lines
docs/devel/tcg-icount.rst new file +10 -0
+   Copyright (c) 2020, Linaro Limited
+   Written by Alex Bennée
+
+
+========================
+TCG Instruction Counting
+========================
+
+TCG has long supported a feature known as icount which allows for
+instruction counting during execution. This should be confused with

Shurely "should not be confused" :-)

Quoted 11 lines
docs/devel/tcg-icount.rst new file +11 -0
+cycle accurate emulation - QEMU does not attempt to emulate how long
+an instruction would take on real hardware. That is a job for other
+more detailed (and slower) tools that simulate the rest of a
+micro-architecture.
+
+This feature is only available for system emulation and is
+incompatible with multi-threaded TCG. It can be used to better align
+execution time with wall-clock time so a "slow" device doesn't run too
+fast on modern hardware. It can also provides for a degree of
+deterministic execution and is an essential part of the record/replay
+support in QEMU.

docs/devel/tcg-icount.rst line 32

Quoted 10 lines
docs/devel/tcg-icount.rst new file +10 -0
+
+Core Concepts
+=============
+
+At its heart icount is simply a count of executed instructions which
+is stored in the TimersState of QEMU's timer sub-system. The number of
+executed instructions can then be used to calculate QEMU_CLOCK_VIRTUAL
+which represents the amount of elapsed time in the system since
+execution started. Depending on the icount mode this may either be a
+fixed number of ns per instructions or adjusted as execution continues

"per instruction"

docs/devel/tcg-icount.rst line 44

Quoted 12 lines
docs/devel/tcg-icount.rst new file +12 -0
+to keep wall clock time and virtual time in sync.
+
+To be able to calculate the number of executed instructions the
+translator starts by allocating a budget of instructions to be
+executed. The budget of instructions is limited by how long it will be
+until the next timer will expire. We store this budget as part of a
+vCPU icount_decr field which shared with the machinery for handling
+cpu_exit(). The whole field is checked at the start of every
+translated block and will cause a return to the outer loop to deal
+with whatever caused the exit.
+
+In the case of icount before the flag is checked we subtract the

"of icount, "

docs/devel/tcg-icount.rst line 46

Quoted 2 lines
docs/devel/tcg-icount.rst new file +2 -0
+number of instructions the translation block would execute. If this
+would cause the instruction budget to got negative we exit the main

"to go negative"

docs/devel/tcg-icount.rst line 48

Quoted 2 lines
docs/devel/tcg-icount.rst new file +2 -0
+loop and regenerate a new translation block with exactly the right
+number of instructions to take the budget to 0 meaning whatever timer

"to 0. This means that whatever timer"

docs/devel/tcg-icount.rst line 55

Quoted 7 lines
docs/devel/tcg-icount.rst new file +7 -0
+was due to expire will expire exactly when we exit the main run loop.
+
+Dealing with MMIO
+-----------------
+
+While we can adjust the instruction budget for known events like timer
+expiry we can not do the same for MMIO. Every load/store we execute

"cannot"

docs/devel/tcg-icount.rst line 56

Quoted 1 line
docs/devel/tcg-icount.rst new file +1 -0
+might potentially trigger an I/O event at which point we will need an

"event, at which point"

docs/devel/tcg-icount.rst line 59

Quoted 3 lines
docs/devel/tcg-icount.rst new file +3 -0
+up to date and accurate reading of the icount number.
+
+To deal with this case when an I/O access is made we:

"this case, when"

Quoted 16 lines
docs/devel/tcg-icount.rst new file +16 -0
+
+  - restore un-executed instructions to the icount budget
+  - re-compile a single [1]_ instruction block for the current PC
+  - exit the cpu loop and execute the re-compiled block
+
+The new block is created with the CF_LAST_IO compile flag which
+ensures the final instruction translation starts with a call to
+gen_io_start() so we don't enter a perpetual loop constantly
+recompiling a single instruction block. For translators using the
+common translator_loop this is done automatically.
+
+.. [1] sometimes two instructions if dealing with delay slots
+
+Other I/O operations
+--------------------
+

docs/devel/tcg-icount.rst line 85

Quoted 10 lines
docs/devel/tcg-icount.rst new file +10 -0
+MMIO isn't the only type of operation for which we might need a
+correct and accurate clock. IO port instructions and accesses to
+system registers are the common examples here. These instructions have
+to be handled by the individual translators which have the knowledge
+of which operations are I/O operations.
+
+.. warning:: Any instruction that eventually causes an access to
+             QEMU_CLOCK_VIRTUAL needs to be preceded by a
+             gen_io_start() and must also be the last instruction
+             translated in the block.

I think I would prefer some text phrased in a way that more explicitly states what the frontend code has to do, like:

======
When the translator is handling an instruction of this kind:
* it must call gen_io_start() if icount is enabled, at some point before the generation of the code which actually does the I/O, using a code fragment similar to:

        if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) {
            gen_io_start();
        }

* it must end the TB immediately after this instruction

Note that some older front-ends call a "gen_io_end()" function:
this is obsolete and should not be used.
======

thanks
-- PMM

#9 lore raw
In reply to Alex Bennée
Patchew URL: https://patchew.org/QEMU/[email protected]/

Patchew URL: https://patchew.org/QEMU/[email protected]/

Hi,

This series failed the docker-mingw@fedora build test. Please find the testing commands and their output below. If you have Docker installed, you can probably reproduce it locally.

=== TEST SCRIPT BEGIN ===
#! /bin/bash
export ARCH=x86_64
make docker-image-fedora V=1 NETWORK=1
time make docker-test-mingw@fedora J=14 NETWORK=1
=== TEST SCRIPT END ===

CC util/cutils.o
CC util/unicode.o

Warning, treated as error:
/tmp/qemu-test/src/docs/interop/booting.rst:141:Title level inconsistent:

Hardware
---
CC util/qemu-thread-win32.o
CC util/envlist.o

Warning, treated as error:
/tmp/qemu-test/src/docs/interop/booting.rst:141:Title level inconsistent:

Hardware
~~~~~~~~
CC util/path.o
make: *** [Makefile:1108: .docs_interop_qemu-ga.8.sentinel.] Error 2
make: *** Deleting file '.docs_interop_qemu-ga.8.sentinel.'
make: *** Waiting for unfinished jobs....
make: *** [Makefile:1093: docs/interop/index.html] Error 2 Traceback (most recent call last):
File "./tests/docker/docker.py", line 669, in <module>

    sys.exit(main())

---
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['sudo', '-n', 'docker', 'run', '--label', 'com.qemu.instance.uuid=8aa5ca1bf60d4a9a844021819abc67e4', '-u', '1001', '--security-opt', 'seccomp=unconfined', '--rm', '-e', 'TARGET_LIST=', '-e', 'EXTRA_CONFIGURE_OPTS=', '-e', 'V=', '-e', 'J=14', '-e', 'DEBUG=', '-e', 'SHOW_ENV=', '-e', 'CCACHE_DIR=/var/tmp/ccache', '-v', '/home/patchew/.cache/qemu-docker-ccache:/var/tmp/ccache:z', '-v', '/var/tmp/patchew-tester-tmp-chc922my/src/docker-src.2020-07-01-12.52.42.12836:/var/tmp/qemu:z,ro', 'qemu:fedora', '/var/tmp/qemu/run', 'test-mingw']' returned non-zero exit status 2. filter=--filter=label=com.qemu.instance.uuid=8aa5ca1bf60d4a9a844021819abc67e4
make[1]: *** [docker-run] Error 1
make[1]: Leaving directory `/var/tmp/patchew-tester-tmp-chc922my/src'
make: *** [docker-run-test-mingw@fedora] Error 2

real 3m5.559s
user 0m8.570s

The full log is available at
http://patchew.org/logs/[email protected]/testing.docker-mingw@fedora/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]

#10 lore raw
In reply to Alex Bennée
Patchew URL: https://patchew.org/QEMU/[email protected]/

Patchew URL: https://patchew.org/QEMU/[email protected]/

Hi,

This series seems to have some coding style problems. See output below for more information:

Subject: [PATCH v2 0/3] some docs (booting, mttcg, icount)
Type: series
Message-id: [email protected]

=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384 Switched to a new branch 'test'
f0c6933 docs/devel: add some notes on tcg-icount for developers b4ed66b docs/devel: convert and update MTTCG design document 2c9c289 docs/booting.rst: start documenting the boot process

=== OUTPUT BEGIN ===
1/3 Checking commit 2c9c289aa77c (docs/booting.rst: start documenting the boot process)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #24:
new file mode 100644

total: 0 errors, 1 warnings, 166 lines checked

Patch 1/3 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
2/3 Checking commit b4ed66b650ef (docs/devel: convert and update MTTCG design document)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #27:
rename from docs/devel/multi-thread-tcg.txt

total: 0 errors, 1 warnings, 97 lines checked

Patch 2/3 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
3/3 Checking commit f0c6933d34a5 (docs/devel: add some notes on tcg-icount for developers)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #33:
new file mode 100644

ERROR: trailing whitespace
#107: FILE: docs/devel/tcg-icount.rst:70:
+ $

ERROR: trailing whitespace
#108: FILE: docs/devel/tcg-icount.rst:71:
+.. [1] sometimes two instructions if dealing with delay slots $

ERROR: trailing whitespace
#123: FILE: docs/devel/tcg-icount.rst:86:
+ $

total: 3 errors, 1 warnings, 96 lines checked

Patch 3/3 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.

=== OUTPUT END ===

Test command exited with code: 1

The full log is available at
http://patchew.org/logs/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]