Re: [PATCH v3] KVM: arm/arm64 : add lpi info in vgic-debug

2018-03-23 Thread Marc Zyngier
On 24/03/18 00:42, Peng Hao wrote: > Add lpi debug info to vgic-stat. > The printed info like this: > SPI 287 0 0100 0 160 -1 > LPI 8192 2 00010000 0 160 -1 > > Signed-off-by: Peng Hao > --- > virt/kvm/arm/vgic/vgic-debug.c | 5

[RFC PATCH v2 15/15] khwasan: update kasan documentation

2018-03-23 Thread Andrey Konovalov
This patch updates KASAN documentation to reflect the addition of KHWASAN. Signed-off-by: Andrey Konovalov --- Documentation/dev-tools/kasan.rst | 212 +- 1 file changed, 122 insertions(+), 90 deletions(-) diff --git a/Documentation/dev-tools/kasan.rst b/Documentati

[RFC PATCH v2 14/15] khwasan, arm64: add brk handler for inline instrumentation

2018-03-23 Thread Andrey Konovalov
KHWASAN inline instrumentation mode (which embeds checks of shadow memory into the generated code, instead of inserting a callback) generates a brk instruction when a tag mismatch is detected. This commit add a KHWASAN brk handler, that decodes the immediate value passed to the brk instructions (t

[RFC PATCH v2 13/15] khwasan: add hooks implementation

2018-03-23 Thread Andrey Konovalov
This commit adds KHWASAN hooks implementation. 1. When a new slab cache is created, KHWASAN rounds up the size of the objects in this cache to KASAN_SHADOW_SCALE_SIZE (== 16). 2. On each kmalloc KHWASAN generates a random tag, sets the shadow memory, that corresponds to this object to this

[RFC PATCH v2 11/15] khwasan, mm: perform untagged pointers comparison in krealloc

2018-03-23 Thread Andrey Konovalov
The krealloc function checks where the same buffer was reused or a new one allocated by comparing kernel pointers. KHWASAN changes memory tag on the krealloc'ed chunk of memory and therefore also changes the pointer tag of the returned pointer. Therefore we need to perform comparison on untagged (w

[RFC PATCH v2 12/15] khwasan: add bug reporting routines

2018-03-23 Thread Andrey Konovalov
This commit adds rountines, that print KHWASAN error reports. Those are quite similar to KASAN, the difference is: 1. The way KHWASAN finds the first bad shadow cell (with a mismatching tag). KHWASAN compares memory tags from the shadow memory to the pointer tag. 2. KHWASAN reports all bugs

[RFC PATCH v2 10/15] khwasan, arm64: enable top byte ignore for the kernel

2018-03-23 Thread Andrey Konovalov
KHWASAN uses the Top Byte Ignore feature of arm64 CPUs to store a pointer tag in the top byte of each pointer. This commit enables the TCR_TBI1 bit, which enables Top Byte Ignore for the kernel, when KHWASAN is used. Signed-off-by: Andrey Konovalov --- arch/arm64/include/asm/pgtable-hwdef.h | 1

[RFC PATCH v2 09/15] khwasan, kvm: untag pointers in kern_hyp_va

2018-03-23 Thread Andrey Konovalov
kern_hyp_va that converts kernel VA into a HYP VA relies on the top byte of kernel pointers being 0xff. Untag pointers passed to it with KHWASAN enabled. Also fix create_hyp_mappings() and create_hyp_io_mappings(), to use the untagged kernel pointers for address computations. Signed-off-by: Andre

[RFC PATCH v2 08/15] khwasan: add tag related helper functions

2018-03-23 Thread Andrey Konovalov
This commit adds a few helper functions, that are meant to be used to work with tags embedded in the top byte of kernel pointers: to set, to get or to reset (set to 0xff) the top byte. Signed-off-by: Andrey Konovalov --- arch/arm64/mm/kasan_init.c | 2 ++ include/linux/kasan.h | 23 +++

[RFC PATCH v2 05/15] khwasan: initialize shadow to 0xff

2018-03-23 Thread Andrey Konovalov
A KHWASAN shadow memory cell contains a memory tag, that corresponds to the tag in the top byte of the pointer, that points to that memory. The native top byte value of kernel pointers is 0xff, so with KHWASAN we need to initialize shadow memory to 0xff. This commit does that. Signed-off-by: Andre

[RFC PATCH v2 06/15] khwasan, arm64: untag virt address in __kimg_to_phys

2018-03-23 Thread Andrey Konovalov
__kimg_to_phys (which is used by virt_to_phys) assumes that the top byte of the address is 0xff, which isn't always the case with KHWASAN enabled. The solution is to reset the tag in __kimg_to_phys. __lm_to_phys doesn't require any fixups, as it zeroes out the top byte with the current implementat

[RFC PATCH v2 07/15] khwasan, arm64: fix up fault handling logic

2018-03-23 Thread Andrey Konovalov
show_pte in arm64 fault handling relies on the fact that the top byte of a kernel pointer is 0xff, which isn't always the case with KHWASAN enabled. Reset the top byte. Signed-off-by: Andrey Konovalov --- arch/arm64/mm/fault.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/arm64/mm/

[RFC PATCH v2 03/15] khwasan: add CONFIG_KASAN_CLASSIC and CONFIG_KASAN_TAGS

2018-03-23 Thread Andrey Konovalov
This commit splits the current CONFIG_KASAN config option into two: 1. CONFIG_KASAN_CLASSIC, that enables the classic KASAN version (the one that exists now); 2. CONFIG_KASAN_TAGS, that enables KHWASAN. With CONFIG_KASAN_TAGS enabled, compiler options are changed to instrument kernel files wiht

[RFC PATCH v2 04/15] khwasan, arm64: adjust shadow size for CONFIG_KASAN_TAGS

2018-03-23 Thread Andrey Konovalov
KWHASAN uses 1 shadow byte for 16 bytes of kernel memory, so it requires 1/16th of the kernel virtual address space for the shadow memory. This commit sets KASAN_SHADOW_SCALE_SHIFT to 4 when KHWASAN is enabled. Signed-off-by: Andrey Konovalov --- arch/arm64/Makefile | 2 +- arch/ar

[RFC PATCH v2 00/15] khwasan: kernel hardware assisted address sanitizer

2018-03-23 Thread Andrey Konovalov
Hi! This is the 2nd RFC version of the patchset. This patchset adds a new mode to KASAN [1], which is called KHWASAN (Kernel HardWare assisted Address SANitizer). There's still some work to do and there are a few TODOs in the code, so I'm publishing this as an RFC to collect some initial feedback.

[RFC PATCH v2 01/15] khwasan, mm: change kasan hooks signatures

2018-03-23 Thread Andrey Konovalov
KHWASAN will change the value of the top byte of pointers returned from the kernel allocation functions (such as kmalloc). This patch updates KASAN hooks signatures and their usage in SLAB and SLUB code to reflect that. Signed-off-by: Andrey Konovalov --- include/linux/kasan.h | 34 +

[RFC PATCH v2 02/15] khwasan: move common kasan and khwasan code to common.c

2018-03-23 Thread Andrey Konovalov
KHWASAN will reuse a significant part of KASAN code, so move the common parts to common.c without any functional changes. Signed-off-by: Andrey Konovalov --- mm/kasan/Makefile | 5 +- mm/kasan/common.c | 318 ++ mm/kasan/kasan.c | 288 +-

[PATCH v3] KVM: arm/arm64 : add lpi info in vgic-debug

2018-03-23 Thread Peng Hao
Add lpi debug info to vgic-stat. The printed info like this: SPI 287 0 0100 0 160 -1 LPI 8192 2 00010000 0 160 -1 Signed-off-by: Peng Hao --- virt/kvm/arm/vgic/vgic-debug.c | 59 ++ virt/

Re: [PATCH] KVM: arm/arm64: vgic-its: Fix potential overrun in vgic_copy_lpi_list

2018-03-23 Thread Andre Przywara
Hi, On 23/03/18 15:21, Marc Zyngier wrote: > vgic_copy_lpi_list() parses the LPI list and picks LPIs targetting targeting > a given vcpu. We allocate the array containing the intids before taking > the lpi_list_lock, which means we can ha

Re: [PATCH v2] KVM: arm/arm64 : add lpi info in vgic-debug

2018-03-23 Thread Marc Zyngier
On 23/03/18 23:01, Peng Hao wrote: > Add lpi debug info to vgic-stat. > the printed info like this: > SPI 287 0 0100 0 160 -1 > LPI 8192 2 00010000 0 160 -1 > > Signed-off-by: Peng Hao > --- > virt/kvm/arm/vgic/vgic-debug.c | 5

[PATCH] KVM: arm/arm64: vgic-its: Fix potential overrun in vgic_copy_lpi_list

2018-03-23 Thread Marc Zyngier
vgic_copy_lpi_list() parses the LPI list and picks LPIs targetting a given vcpu. We allocate the array containing the intids before taking the lpi_list_lock, which means we can have an array size that is not equal to the number of LPIs. This is particularily obvious when looking at the path coming

Re: [PATCH 2/4] iommu/virtio: Add probe request

2018-03-23 Thread Robin Murphy
On 14/02/18 14:53, Jean-Philippe Brucker wrote: When the device offers the probe feature, send a probe request for each device managed by the IOMMU. Extract RESV_MEM information. When we encounter a MSI doorbell region, set it up as a IOMMU_RESV_MSI region. This will tell other subsystems that th

Re: [PATCH 1/4] iommu: Add virtio-iommu driver

2018-03-23 Thread Robin Murphy
On 14/02/18 14:53, Jean-Philippe Brucker wrote: The virtio IOMMU is a para-virtualized device, allowing to send IOMMU requests such as map/unmap over virtio-mmio transport without emulating page tables. This implementation handles ATTACH, DETACH, MAP and UNMAP requests. The bulk of the code tran

Re: [PATCH] KVM: arm/arm64 : add lpi info in vgic-debug

2018-03-23 Thread Marc Zyngier
[fixing Christoffer's email address] On 23/03/18 13:33, peng.h...@zte.com.cn wrote: >> On 23/03/18 10:36, Peng Hao wrote: >>> Add lpi debug info to vgic-stat. >>> the printed info like this: >>> SPI 287 0 0100 0 160 -1 >>> LPI 8192 2 0001000

[PATCH v2] KVM: arm/arm64 : add lpi info in vgic-debug

2018-03-23 Thread Peng Hao
Add lpi debug info to vgic-stat. the printed info like this: SPI 287 0 0100 0 160 -1 LPI 8192 2 00010000 0 160 -1 Signed-off-by: Peng Hao --- virt/kvm/arm/vgic/vgic-debug.c | 56 ++ 1 fil

Re:Re: [PATCH] KVM: arm/arm64 : add lpi info in vgic-debug

2018-03-23 Thread peng.hao2
>On 23/03/18 10:36, Peng Hao wrote: >> Add lpi debug info to vgic-stat. >> the printed info like this: >> SPI 287 0 0100 0 160 -1 >> LPI 8192 2 00010000 0 160 -1 >> >> Signed-off-by: Peng Hao >> --- >> virt/kvm/arm/vgic/vgic-

Re: [RFC 02/12] KVM: arm/arm64: Document KVM_VGIC_V3_ADDR_TYPE_REDIST_REGION

2018-03-23 Thread Peter Maydell
On 19 March 2018 at 09:20, Eric Auger wrote: > We introduce a new KVM_VGIC_V3_ADDR_TYPE_REDIST_REGION attribute in > KVM_DEV_ARM_VGIC_GRP_ADDR group. It allows userspace to provide the > base address and size of a redistributor region > > Compared to KVM_VGIC_V3_ADDR_TYPE_REDIST, this new attribut

Re: [PATCH] KVM: arm/arm64 : add lpi info in vgic-debug

2018-03-23 Thread Marc Zyngier
On 23/03/18 10:36, Peng Hao wrote: > Add lpi debug info to vgic-stat. > the printed info like this: > SPI 287 0 0100 0 160 -1 > LPI 8192 2 00010000 0 160 -1 > > Signed-off-by: Peng Hao > --- > virt/kvm/arm/vgic/vgic-debug.c |

RE: [PATCH 1/4] iommu: Add virtio-iommu driver

2018-03-23 Thread Tian, Kevin
> From: Tian, Kevin > Sent: Thursday, March 22, 2018 6:06 PM > > > From: Robin Murphy [mailto:robin.mur...@arm.com] > > Sent: Wednesday, March 21, 2018 10:24 PM > > > > On 21/03/18 13:14, Jean-Philippe Brucker wrote: > > > On 21/03/18 06:43, Tian, Kevin wrote: > > > [...] > > >>> + > > >>> +#inclu

[PATCH] KVM: arm/arm64 : add lpi info in vgic-debug

2018-03-23 Thread Peng Hao
Add lpi debug info to vgic-stat. the printed info like this: SPI 287 0 0100 0 160 -1 LPI 8192 2 00010000 0 160 -1 Signed-off-by: Peng Hao --- virt/kvm/arm/vgic/vgic-debug.c | 61 ++ 1 f