Re: [RFC PATCH v3 17/36] pflash_cfi01/tdx: Introduce ram_mode of pflash for TDVF

2022-03-30 Thread Xiaoyao Li
On 3/24/2022 4:35 PM, Gerd Hoffmann wrote: On Tue, Mar 22, 2022 at 01:20:24PM +0100, Gerd Hoffmann wrote: Hi, At the time I did try a gross hack that (IIRC) disabled the rom_reset logic, and munged x86_bios_rom_init so that it would force load it straight at the RAM location. Sounds reaso

[PATCH] coverity: update model for latest tools

2022-03-30 Thread Paolo Bonzini
Coverity is now rejecting incomplete types in the modeling file. Just use a random number (in the neighborhood of the actual one) for the size of a GIOChannel. Signed-off-by: Paolo Bonzini --- scripts/coverity-scan/model.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scr

Re: iotest40 problem

2022-03-30 Thread Hanna Reitz
On 29.03.22 18:49, Li Zhang wrote: Update what I observed. It seems that aqmp is not stable when running test cases. So I revert the patches as the following, iotest40/41 test cases work well. Thanks for bisecting.  I haven’t seen this problem before, so I didn’t look into it; CC-ing John, p

[PATCH v3] vdpa: reset the backend device in the end of vhost_net_stop()

2022-03-30 Thread 08005325
From: Michael Qiu Currently, when VM poweroff, it will trigger vdpa device(such as mlx bluefield2 VF) reset many times(with 1 datapath queue pair and one control queue, triggered 3 times), this leads to below issue: vhost VQ 2 ring restore failed: -22: Invalid argument (22) This because in vhos

Re: Re: [PATCH] target/riscv: Exit current TB after an sfence.vma

2022-03-30 Thread Alistair Francis
On Thu, Mar 31, 2022 at 2:36 PM Palmer Dabbelt wrote: > > On Wed, 30 Mar 2022 20:23:21 PDT (-0700), alistai...@gmail.com wrote: > > On Thu, Mar 31, 2022 at 3:11 AM Idan Horowitz > > wrote: > >> > >> On Wed, 30 Mar 2022 at 19:11, Palmer Dabbelt wrote: > >> > > >> > > >> > Presumably you mean "re

Re: [PATCH] target/riscv: Avoid leaking "no translation" TLB entries

2022-03-30 Thread Alistair Francis
On Thu, Mar 31, 2022 at 3:11 AM Palmer Dabbelt wrote: > > The ISA doesn't allow bare mappings to be cached, as the caches are > translations and bare mppings are not translated. We cache these > translations in QEMU in order to utilize the TLB code, but that leaks > out to the guest. > > Suggeste

[RFC PATCH 4/7] aspeed: i2c: Use reg array instead of individual vars

2022-03-30 Thread Joe Komlodi
Using a register array will allow us to represent old-mode and new-mode I2C registers by using the same underlying register array, instead of adding an entire new set of variables to represent new mode. As part of this, we also do additional cleanup to use ARRAY_FIELD_ macros instead of FIELD_ mac

Re: [RFC PATCH 1/2] spapr: Report correct GTSE support via ov5

2022-03-30 Thread David Gibson
On Mon, Mar 14, 2022 at 07:10:10PM -0300, Fabiano Rosas wrote: > David Gibson writes: > > > On Tue, Mar 08, 2022 at 10:23:59PM -0300, Fabiano Rosas wrote: > >> QEMU reports MMU support to the guest via the ibm,architecture-vec-5 > >> property of the /chosen node. Byte number 26 specifies Radix Ta

[RFC PATCH 1/7] hw/registerfields: Add shared fields macros

2022-03-30 Thread Joe Komlodi
Occasionally a peripheral will have different operating modes, where the MMIO layout changes, but some of the register fields have the same offsets and behaviors. To help support this, we add SHARED_FIELD_XX macros that create SHIFT, LENGTH, and MASK macros for the fields that are shared across re

[RFC PATCH 2/7] aspeed: i2c: Add ctrl_global_rsvd property

2022-03-30 Thread Joe Komlodi
The Aspeed I2C controller is used across other SKUs that have different reserved bits for the ctrl_global_rsvd register. Signed-off-by: Joe Komlodi Change-Id: I606c5933c527274a9d2b0afe559b2e895767636c --- hw/arm/aspeed_ast2600.c | 2 ++ hw/i2c/aspeed_i2c.c | 4 include/hw/i2c/as

[RFC PATCH 0/7] aspeed: i2c: Add new mode support

2022-03-30 Thread Joe Komlodi
Hi all, This series migrates the Aspeed I2C controller to use the register API, and then adds new mode support. New mode has some behavior changes and a register layout change compared to old mode. The series starts by adding "shared field" macros to help simplify logic when adding new mode. Gen

[RFC PATCH 3/7] aspeed: i2c: Migrate to registerfields API

2022-03-30 Thread Joe Komlodi
This cleans up some of the field accessing, setting, and clearing bitwise operations, and wraps them in macros instead. Signed-off-by: Joe Komlodi Change-Id: I33018d6325fa04376e7c29dc4a49ab389a8e333a --- hw/i2c/aspeed_i2c.c | 393 ++-- 1 file changed, 196

Re: Re: [PATCH] target/riscv: Exit current TB after an sfence.vma

2022-03-30 Thread Palmer Dabbelt
On Wed, 30 Mar 2022 20:23:21 PDT (-0700), alistai...@gmail.com wrote: On Thu, Mar 31, 2022 at 3:11 AM Idan Horowitz wrote: On Wed, 30 Mar 2022 at 19:11, Palmer Dabbelt wrote: > > > Presumably you mean "revert" here? That might be the right way to go, > just to avoid breaking users (even if w

[RFC PATCH 7/7] aspeed: i2c: Move regs and helpers to header file

2022-03-30 Thread Joe Komlodi
Moves register definitions and short commonly used inlined functiosn to the header file to help tidy up the implementation file. Signed-off-by: Joe Komlodi Change-Id: I34dff7485b6bbe3c9482715ccd94dbd65dc5f324 --- hw/i2c/aspeed_i2c.c | 266 --- include/hw/i

[RFC PATCH 6/7] aspeed: i2c: Add PKT_DONE IRQ to trace

2022-03-30 Thread Joe Komlodi
Signed-off-by: Joe Komlodi Change-Id: I566eb09f4b9016e24570572f367627f6594039f5 --- hw/i2c/aspeed_i2c.c | 3 +++ hw/i2c/trace-events | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/hw/i2c/aspeed_i2c.c b/hw/i2c/aspeed_i2c.c index 948d8dc2bb..f179f78ee9 100644 --- a/hw/i2c/asp

[RFC PATCH 5/7] aspeed: i2c: Add new mode support

2022-03-30 Thread Joe Komlodi
On AST2600, I2C has a secondary mode, called "new mode", which changes the layout of registers, adds some minor behavior changes, and introduces a new way to transfer data called "packet mode". Most of the bit positions of the fields are the same between old and new mode, so we use SHARED_FIELD_XX

Re: [PATCH v2] vdpa: reset the backend device in stage of stop last vhost device

2022-03-30 Thread Michael Qiu
On 2022/3/31 8:15, Si-Wei Liu wrote: On 3/30/2022 3:02 AM, 08005...@163.com wrote: From: Michael Qiu Currently, when VM poweroff, it will trigger vdpa device(such as mlx bluefield2 VF) reset many times(with 1 datapath queue pair and one control queue, triggered 3 times), this leads to bel

Re: [PATCH v2] vdpa: reset the backend device in stage of stop last vhost device

2022-03-30 Thread Michael Qiu
On 2022/3/31 8:15, Si-Wei Liu wrote: On 3/30/2022 3:02 AM, 08005...@163.com wrote: From: Michael Qiu Currently, when VM poweroff, it will trigger vdpa device(such as mlx bluefield2 VF) reset many times(with 1 datapath queue pair and one control queue, triggered 3 times), this leads to bel

Re: Re: [PATCH] target/riscv: Exit current TB after an sfence.vma

2022-03-30 Thread Alistair Francis
On Thu, Mar 31, 2022 at 3:11 AM Idan Horowitz wrote: > > On Wed, 30 Mar 2022 at 19:11, Palmer Dabbelt wrote: > > > > > > Presumably you mean "revert" here? That might be the right way to go, > > just to avoid breaking users (even if we fix the kernel bug, it'll take > > a while to get everyone t

Re: [PATCH qemu v7 00/14] Add tail agnostic behavior for rvv instructions

2022-03-30 Thread Alistair Francis
On Thu, Mar 31, 2022 at 11:24 AM Weiwei Li wrote: > > > 在 2022/3/31 上午8:11, Alistair Francis 写道: > > On Wed, Mar 30, 2022 at 10:52 PM Weiwei Li wrote: > >> > >> 在 2022/3/30 下午6:24, ~eopxd 写道: > >>> According to v-spec, tail agnostic behavior can be either kept as > >>> undisturbed or set elements

Re: [RFC PATCH v3 1/4] target/riscv: Add smstateen support

2022-03-30 Thread Alistair Francis
On Tue, Mar 29, 2022 at 3:24 AM Mayuresh Chitale wrote: > > Smstateen extension specifies a mechanism to close > the potential covert channels that could cause security issues. > > This patch adds the CSRs defined in the specification and > the corresponding predicates and read/write functions. >

RE: [PATCH 2/4] net/colo: Fix a "double free" crash to clear the conn_list

2022-03-30 Thread Zhang, Chen
> -Original Message- > From: lizhij...@fujitsu.com > Sent: Thursday, March 31, 2022 9:15 AM > To: Zhang, Chen ; Jason Wang > > Cc: qemu-dev ; Like Xu > Subject: Re: [PATCH 2/4] net/colo: Fix a "double free" crash to clear the > conn_list > > > connection_track_table > -+-

Re: [PATCH v2] vdpa: reset the backend device in stage of stop last vhost device

2022-03-30 Thread Michael Qiu
Michael, Others has already received the patch, don't know why. Anyway, I will repost another version(V3). Here is the V2 patch, see below: From: Michael Qiu Currently, when VM poweroff, it will trigger vdpa device(such as mlx bluefield2 VF) reset many times(with 1 datapath queue pair and o

Re: [RFC PATCH v7 11/29] target/loongarch: Add LoongArch interrupt and exception handle

2022-03-30 Thread yangxiaojuan
On 2022/3/29 上午4:19, Richard Henderson wrote: On 3/28/22 06:57, Xiaojuan Yang wrote: 1.This patch Add loongarch interrupt and exception handle. 2.Rename the user excp to the exccode from the csr defintions. Signed-off-by: Xiaojuan Yang Signed-off-by: Song Gao ---   linux-user/loongarch64/cp

Re: [PATCH v2 2/4] target/ppc: init 'lpcr' in kvmppc_enable_cap_large_decr()

2022-03-30 Thread David Gibson
On Wed, Mar 30, 2022 at 09:17:15PM -0300, Daniel Henrique Barboza wrote: > 'lpcr' is used as an input of kvm_get_one_reg(). Valgrind doesn't > understand that and it returns warnings as such for this function: > > ==55240== Thread 1: > ==55240== Conditional jump or move depends on uninitialised va

Re: [PATCH v2 1/4] target/ppc: initialize 'val' union in kvm_get_one_spr()

2022-03-30 Thread David Gibson
On Wed, Mar 30, 2022 at 09:17:14PM -0300, Daniel Henrique Barboza wrote: > Valgrind isn't convinced that we are initializing the values we assign > to env->spr[spr] because it doesn't understand that the 'val' union is > being written by the kvm_vcpu_ioctl() that follows (via struct > kvm_one_reg).

Re: [RFC PATCH v7 17/29] hw/intc: Add LoongArch ls7a interrupt controller support(PCH-PIC)

2022-03-30 Thread yangxiaojuan
On 2022/3/29 上午4:18, Mark Cave-Ayland wrote: On 28/03/2022 13:57, Xiaojuan Yang wrote: This patch realize the PCH-PIC interrupt controller. Signed-off-by: Xiaojuan Yang Signed-off-by: Song Gao ---   hw/intc/Kconfig |   4 +   hw/intc/loongarch_pch_pic.c | 488

Re: [PATCH qemu v7 00/14] Add tail agnostic behavior for rvv instructions

2022-03-30 Thread Weiwei Li
在 2022/3/31 上午8:11, Alistair Francis 写道: On Wed, Mar 30, 2022 at 10:52 PM Weiwei Li wrote: 在 2022/3/30 下午6:24, ~eopxd 写道: According to v-spec, tail agnostic behavior can be either kept as undisturbed or set elements' bits to all 1s. To distinguish the difference of tail policies, QEMU shoul

Re: [RFC PATCH v7 10/29] target/loongarch: Add other core instructions support

2022-03-30 Thread yangxiaojuan
On 2022/3/29 上午4:16, Richard Henderson wrote: On 3/28/22 06:57, Xiaojuan Yang wrote: +void helper_idle(CPULoongArchState *env) +{ +    CPUState *cs = env_cpu(env); + +    cs->halted = 1; +    cpu_reset_interrupt(cs, CPU_INTERRUPT_WAKE); +    do_raise_exception(env, EXCP_HLT, 0); +} Why are y

Re: [RFC PATCH v7 16/29] hw/loongarch: Add LoongArch ipi interrupt support(IPI)

2022-03-30 Thread yangxiaojuan
Hi Mark, On 2022/3/29 上午4:15, Mark Cave-Ayland wrote: + +#define TYPE_LOONGARCH_IPI "loongarch_ipi" +OBJECT_DECLARE_SIMPLE_TYPE(LoongArchIPI, LOONGARCH_IPI) + +typedef struct IPICore { +    uint32_t status; +    uint32_t en; +    uint32_t set; +    uint32_t clear; +    /* 64bit buf divide into 2

Re: [PATCH 2/4] net/colo: Fix a "double free" crash to clear the conn_list

2022-03-30 Thread lizhij...@fujitsu.com
connection_track_table -+-- key1 | conn|---+ -+-- | key2 | conn|--+| -+--

Re: [RFC PATCH v7 09/29] target/loongarch: Add TLB instruction support

2022-03-30 Thread yangxiaojuan
On 2022/3/29 上午4:12, Richard Henderson wrote: On 3/28/22 06:57, Xiaojuan Yang wrote: +static void output_empty(DisasContext *ctx, arg_empty *a, + const char *mnemonic) +{ +} No, you must still do     output(ctx, mnemonic, ""); +static bool trans_tlbwr(DisasContext

Re: [RFC PATCH v7 05/29] target/loongarch: Add constant timer support

2022-03-30 Thread yangxiaojuan
On 2022/3/29 上午3:46, Richard Henderson wrote: On 3/28/22 06:57, Xiaojuan Yang wrote: +void cpu_loongarch_store_constant_timer_config(LoongArchCPU *cpu, +   uint64_t value) +{ +    CPULoongArchState *env = &cpu->env; +    uint64_t now, next; + +    en

Re: [PATCH 1/4] s390x: follow qdev tree to detect SCSI device on a CCW bus

2022-03-30 Thread Halil Pasic
On Mon, 28 Mar 2022 16:30:16 +0200 Paolo Bonzini wrote: > Do not make assumptions on the parent type of the SCSIDevice, instead > use object_dynamic_cast all the way up to the CcwDevice. This is cleaner > because there is no guarantee that the bus is on a virtio-scsi device; > that is only the c

Re: [PATCH] hw/riscv: virt: Warn the user if -bios is provided when using KVM

2022-03-30 Thread Alistair Francis
On Thu, Mar 24, 2022 at 7:08 PM Daniel P. Berrangé wrote: > > On Wed, Mar 23, 2022 at 06:13:46PM +0100, Ralf Ramsauer wrote: > > The -bios option is silently ignored if used in combination with > > -enable-kvm. > > The reason is that the machine starts in S-Mode, and the bios typically > > runs

[PATCH v2 2/4] target/ppc: init 'lpcr' in kvmppc_enable_cap_large_decr()

2022-03-30 Thread Daniel Henrique Barboza
'lpcr' is used as an input of kvm_get_one_reg(). Valgrind doesn't understand that and it returns warnings as such for this function: ==55240== Thread 1: ==55240== Conditional jump or move depends on uninitialised value(s) ==55240==at 0xB011E4: kvmppc_enable_cap_large_decr (kvm.c:2546) ==55240=

Re: [PATCH v7] target/riscv: Add isa extenstion strings to the device tree

2022-03-30 Thread Alistair Francis
On Wed, Mar 30, 2022 at 5:59 AM Atish Patra wrote: > > The Linux kernel parses the ISA extensions from "riscv,isa" DT > property. It used to parse only the single letter base extensions > until now. A generic ISA extension parsing framework was proposed[1] > recently that can parse multi-letter IS

[PATCH v2 0/4] ppc: valgrind "uninitialized values" fixes

2022-03-30 Thread Daniel Henrique Barboza
Changes from v1: - patch 1: init 'val' union in a single statement - all patches: * added Philippe's R-b * changed initialization format from {0} to { } - v1 link: https://lists.gnu.org/archive/html/qemu-devel/2022-03/msg07234.html Daniel Henrique Barboza (4): target/ppc: initialize 'val' un

[PATCH v2 3/4] target/ppc: init 'sregs' in kvmppc_put_books_sregs()

2022-03-30 Thread Daniel Henrique Barboza
Init 'sregs' to avoid Valgrind complaints about uninitialized bytes from kvmppc_put_books_sregs(): ==54059== Thread 3: ==54059== Syscall param ioctl(generic) points to uninitialised byte(s) ==54059==at 0x55864E4: ioctl (in /usr/lib64/libc.so.6) ==54059==by 0xD1FA23: kvm_vcpu_ioctl (kvm-all

[PATCH v2 4/4] target/ppc: init 'rmmu_info' in kvm_get_radix_page_info()

2022-03-30 Thread Daniel Henrique Barboza
Init the struct to avoid Valgrind complaints about unitialized bytes, such as this one: ==39549== Syscall param ioctl(generic) points to uninitialised byte(s) ==39549==at 0x55864E4: ioctl (in /usr/lib64/libc.so.6) ==39549==by 0xD1F7EF: kvm_vm_ioctl (kvm-all.c:3035) ==39549==by 0xAF8F5B

Re: [PATCH v2] vdpa: reset the backend device in stage of stop last vhost device

2022-03-30 Thread Si-Wei Liu
On 3/30/2022 3:02 AM, 08005...@163.com wrote: From: Michael Qiu Currently, when VM poweroff, it will trigger vdpa device(such as mlx bluefield2 VF) reset many times(with 1 datapath queue pair and one control queue, triggered 3 times), this leads to below issue: vhost VQ 2 ring restore faile

[PATCH v7 12/12] target/riscv: Update the privilege field for sscofpmf CSRs

2022-03-30 Thread Atish Patra
The sscofpmf extension was ratified as a part of priv spec v1.12. Mark the csr_ops accordingly. Signed-off-by: Atish Patra --- target/riscv/csr.c | 90 ++ 1 file changed, 60 insertions(+), 30 deletions(-) diff --git a/target/riscv/csr.c b/target/riscv

Re: [RESEND PATCH] target/riscv: fix start byte for vmvr.v when vstart != 0

2022-03-30 Thread Alistair Francis
On Wed, Mar 30, 2022 at 12:14 PM Weiwei Li wrote: > > The spec for vmvr.v says: 'the instructions operate as if EEW=SEW, > EMUL = NREG, effective length evl= EMUL * VLEN/SEW.' > > So the start byte for vstart != 0 should take sew into account > > Signed-off-by: Weiwei Li > Signed-off-by: Junqiang

[PATCH v2 1/4] target/ppc: initialize 'val' union in kvm_get_one_spr()

2022-03-30 Thread Daniel Henrique Barboza
Valgrind isn't convinced that we are initializing the values we assign to env->spr[spr] because it doesn't understand that the 'val' union is being written by the kvm_vcpu_ioctl() that follows (via struct kvm_one_reg). This results in Valgrind complaining about uninitialized values every time we u

Re: [PATCH qemu v7 00/14] Add tail agnostic behavior for rvv instructions

2022-03-30 Thread Alistair Francis
On Wed, Mar 30, 2022 at 10:52 PM Weiwei Li wrote: > > > 在 2022/3/30 下午6:24, ~eopxd 写道: > > According to v-spec, tail agnostic behavior can be either kept as > > undisturbed or set elements' bits to all 1s. To distinguish the > > difference of tail policies, QEMU should be able to simulate the tail

[PATCH v7 08/12] target/riscv: Add sscofpmf extension support

2022-03-30 Thread Atish Patra
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. A

[PATCH v7 09/12] target/riscv: Simplify counter predicate function

2022-03-30 Thread Atish Patra
All the hpmcounters and the fixed counters (CY, IR, TM) can be represented as a unified counter. Thus, the predicate function doesn't need handle each case separately. Simplify the predicate function so that we just handle things differently between RV32/RV64 and S/HS mode. Reviewed-by: Bin Meng

[PATCH v7 11/12] hw/riscv: virt: Add PMU DT node to the device tree

2022-03-30 Thread Atish Patra
Qemu virt machine can support few cache events and cycle/instret counters. It also supports counter overflow for these events. Add a DT node so that OpenSBI/Linux kernel is aware of the virt machine capabilities. There are some dummy nodes added for testing as well. Signed-off-by: Atish Patra Si

[PATCH v7 10/12] target/riscv: Add few cache related PMU events

2022-03-30 Thread Atish Patra
From: Atish Patra Qemu can monitor the following cache related PMU events through tlb_fill functions. 1. DTLB load/store miss 3. ITLB prefetch miss Increment the PMU counter in tlb_fill function. Reviewed-by: Alistair Francis Signed-off-by: Atish Patra Signed-off-by: Atish Patra --- target

[PATCH v7 03/12] target/riscv: pmu: Rename the counters extension to pmu

2022-03-30 Thread Atish Patra
From: Atish Patra The PMU counters are supported via cpu config "Counters" which doesn't indicate the correct purpose of those counters. Rename the config property to pmu to indicate that these counters are performance monitoring counters. This aligns with cpu options for ARM architecture as wel

[PATCH v7 07/12] target/riscv: Support mcycle/minstret write operation

2022-03-30 Thread Atish Patra
From: Atish Patra mcycle/minstret are actually WARL registers and can be written with any given value. With SBI PMU extension, it will be used to store a initial value provided from supervisor OS. The Qemu also need prohibit the counter increment if mcountinhibit is set. Support mcycle/minstret

[PATCH v7 04/12] target/riscv: pmu: Make number of counters configurable

2022-03-30 Thread Atish Patra
The RISC-V privilege specification provides flexibility to implement any number of counters from 29 programmable counters. However, the QEMU implements all the counters. Make it configurable through pmu config parameter which now will indicate how many programmable counters should be implemented b

[PATCH v7 05/12] target/riscv: Implement mcountinhibit CSR

2022-03-30 Thread Atish Patra
From: Atish Patra As per the privilege specification v1.11, mcountinhibit allows to start/stop a pmu counter selectively. Reviewed-by: Bin Meng Reviewed-by: Alistair Francis Signed-off-by: Atish Patra Signed-off-by: Atish Patra --- target/riscv/cpu.h | 2 ++ target/riscv/cpu_bits.h |

[PATCH v7 06/12] target/riscv: Add support for hpmcounters/hpmevents

2022-03-30 Thread Atish Patra
From: Atish Patra With SBI PMU extension, user can use any of the available hpmcounters to track any perf events based on the value written to mhpmevent csr. Add read/write functionality for these csrs. Reviewed-by: Alistair Francis Reviewed-by: Bin Meng Signed-off-by: Atish Patra Signed-off-

[PATCH v7 01/12] target/riscv: Fix PMU CSR predicate function

2022-03-30 Thread Atish Patra
From: Atish Patra The predicate function calculates the counter index incorrectly for hpmcounterx. Fix the counter index to reflect correct CSR number. Fixes: e39a8320b088 ("target/riscv: Support the Virtual Instruction fault") Reviewed-by: Alistair Francis Reviewed-by: Bin Meng Signed-off-by

[PATCH v7 02/12] target/riscv: Implement PMU CSR predicate function for S-mode

2022-03-30 Thread Atish Patra
From: Atish Patra Currently, the predicate function for PMU related CSRs only works if virtualization is enabled. It also does not check mcounteren bits before before cycle/minstret/hpmcounterx access. Support supervisor mode access in the predicate function as well. Reviewed-by: Alistair Franc

[PATCH-for-7.1] hw/tpm/tpm_tis: Avoid eventual read overrun

2022-03-30 Thread Philippe Mathieu-Daudé
From: Philippe Mathieu-Daudé The TPMState structure hold an array of TPM_TIS_NUM_LOCALITIES TPMLocality loc[], having TPM_TIS_NUM_LOCALITIES defined as '5'. tpm_tis_locality_from_addr() returns up to 3 bits, so 7. While unlikely, Coverity is right to report an overrun. Assert we are in range to

[PATCH v7 00/12] Improve PMU support

2022-03-30 Thread Atish Patra
The latest version of the SBI specification includes a Performance Monitoring Unit(PMU) extension[1] which allows the supervisor to start/stop/configure various PMU events. The Sscofpmf ('Ss' for Privileged arch and Supervisor-level extensions, and 'cofpmf' for Count OverFlow and Privilege Mode Fil

[PATCH v5 42/45] iotests.py: add VM.qmp_check() helper

2022-03-30 Thread Vladimir Sementsov-Ogievskiy
I'm tired of this pattern being everywhere. Let's add a helper. Signed-off-by: Vladimir Sementsov-Ogievskiy --- tests/qemu-iotests/iotests.py | 4 1 file changed, 4 insertions(+) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index aaa77b5105..329297bfe4 100644

[PATCH v5 45/45] block/copy-before-write: correct permission scheme

2022-03-30 Thread Vladimir Sementsov-Ogievskiy
Finally we can strictly unshare write on source node, as all write must go through copy-before-write filter. For this to work: - Declare independent close, so that blockdev-del transaction action may detach children of removed node at prepare phase (that's for filter removement). We can do

[PATCH v5 41/45] iotests.py: introduce VM.assert_edges_list() method

2022-03-30 Thread Vladimir Sementsov-Ogievskiy
Add an alternative method to check block graph, to be used in further commit. Signed-off-by: Vladimir Sementsov-Ogievskiy --- tests/qemu-iotests/iotests.py | 17 + 1 file changed, 17 insertions(+) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index c

[PATCH v5 44/45] block: bdrv_open_inherit: create BlockBackend only when necessary

2022-03-30 Thread Vladimir Sementsov-Ogievskiy
We need this blk only for probing - let's create it only when we are going to probe. That's significant for further changes: we'll need to avoid permission update during open() when possible (to refresh them later of course). But blk_unref() leads to permission update. Instead of implementing extr

[PATCH v5 39/45] block: bdrv_get_xdbg_block_graph(): report export ids

2022-03-30 Thread Vladimir Sementsov-Ogievskiy
Currently for block exports we report empty blk names. That's not good. Let's try to find corresponding block export and report its id. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block.c | 4 block/export/export.c | 13 + include/block/export.h

[PATCH v5 40/45] iotests.py: qemu_img_create: use imgfmt by default

2022-03-30 Thread Vladimir Sementsov-Ogievskiy
Less typing: let's use imgfmt by default if user doesn't specify neither -f nor --image-opts. Signed-off-by: Vladimir Sementsov-Ogievskiy --- tests/qemu-iotests/iotests.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index fc

[PATCH v5 34/45] block/export: add blk_by_export_id()

2022-03-30 Thread Vladimir Sementsov-Ogievskiy
Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/export/export.c | 18 ++ include/sysemu/block-backend-global-state.h | 1 + 2 files changed, 19 insertions(+) diff --git a/block/export/export.c b/block/export/export.c index 7253af3bc3..66e62f0074 10064

[PATCH v5 43/45] iotests: add filter-insertion

2022-03-30 Thread Vladimir Sementsov-Ogievskiy
Demonstrate new API for filter insertion and removal. Signed-off-by: Vladimir Sementsov-Ogievskiy --- tests/qemu-iotests/tests/filter-insertion | 253 ++ tests/qemu-iotests/tests/filter-insertion.out | 5 + 2 files changed, 258 insertions(+) create mode 100755 tests/qemu-i

[PATCH v5 36/45] block: bdrv_replace_child_bs(): move to external transaction

2022-03-30 Thread Vladimir Sementsov-Ogievskiy
We'll need this functionality as part of external transaction, so make the whole function to be transaction action. For this we need to introduce a transaction action helper: bdrv_drained(), which calls bdrv_drained_begin() and postpone bdrv_drained_end() to .clean() phase. Signed-off-by: Vladimir

[PATCH v5 38/45] qapi: add x-blockdev-replace transaction action

2022-03-30 Thread Vladimir Sementsov-Ogievskiy
Support blockdev-replace in a transaction. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block.c| 4 ++-- blockdev.c | 29 - include/block/block-global-state.h | 2 ++ qapi/transaction.json | 15

[PATCH v5 33/45] block-backend: blk_root(): drop const specifier on return type

2022-03-30 Thread Vladimir Sementsov-Ogievskiy
We'll need get non-const child pointer for graph modifications in further commits. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/block-backend.c | 2 +- include/sysemu/block-backend-global-state.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git

[PATCH v5 35/45] block: make bdrv_find_child() function public

2022-03-30 Thread Vladimir Sementsov-Ogievskiy
To be reused soon. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block.c | 13 + blockdev.c | 14 -- include/block/block_int-io.h | 1 + 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/block.c b/block.c index 17c0

[PATCH v5 32/45] iotests: add blockdev-add-transaction

2022-03-30 Thread Vladimir Sementsov-Ogievskiy
Add a test for transaction support of blockdev-add. Test is format-agnostic, so limit it to qcow2 to avoid extra test runs. Signed-off-by: Vladimir Sementsov-Ogievskiy --- .../tests/blockdev-add-transaction| 52 +++ .../tests/blockdev-add-transaction.out| 6

[PATCH v5 28/45] qapi: block: add blockdev-del transaction action

2022-03-30 Thread Vladimir Sementsov-Ogievskiy
Support blockdev-del in a transaction. The tricky thing is how we update permissions: not after every blockdev-del operation, but after group of such operations. Soon we'll support blockdev-add and new blockdev-replace in the same manner, and we'll be able to do a wide range of block-graph modifyi

[PATCH v5 24/45] blockdev: transactions: rename some things

2022-03-30 Thread Vladimir Sementsov-Ogievskiy
Look at qmp_transaction(): dev_list is not obvious name for list of actions. Let's look at qapi spec, this argument is "actions". Let's follow the common practice of using same argument names in qapi scheme and code. To be honest, rename props to properties for same reason. Next, we have to renam

[PATCH v5 37/45] qapi: add x-blockdev-replace command

2022-03-30 Thread Vladimir Sementsov-Ogievskiy
Add a command that can replace bs in following BdrvChild structures: - qdev blk root child - block-export blk root child - any child BlockDriverState selected by child-name Signed-off-by: Vladimir Sementsov-Ogievskiy --- blockdev.c | 65 ++

[PATCH v5 27/45] blockdev: qmp_transaction: drop extra generic layer

2022-03-30 Thread Vladimir Sementsov-Ogievskiy
Let's simplify things: First, actions generally don't need and access to common BlkActionState structure. The only exclusion are backup actions that need block_job_txn. Next, for transaction actions of Transaction API is more native to allocated state structure in the action itself. So, do the f

[PATCH v5 29/45] block: introduce BDRV_O_NOPERM flag

2022-03-30 Thread Vladimir Sementsov-Ogievskiy
Now copy-before-write filter has weak permission model: when it has no parents, it share write permission on source. Otherwise we just can't blockdev-add it, when existing user of source has write permission. The situation is bad, it means that copy-before-write filter doesn't guarantee that all w

[PATCH v5 17/45] block: drop bdrv_remove_filter_or_cow_child

2022-03-30 Thread Vladimir Sementsov-Ogievskiy
Drop this simple wrapper used only in one place. We have too many graph modifying functions even without it. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block.c | 15 +-- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/block.c b/block.c index 34e89b277f..656e596e0c

[PATCH v5 25/45] blockdev: qmp_transaction: refactor loop to classic for

2022-03-30 Thread Vladimir Sementsov-Ogievskiy
Signed-off-by: Vladimir Sementsov-Ogievskiy --- blockdev.c | 9 +++-- 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/blockdev.c b/blockdev.c index 177f3ff989..b44f0ca101 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2386,7 +2386,7 @@ void qmp_transaction(TransactionActionList *a

[PATCH v5 31/45] qapi: block: add blockdev-add transaction action

2022-03-30 Thread Vladimir Sementsov-Ogievskiy
Use new flag to avoid permission updates where possible during blockdev_add, so that a bunch of add/del (and soon, new 'replace') command may be done before actual permission update to avoid intermediate permission conflicts. Signed-off-by: Vladimir Sementsov-Ogievskiy --- blockdev.c

[PATCH v5 26/45] blockdev: transaction: refactor handling transaction properties

2022-03-30 Thread Vladimir Sementsov-Ogievskiy
Only backup supports GROUPED mode. Make this logic more clear. And avoid passing extra thing to each action. Signed-off-by: Vladimir Sementsov-Ogievskiy --- blockdev.c | 88 -- 1 file changed, 19 insertions(+), 69 deletions(-) diff --git a/blo

[PATCH v5 16/45] block: drop bdrv_detach_child()

2022-03-30 Thread Vladimir Sementsov-Ogievskiy
The only caller is bdrv_root_unref_child(), let's just do the logic directly in it. It simplifies further convertion of bdrv_root_unref_child() to transaction action. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block.c | 45 ++--- 1 file changed, 18 in

[PATCH v5 30/45] block: bdrv_insert_node(): use BDRV_O_NOPERM

2022-03-30 Thread Vladimir Sementsov-Ogievskiy
Further bdrv_replace_node will refresh permissions anyway, so we can avoid intermediate permission conflicts. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block.c b/block.c index ca0b629bec..17c057a962 100644 ---

[PATCH v5 23/45] blockdev: refactor transaction to use Transaction API

2022-03-30 Thread Vladimir Sementsov-Ogievskiy
We are going to add more block-graph modifying transaction actions, and block-graph modifying functions are already based on Transaction API. Next, we'll need to separately update permissions after several graph-modifying actions, and this would be simple with help of Transaction API. So, now let

[PATCH v5 08/45] block/snapshot: stress that we fallback to primary child

2022-03-30 Thread Vladimir Sementsov-Ogievskiy
Actually what we chose is a primary child. Let's stress it in the code. We are going to drop indirect pointer logic here in future. Actually this commit simplifies the future work: we drop use of indirection in the assertion now. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/snapshot.c

[PATCH v5 22/45] block: implemet bdrv_unref_tran()

2022-03-30 Thread Vladimir Sementsov-Ogievskiy
Now nodes are removed during block-graph update transactions now? Look at bdrv_replace_child_tran: bdrv_unref() is simply postponed to commit phase. What is the problem with it? We want to make copy-before-write permissions strict: it should unshare write always, not only when it has at least one

[PATCH v5 20/45] block: make permission update functions public

2022-03-30 Thread Vladimir Sementsov-Ogievskiy
We'll need them in further commits in blockdev.c for new transaction block-graph modifying API. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block.c| 7 +++ include/block/block-global-state.h | 4 2 files changed, 7 insertions(+), 4 deletions(-) diff --gi

[PATCH v5 15/45] block: refactor bdrv_remove_file_or_backing_child to bdrv_remove_child

2022-03-30 Thread Vladimir Sementsov-Ogievskiy
Now the function can remove any child, so give it more common name. Drop assertions and drop bs argument which becomes unused. Function would be reused in a further commit. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block.c | 22 -- 1 file changed, 8 insertions(+), 14 de

[PATCH v5 21/45] block: add bdrv_try_set_aio_context_tran transaction action

2022-03-30 Thread Vladimir Sementsov-Ogievskiy
To be used in further commit. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block.c | 48 1 file changed, 48 insertions(+) diff --git a/block.c b/block.c index be19964f89..1900cdf277 100644 --- a/block.c +++ b/block.c @@ -2907,6 +2907,54 @@ sta

[PATCH v5 07/45] block: document connection between child roles and bs->backing/bs->file

2022-03-30 Thread Vladimir Sementsov-Ogievskiy
Make the informal rules formal. In further commit we'll add corresponding assertions. Signed-off-by: Vladimir Sementsov-Ogievskiy --- include/block/block-common.h | 42 1 file changed, 42 insertions(+) diff --git a/include/block/block-common.h b/include/bloc

[PATCH v5 19/45] block: refactor bdrv_list_refresh_perms to allow any list of nodes

2022-03-30 Thread Vladimir Sementsov-Ogievskiy
We are going to increase usage of collecting nodes in a list to then update, and calling bdrv_topological_dfs() each time is not convenient, and not correct as we are going to interleave graph modifying with filling the node list. So, let's switch to a function that takes any list of nodes, adds a

[PATCH v5 18/45] block: bdrv_refresh_perms(): allow external tran

2022-03-30 Thread Vladimir Sementsov-Ogievskiy
Allow passing external Transaction pointer, stop creating extra Transaction objects. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block.c | 31 --- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/block.c b/block.c index 656e596e0c..f3ed351360 100644

[PATCH v5 14/45] block/snapshot: drop indirection around bdrv_snapshot_fallback_ptr

2022-03-30 Thread Vladimir Sementsov-Ogievskiy
Now the indirection is not actually used, we can safely reduce it to simple pointer. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/snapshot.c | 39 +-- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/block/snapshot.c b/block/snapshot.c

[PATCH v5 06/45] test-bdrv-graph-mod: fix filters to be filters

2022-03-30 Thread Vladimir Sementsov-Ogievskiy
bdrv_pass_through is used as filter, even all node variables has corresponding names. We want to append it, so it should be backing-child-based filter like mirror_top. So, in test_update_perm_tree, first child should be DATA, as we don't want filters with two filtered children. bdrv_exclusive_writ

[PATCH v5 10/45] Revert "block: Let replace_child_tran keep indirect pointer"

2022-03-30 Thread Vladimir Sementsov-Ogievskiy
That's a preparation to previously reverted "block: Let replace_child_noperm free children". Drop it too, we don't need it for a new approach. This reverts commit 82b54cf51656bf3cd5ed1ac549e8a1085a0e3290. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block.c | 81 +++--

[PATCH v5 02/45] block: introduce bdrv_open_file_child() helper

2022-03-30 Thread Vladimir Sementsov-Ogievskiy
Almost all drivers call bdrv_open_child() similarly. Let's create a helper for this. The only not updated driver that call bdrv_open_child() to set bs->file is raw-format, as it sometimes want to have filtered child but don't set drv->is_filter to true. Possibly we should implement drv->is_filter

[PATCH v5 13/45] block: Manipulate bs->file / bs->backing pointers in .attach/.detach

2022-03-30 Thread Vladimir Sementsov-Ogievskiy
bs->file and bs->backing are a kind of duplication of part of bs->children. But very useful diplication, so let's not drop them at all:) We should manage bs->file and bs->backing in same place, where we manage bs->children, to keep them in sync. Moreover, generic io paths are unprepared to BdrvCh

[PATCH v5 05/45] tests-bdrv-drain: bdrv_replace_test driver: declare supports_backing

2022-03-30 Thread Vladimir Sementsov-Ogievskiy
We do add COW child to the node. In future we are going to forbid adding COW child to the node that doesn't support backing. So, fix it here now. Don't worry about setting bs->backing itself: it further commit we'll update the block-layer to automatically set/unset this field in generic code. Si

[PATCH v5 03/45] block/blklogwrites: don't care to remove bs->file child on failure

2022-03-30 Thread Vladimir Sementsov-Ogievskiy
We don't need to remove bs->file, generic layer takes care of it. No other driver cares to remove bs->file on failure by hand. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/blklogwrites.c | 4 1 file changed, 4 deletions(-) diff --git a/block/blklogwrites.c b/block/blklogwrites.c i

[PATCH v5 04/45] test-bdrv-graph-mod: update test_parallel_perm_update test case

2022-03-30 Thread Vladimir Sementsov-Ogievskiy
test_parallel_perm_update() does two things that we are going to restrict in the near future: 1. It updates bs->file field by hand. bs->file will be managed automatically by generic code (together with bs->children list). Let's better refactor our "tricky" bds to have own state where one

[PATCH v5 12/45] Revert "block: Pass BdrvChild ** to replace_child_noperm"

2022-03-30 Thread Vladimir Sementsov-Ogievskiy
That's a preparation to previously reverted "block: Let replace_child_noperm free children". Drop it too, we don't need it for a new approach. This reverts commit be64bbb0149748f3999c49b13976aafb8330ea86. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block.c | 23 +++ 1 fi

  1   2   3   4   5   >