Re: [PATCH 0/4] pci: Compare function number and ARI next function number

2023-07-01 Thread Michael S. Tsirkin
On Sat, Jul 01, 2023 at 04:01:18PM +0900, Akihiko Odaki wrote: > The function number must be lower than the next function number > advertised with ARI. Add a check to enforce this. > > I suggested this change at: >

Re: [PATCH 3/4] igb: Fix ARI next function numbers

2023-07-01 Thread Michael S. Tsirkin
On Sat, Jul 01, 2023 at 04:01:21PM +0900, Akihiko Odaki wrote: > The next function numbers are expected to form a linked list ending with > 0. > > Fixes: 3a977deebe ("Intrdocue igb device emulation") > Signed-off-by: Akihiko Odaki > --- > hw/net/igb_core.h | 3 +++ > hw/net/igb.c | 4 +---

Re: [PATCH 4/4] pci: Compare function number and ARI next function number

2023-07-01 Thread Michael S. Tsirkin
On Sat, Jul 01, 2023 at 04:01:22PM +0900, Akihiko Odaki wrote: > The function number must be lower than the next function number > advertised with ARI. > > Signed-off-by: Akihiko Odaki I don't get this logic at all - where is the limitation coming from? All I see in the spec is: Next

Re: [PATCH 1/4] docs: Fix next function numbers in SR/IOV documentation

2023-07-01 Thread Akihiko Odaki
On 2023/07/01 23:31, Ani Sinha wrote: On 01-Jul-2023, at 12:31 PM, Akihiko Odaki wrote: The next function numbers are expected to form a linked list ending with 0. Fixes: 2503461691 ("pcie: Add some SR/IOV API documentation in docs/pcie_sriov.txt") Signed-off-by: Akihiko Odaki ---

[PATCH v2] hw/ide/piix: properly initialize the BMIBA register

2023-07-01 Thread Olaf Hering
According to the 82371FB documentation (82371FB.pdf, 2.3.9. BMIBA—BUS MASTER INTERFACE BASE ADDRESS REGISTER, April 1997), the register is 32bit wide. To properly reset it to default values, all 32bit need to be cleared. Bit #0 "Resource Type Indicator (RTE)" needs to be enabled. The initial

Re: [PATCH v1] hw/ide/piix: properly initialize the BMIBA register

2023-07-01 Thread Olaf Hering
Sat, 1 Jul 2023 15:34:40 +0200 (CEST) BALATON Zoltan : > If all 32 bits should be writtern does this need pci_set_long instead of > pci_set_word? Thanks for spotting. After a number of experiments I used the wrong variant. Olaf pgpqRNZ3DILTu.pgp Description: Digitale Signatur von OpenPGP

Re: [PATCH 1/4] docs: Fix next function numbers in SR/IOV documentation

2023-07-01 Thread Ani Sinha
> On 01-Jul-2023, at 12:31 PM, Akihiko Odaki wrote: > > The next function numbers are expected to form a linked list ending with > 0. > > Fixes: 2503461691 ("pcie: Add some SR/IOV API documentation in > docs/pcie_sriov.txt") > Signed-off-by: Akihiko Odaki > --- > docs/pcie_sriov.txt | 5

Re: [PATCH v1] hw/ide/piix: properly initialize the BMIBA register

2023-07-01 Thread BALATON Zoltan
On Sat, 1 Jul 2023, Olaf Hering wrote: According to the 82371FB documentation (82371FB.pdf, 2.3.9. BMIBA—BUS MASTER INTERFACE BASE ADDRESS REGISTER, April 1997), the register is 32bit wide. To properly reset it to default values, all 32bit need to be cleared. Bit #1 "Resource Type Indicator

[PATCH v1] hw/ide/piix: properly initialize the BMIBA register

2023-07-01 Thread Olaf Hering
According to the 82371FB documentation (82371FB.pdf, 2.3.9. BMIBA—BUS MASTER INTERFACE BASE ADDRESS REGISTER, April 1997), the register is 32bit wide. To properly reset it to default values, all 32bit need to be cleared. Bit #1 "Resource Type Indicator (RTE)" needs to be enabled. The initial

[PATCH v2 7/7] iotests: Add test for data_off check

2023-07-01 Thread Alexander Ivanov
Write a pattern to the first cluster. Corrupt the data_off field and check if the field was repaired on image opening and the pattern has not changed. Signed-off-by: Alexander Ivanov --- tests/qemu-iotests/tests/parallels-checks | 15 +++

[PATCH v2 6/7] iotests: Fix test 131 after repair was added to parallels_open()

2023-07-01 Thread Alexander Ivanov
Images repairing in parallels_open() was added, thus parallels tests fail. Access to an image leads to repairing the image. Further image check don't detect any corruption. Remove reads after image creation in test 131. Signed-off-by: Alexander Ivanov --- tests/qemu-iotests/131 | 6 ++

[PATCH v2 2/7] iotests: Add leak check test for parallels format

2023-07-01 Thread Alexander Ivanov
Write a pattern to the last cluster, extend the image by 1 claster, repair and check that the last cluster still has the same pattern. Signed-off-by: Alexander Ivanov --- tests/qemu-iotests/tests/parallels-checks | 27 +++ tests/qemu-iotests/tests/parallels-checks.out | 22

[PATCH v2 5/7] iotests: Fix cluster size in parallels images tests (131)

2023-07-01 Thread Alexander Ivanov
In this test cluster size is 64k, but modern tools generate images with cluster size 1M. Calculate cluster size using track field from image header. Signed-off-by: Alexander Ivanov --- tests/qemu-iotests/131 | 5 - tests/qemu-iotests/131.out | 44 +++---

[PATCH v2 0/7] iotests/parallels: Add new tests and fix old

2023-07-01 Thread Alexander Ivanov
This patchset should be applied on top of [PATCH v7 0/8] parallels: Add duplication check, repair at open, fix bugs Add out-of-image, leak and BAT entries duplication checks tests. Old parallels images check test (131): Refactor, fix cluster size and fix after repairing was added to

[PATCH v2 1/7] iotests: Add out-of-image check test for parallels format

2023-07-01 Thread Alexander Ivanov
Fill the image with a pattern to generate entries in the BAT, set the first BAT entry outside the image, try to read the corrupted image. At the image opening it should be repaired, check for zeroes in the first cluster. Signed-off-by: Alexander Ivanov ---

[PATCH v2 3/7] iotests: Add test for BAT entries duplication check

2023-07-01 Thread Alexander Ivanov
Fill a parallels image with a pattern and write another pattern to the second cluster. Corrupt the image and check if the pattern changes. Repair the image and check the patterns on guest and host sides. Signed-off-by: Alexander Ivanov --- tests/qemu-iotests/tests/parallels-checks | 32

[PATCH v2 4/7] iotests: Refactor tests of parallels images checks (131)

2023-07-01 Thread Alexander Ivanov
Replace hardcoded numbers by variables. Signed-off-by: Alexander Ivanov --- tests/qemu-iotests/131 | 29 - 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/tests/qemu-iotests/131 b/tests/qemu-iotests/131 index a847692b4c..601546c84c 100755 ---

[PATCH v7 0/8] parallels: Add duplication check, repair at open, fix bugs

2023-07-01 Thread Alexander Ivanov
Fix incorrect data end calculation in parallels_open(). Check if data_end greater than the file size. Add change_info argument to parallels_check_leak(). Add checking and repairing duplicate offsets in BAT Image repairing in parallels_open(). v7: 3: Renamed "change_info" argument to

[PATCH v7 7/8] parallels: Use bdrv_co_getlength() in parallels_check_outside_image()

2023-07-01 Thread Alexander Ivanov
bdrv_co_getlength() should be used in coroutine context. Replace bdrv_getlength() by bdrv_co_getlength() in parallels_check_outside_image(). Signed-off-by: Alexander Ivanov --- block/parallels.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/parallels.c

[PATCH v7 6/8] parallels: Image repairing in parallels_open()

2023-07-01 Thread Alexander Ivanov
Repair an image at opening if the image is unclean or out-of-image corruption was detected. Signed-off-by: Alexander Ivanov --- block/parallels.c | 70 +-- 1 file changed, 38 insertions(+), 32 deletions(-) diff --git a/block/parallels.c

[PATCH v7 8/8] parallels: Add data_off check

2023-07-01 Thread Alexander Ivanov
data_off field of the parallels image header can be corrupted. Check if this field greater than the header + BAT size and less than file size. Change checking code in parallels_open() accordingly. Signed-off-by: Alexander Ivanov --- block/parallels.c | 98

[PATCH v7 3/8] parallels: Add "explicit" argument to parallels_check_leak()

2023-07-01 Thread Alexander Ivanov
In the on of the next patches we need to repair leaks without changing leaks and leaks_fixed info in res. Also we don't want to print any warning about leaks. Add "explicit" argument to skip info changing if the argument is false. Signed-off-by: Alexander Ivanov --- block/parallels.c | 19

[PATCH v7 2/8] parallels: Check if data_end greater than the file size

2023-07-01 Thread Alexander Ivanov
Initially data_end is set to the data_off image header field and must not be greater than the file size. Signed-off-by: Alexander Ivanov --- block/parallels.c | 5 + 1 file changed, 5 insertions(+) diff --git a/block/parallels.c b/block/parallels.c index 86bc3bfcb8..40a26908db 100644 ---

[PATCH v7 4/8] parallels: Add data_start field to BDRVParallelsState

2023-07-01 Thread Alexander Ivanov
In the next patch we will need the offset of the data area for host cluster index calculation. Add this field and setting up code. Signed-off-by: Alexander Ivanov --- block/parallels.c | 7 --- block/parallels.h | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git

[PATCH v7 1/8] parallels: Incorrect data end calculation in parallels_open()

2023-07-01 Thread Alexander Ivanov
The BDRVParallelsState structure contains data_end field that is measured in sectors. In parallels_open() initially this field is set by data_off field from parallels image header. According to the parallels format documentation, data_off field contains an offset, in sectors, from the start of

[PATCH v7 5/8] parallels: Add checking and repairing duplicate offsets in BAT

2023-07-01 Thread Alexander Ivanov
Cluster offsets must be unique among all the BAT entries. Find duplicate offsets in the BAT and fix it by copying the content of the relevant cluster to a newly allocated cluster and set the new cluster offset to the duplicated entry. Add host_cluster_index() helper to deduplicate the code. When

[PATCH 2/4] hw/nvme: Fix ARI next function numbers

2023-07-01 Thread Akihiko Odaki
The next function numbers are expected to form a linked list ending with 0. Fixes: 44c2c09488 ("hw/nvme: Add support for SR-IOV") Signed-off-by: Akihiko Odaki --- hw/nvme/ctrl.c | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index

[PATCH 1/4] docs: Fix next function numbers in SR/IOV documentation

2023-07-01 Thread Akihiko Odaki
The next function numbers are expected to form a linked list ending with 0. Fixes: 2503461691 ("pcie: Add some SR/IOV API documentation in docs/pcie_sriov.txt") Signed-off-by: Akihiko Odaki --- docs/pcie_sriov.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git

[PATCH 4/4] pci: Compare function number and ARI next function number

2023-07-01 Thread Akihiko Odaki
The function number must be lower than the next function number advertised with ARI. Signed-off-by: Akihiko Odaki --- hw/pci/pci.c | 15 +++ 1 file changed, 15 insertions(+) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index e2eb4c3b4a..568665ee42 100644 --- a/hw/pci/pci.c +++

[PATCH 3/4] igb: Fix ARI next function numbers

2023-07-01 Thread Akihiko Odaki
The next function numbers are expected to form a linked list ending with 0. Fixes: 3a977deebe ("Intrdocue igb device emulation") Signed-off-by: Akihiko Odaki --- hw/net/igb_core.h | 3 +++ hw/net/igb.c | 4 +--- hw/net/igbvf.c| 5 - 3 files changed, 8 insertions(+), 4 deletions(-)

[PATCH 0/4] pci: Compare function number and ARI next function number

2023-07-01 Thread Akihiko Odaki
The function number must be lower than the next function number advertised with ARI. Add a check to enforce this. I suggested this change at: https://lore.kernel.org/qemu-devel/bf351f8b-1c8a-8a7a-7f44-17c9ba18f...@daynix.com/ Implementing this change, I found the devices implementing ARI do not