<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-dev/arch/arm64/kvm/vgic, branch master</title>
<subtitle>Linux kernel development work - see feature branches</subtitle>
<id>https://git.zx2c4.com/linux-dev/atom/arch/arm64/kvm/vgic?h=master</id>
<link rel='self' href='https://git.zx2c4.com/linux-dev/atom/arch/arm64/kvm/vgic?h=master'/>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/'/>
<updated>2022-10-15T11:10:54Z</updated>
<entry>
<title>KVM: arm64: vgic: Fix exit condition in scan_its_table()</title>
<updated>2022-10-15T11:10:54Z</updated>
<author>
<name>Eric Ren</name>
<email>renzhengeek@gmail.com</email>
</author>
<published>2022-10-15T03:19:28Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=c000a2607145d28b06c697f968491372ea56c23a'/>
<id>urn:sha1:c000a2607145d28b06c697f968491372ea56c23a</id>
<content type='text'>
With some PCIe topologies, restoring a guest fails while
parsing the ITS device tables.

Reproducer hints:
1. Create ARM virt VM with pxb-pcie bus which adds
   extra host bridges, with qemu command like:

```
  -device pxb-pcie,bus_nr=8,id=pci.x,numa_node=0,bus=pcie.0 \
  -device pcie-root-port,..,bus=pci.x \
  ...
  -device pxb-pcie,bus_nr=37,id=pci.y,numa_node=1,bus=pcie.0 \
  -device pcie-root-port,..,bus=pci.y \
  ...

```
2. Ensure the guest uses 2-level device table
3. Perform VM migration which calls save/restore device tables

In that setup, we get a big "offset" between 2 device_ids,
which makes unsigned "len" round up a big positive number,
causing the scan loop to continue with a bad GPA. For example:

1. L1 table has 2 entries;
2. and we are now scanning at L2 table entry index 2075 (pointed
   to by L1 first entry)
3. if next device id is 9472, we will get a big offset: 7397;
4. with unsigned 'len', 'len -= offset * esz', len will underflow to a
   positive number, mistakenly into next iteration with a bad GPA;
   (It should break out of the current L2 table scanning, and jump
   into the next L1 table entry)
5. that bad GPA fails the guest read.

Fix it by stopping the L2 table scan when the next device id is
outside of the current table, allowing the scan to continue from
the next L1 table entry.

Thanks to Eric Auger for the fix suggestion.

Fixes: 920a7a8fa92a ("KVM: arm64: vgic-its: Add infrastructure for tableookup")
Suggested-by: Eric Auger &lt;eric.auger@redhat.com&gt;
Signed-off-by: Eric Ren &lt;renzhengeek@gmail.com&gt;
[maz: commit message tidy-up]
Signed-off-by: Marc Zyngier &lt;maz@kernel.org&gt;
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/d9c3a564af9e2c5bf63f48a7dcbf08cd593c5c0b.1665802985.git.renzhengeek@gmail.com
</content>
</entry>
<entry>
<title>KVM: arm64: vgic: Remove duplicate check in update_affinity_collection()</title>
<updated>2022-09-26T09:46:37Z</updated>
<author>
<name>Gavin Shan</name>
<email>gshan@redhat.com</email>
</author>
<published>2022-09-23T06:54:47Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=096560dd13251e351176aef54b7aee91c99920a3'/>
<id>urn:sha1:096560dd13251e351176aef54b7aee91c99920a3</id>
<content type='text'>
The 'coll' parameter to update_affinity_collection() is never NULL,
so comparing it with 'ite-&gt;collection' is enough to cover both
the NULL case and the "another collection" case.

Remove the duplicate check in update_affinity_collection().

Signed-off-by: Gavin Shan &lt;gshan@redhat.com&gt;
[maz: repainted commit message]
Signed-off-by: Marc Zyngier &lt;maz@kernel.org&gt;
Link: https://lore.kernel.org/r/20220923065447.323445-1-gshan@redhat.com
</content>
</entry>
<entry>
<title>KVM: arm64: vgic: Tidy-up calls to vgic_{get,set}_common_attr()</title>
<updated>2022-07-17T10:55:33Z</updated>
<author>
<name>Marc Zyngier</name>
<email>maz@kernel.org</email>
</author>
<published>2022-07-14T07:10:09Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=619064afa9b6f0088b86a1fed20c049cfe94cdf7'/>
<id>urn:sha1:619064afa9b6f0088b86a1fed20c049cfe94cdf7</id>
<content type='text'>
The userspace accessors have an early call to vgic_{get,set}_common_attr()
that makes the code hard to follow. Move it to the default: clause of
the decoding switch statement, which results in a nice cleanup.

This requires us to move the handling of the pending table into the
common handling, even if it is strictly a GICv3 feature (it has the
benefit of keeping the whole control group handling in the same
function).

Also cleanup vgic_v3_{get,set}_attr() while we're at it, deduplicating
the calls to vgic_v3_attr_regs_access().

Suggested-by: Reiji Watanabe &lt;reijiw@google.com&gt;
Signed-off-by: Marc Zyngier &lt;maz@kernel.org&gt;
</content>
</entry>
<entry>
<title>KVM: arm64: vgic: Consolidate userspace access for base address setting</title>
<updated>2022-07-17T10:55:33Z</updated>
<author>
<name>Marc Zyngier</name>
<email>maz@kernel.org</email>
</author>
<published>2022-07-05T13:39:24Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=4b85080f4e378f617f88964dec94fd282bcf2af4'/>
<id>urn:sha1:4b85080f4e378f617f88964dec94fd282bcf2af4</id>
<content type='text'>
Align kvm_vgic_addr() with the rest of the code by moving the
userspace accesses into it. kvm_vgic_addr() is also made static.

Signed-off-by: Marc Zyngier &lt;maz@kernel.org&gt;
</content>
</entry>
<entry>
<title>KVM: arm64: vgic-v2: Add helper for legacy dist/cpuif base address setting</title>
<updated>2022-07-17T10:55:33Z</updated>
<author>
<name>Marc Zyngier</name>
<email>maz@kernel.org</email>
</author>
<published>2022-07-05T13:34:33Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=9f968c9266aa30b0e81be0c6a560e45b93bed3dc'/>
<id>urn:sha1:9f968c9266aa30b0e81be0c6a560e45b93bed3dc</id>
<content type='text'>
We carry a legacy interface to set the base addresses for GICv2.
As this is currently plumbed into the same handling code as
the modern interface, it limits the evolution we can make there.

Add a helper dedicated to this handling, with a view of maybe
removing this in the future.

Signed-off-by: Marc Zyngier &lt;maz@kernel.org&gt;
</content>
</entry>
<entry>
<title>KVM: arm64: vgic: Use {get,put}_user() instead of copy_{from.to}_user</title>
<updated>2022-07-17T10:55:33Z</updated>
<author>
<name>Marc Zyngier</name>
<email>maz@kernel.org</email>
</author>
<published>2022-07-05T10:27:37Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=d7df6f282db67677c06456fd29d47eda0ba060b9'/>
<id>urn:sha1:d7df6f282db67677c06456fd29d47eda0ba060b9</id>
<content type='text'>
Tidy-up vgic_get_common_attr() and vgic_set_common_attr() to use
{get,put}_user() instead of the more complex (and less type-safe)
copy_{from,to}_user().

Reviewed-by: Reiji Watanabe &lt;reijiw@google.com&gt;
Signed-off-by: Marc Zyngier &lt;maz@kernel.org&gt;
</content>
</entry>
<entry>
<title>KVM: arm64: vgic-v2: Consolidate userspace access for MMIO registers</title>
<updated>2022-07-17T10:55:33Z</updated>
<author>
<name>Marc Zyngier</name>
<email>maz@kernel.org</email>
</author>
<published>2022-07-05T09:26:07Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=7e9f723c2a90e41407d5889700169be4797a2009'/>
<id>urn:sha1:7e9f723c2a90e41407d5889700169be4797a2009</id>
<content type='text'>
Align the GICv2 MMIO accesses from userspace with the way the GICv3
code is now structured.

Reviewed-by: Reiji Watanabe &lt;reijiw@google.com&gt;
Signed-off-by: Marc Zyngier &lt;maz@kernel.org&gt;
</content>
</entry>
<entry>
<title>KVM: arm64: vgic-v3: Consolidate userspace access for MMIO registers</title>
<updated>2022-07-17T10:55:33Z</updated>
<author>
<name>Marc Zyngier</name>
<email>maz@kernel.org</email>
</author>
<published>2022-07-05T09:26:07Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=e1246f3f2df7aec025fd587ac3d7912007d1144d'/>
<id>urn:sha1:e1246f3f2df7aec025fd587ac3d7912007d1144d</id>
<content type='text'>
For userspace accesses to GICv3 MMIO registers (and related data),
vgic_v3_{get,set}_attr are littered with {get,put}_user() calls,
making it hard to audit and reason about.

Consolidate all userspace accesses in vgic_v3_attr_regs_access(),
making the code far simpler to audit.

Reviewed-by: Reiji Watanabe &lt;reijiw@google.com&gt;
Signed-off-by: Marc Zyngier &lt;maz@kernel.org&gt;
</content>
</entry>
<entry>
<title>KVM: arm64: vgic-v3: Use u32 to manage the line level from userspace</title>
<updated>2022-07-17T10:55:33Z</updated>
<author>
<name>Marc Zyngier</name>
<email>maz@kernel.org</email>
</author>
<published>2022-07-05T09:16:44Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=38cf0bb7625a58625efeef9ec944671464ff7430'/>
<id>urn:sha1:38cf0bb7625a58625efeef9ec944671464ff7430</id>
<content type='text'>
Despite the userspace ABI clearly defining the bits dealt with by
KVM_DEV_ARM_VGIC_GRP_LEVEL_INFO as a __u32, the kernel uses a u64.

Use a u32 to match the userspace ABI, which will subsequently lead
to some simplifications.

Reviewed-by: Reiji Watanabe &lt;reijiw@google.com&gt;
Signed-off-by: Marc Zyngier &lt;maz@kernel.org&gt;
</content>
</entry>
<entry>
<title>KVM: arm64: vgic-v3: Push user access into vgic_v3_cpu_sysregs_uaccess()</title>
<updated>2022-07-17T10:55:33Z</updated>
<author>
<name>Marc Zyngier</name>
<email>maz@kernel.org</email>
</author>
<published>2022-07-04T07:07:44Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/linux-dev/commit/?id=db25081e147c3cc496b8cd8c9d67f992546df6d5'/>
<id>urn:sha1:db25081e147c3cc496b8cd8c9d67f992546df6d5</id>
<content type='text'>
In order to start making the vgic sysreg access from userspace
similar to all the other sysregs, push the userspace memory
access one level down into vgic_v3_cpu_sysregs_uaccess().

The next step will be to rely on the sysreg infrastructure
to perform this task.

Reviewed-by: Reiji Watanabe &lt;reijiw@google.com&gt;
Signed-off-by: Marc Zyngier &lt;maz@kernel.org&gt;
</content>
</entry>
</feed>
