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

2018-03-27 Thread Andrey Konovalov
On Sat, Mar 24, 2018 at 9:29 AM, Ingo Molnar wrote: > > * Andrey Konovalov wrote: > >> 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

[PATCH v2 03/17] arm64: Make page table helpers reusable

2018-03-27 Thread Suzuki K Poulose
This patch rearranges the page table level helpers so that it can be reused for a page table with different number of levels (e.g, stage2 page table for a VM) than the kernel page tables. As such there is no functional change with this patch. The page table helpers are defined to do the right

[PATCH v2 04/17] arm64: Refactor pud_huge for reusability

2018-03-27 Thread Suzuki K Poulose
Make pud_huge reusable for stage2 tables, independent of the stage1 levels. Cc: Steve Capper Cc: Mark Rutland Cc: Will Deacon Cc: Catalin Marinas Cc: Christoffer Dall Signed-off-by:

[PATCH v2 10/17] kvm: arm64: Dynamic configuration of VTCR and VTTBR mask

2018-03-27 Thread Suzuki K Poulose
VTCR_EL2 holds the following key stage2 translation table parameters: SL0 - Entry level in the page table lookup. T0SZ - Denotes the size of the memory addressed by the table. We have been using fixed values for the SL0 depending on the page size as we have a fixed IPA size. But since we are

[PATCH v2 11/17] kvm: arm64: Configure VTCR per VM

2018-03-27 Thread Suzuki K Poulose
We set VTCR_EL2 very early during the stage2 init and don't touch it ever. This is fine as we had a fixed IPA size. This patch changes the behavior to set the VTCR for a given VM, depending on its stage2 table. The common configuration for VTCR is still performed during the early init as we have

[kvmtool PATCH 20/17] kvmtool: arm64: Switch memory layout

2018-03-27 Thread Suzuki K Poulose
If the guest wants to use a larger physical address space place the RAM at upper half of the address space. Otherwise, it uses the default layout. Signed-off-by: Suzuki K Poulose --- arm/aarch32/include/kvm/kvm-arch.h | 1 + arm/aarch64/include/kvm/kvm-arch.h | 15

[kvmtool PATCH 19/17] kvmtool: arm64: Add support for guest physical address size

2018-03-27 Thread Suzuki K Poulose
Add an option to specify the physical address size used by this VM. Signed-off-by: Suzuki K Poulose --- arm/aarch64/include/kvm/kvm-config-arch.h | 5 - arm/include/arm-common/kvm-config-arch.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git

[PATCH v2 00/17] kvm: arm64: Dynamic & 52bit IPA support

2018-03-27 Thread Suzuki K Poulose
The physical address space size for a VM (IPA size) on arm/arm64 is limited to a static limit of 40bits. This series adds support for using a limit specific to a VM, allowing to use a limit supported by the host (based on the host kernel configuration and CPU support). The default and the minimum

[PATCH v2 01/17] virtio: mmio-v1: Validate queue PFN

2018-03-27 Thread Suzuki K Poulose
virtio-mmio with virtio-v1 uses a 32bit PFN for the queue. If the queue pfn is too large to fit in 32bits, which we could hit on arm64 systems with 52bit physical addresses (even with 64K page size), we simply miss out a proper link to the other side of the queue. Add a check to validate the PFN,

[PATCH v2 02/17] virtio: pci-legacy: Validate queue pfn

2018-03-27 Thread Suzuki K Poulose
Legacy PCI over virtio uses a 32bit PFN for the queue. If the queue pfn is too large to fit in 32bits, which we could hit on arm64 systems with 52bit physical addresses (even with 64K page size), we simply miss out a proper link to the other side of the queue. Add a check to validate the PFN,

[kvmtool PATCH 18/17] kvmtool: Allow backends to run checks on the KVM device fd

2018-03-27 Thread Suzuki K Poulose
Allow architectures to perform initialisation based on the KVM device fd ioctls, even before the VM is created. Signed-off-by: Suzuki K Poulose --- include/kvm/kvm.h | 4 kvm.c | 2 ++ 2 files changed, 6 insertions(+) diff --git a/include/kvm/kvm.h

[PATCH v2 15/17] vgic: Add support for 52bit guest physical address

2018-03-27 Thread Suzuki K Poulose
From: Kristina Martsenko Add support for handling 52bit guest physical address to the VGIC layer. So far we have limited the guest physical address to 48bits, by explicitly masking the upper bits. This patch removes the restriction. We do not have to check if the host

[PATCH v2 16/17] kvm: arm64: Add support for handling 52bit IPA

2018-03-27 Thread Suzuki K Poulose
Add support for handling the 52bit IPA. 52bit IPA support needs changes to the following : 1) Page-table entries - We use kernel page table helpers for setting up the stage2. Hence we don't explicit changes here 2) VTTBR:BADDR - This is already supported with : commit 529c4b05a3cb2f324aa

[PATCH v2 17/17] kvm: arm64: Allow IPA size supported by the system

2018-03-27 Thread Suzuki K Poulose
So far we have restricted the IPA size of the VM to the default value (40bits). Now that we can manage the IPA size per VM and support dynamic stage2 page tables, allow VMs to bigger IPA. This is done by setting the IPA limit to the one supported by the hardware and kernel. This patch also moves

[PATCH v2 13/17] kvm: arm/arm64: Allow tuning the physical address size for VM

2018-03-27 Thread Suzuki K Poulose
Allow specifying the physical address size for a new VM via the kvm_type argument for KVM_CREATE_VM ioctl. This allows us to finalise the stage2 page table format as early as possible and hence perform the right checks on the memory slots without complication. The size is encoded as Log2(PA_Siz)

[PATCH v2 14/17] kvm: arm64: Switch to per VM IPA limit

2018-03-27 Thread Suzuki K Poulose
Now that we can manage the stage2 page table per VM, switch the configuration details to per VM instance. We keep track of the IPA bits, number of page table levels and the VTCR bits (which depends on the IPA and the number of levels). While at it, remove unused pgd_lock field from kvm_arch for

[PATCH v2 08/17] kvm: arm/arm64: Prepare for VM specific stage2 translations

2018-03-27 Thread Suzuki K Poulose
Right now the stage2 page table for a VM is hard coded, assuming an IPA of 40bits. As we are about to add support for per VM IPA, prepare the stage2 page table helpers to accept the kvm instance to make the right decision for the VM. No functional changes. Cc: Marc Zyngier

[PATCH v2 06/17] kvm: arm/arm64: Fix stage2_flush_memslot for 4 level page table

2018-03-27 Thread Suzuki K Poulose
So far we have only supported 3 level page table with fixed IPA of 40bits. Fix stage2_flush_memslot() to accommodate for 4 level tables. Cc: Marc Zyngier Acked-by: Christoffer Dall Signed-off-by: Suzuki K Poulose ---

[PATCH v2 07/17] kvm: arm/arm64: Remove spurious WARN_ON

2018-03-27 Thread Suzuki K Poulose
On a 4-level page table pgd entry can be empty, unlike a 3-level page table. Remove the spurious WARN_ON() in stage_get_pud(). Cc: Marc Zyngier Acked-by: Christoffer Dall Signed-off-by: Suzuki K Poulose --- virt/kvm/arm/mmu.c | 2

[kvmtool PATCH 21/17] kvmtool: arm: Add support for creating VM with PA size

2018-03-27 Thread Suzuki K Poulose
Specify the physical size for the VM encoded in the vm type. Signed-off-by: Suzuki K Poulose --- arm/include/arm-common/kvm-arch.h | 6 +- arm/kvm.c | 21 + 2 files changed, 26 insertions(+), 1 deletion(-) diff --git

[RFC v2 12/12] KVM: arm/arm64: Bump VGIC_V3_MAX_CPUS to 512

2018-03-27 Thread Eric Auger
Let's raise the number of supported vcpus along with vgic v3 now that HW is looming with more physical CPUs. Signed-off-by: Eric Auger --- include/kvm/arm_vgic.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/kvm/arm_vgic.h

Re: [PATCH v2 01/17] virtio: mmio-v1: Validate queue PFN

2018-03-27 Thread Michael S. Tsirkin
On Tue, Mar 27, 2018 at 02:15:11PM +0100, Suzuki K Poulose wrote: > virtio-mmio with virtio-v1 uses a 32bit PFN for the queue. > If the queue pfn is too large to fit in 32bits, which > we could hit on arm64 systems with 52bit physical addresses > (even with 64K page size), we simply miss out a

[RFC v2 09/12] KVM: arm/arm64: Check all vcpu redistributors are set on map_resources

2018-03-27 Thread Eric Auger
On vcpu first run, we eventually know the actual number of vcpus. This is a synchronization point to check all redistributors regions were assigned. On kvm_vgic_map_resources() we check both dist and redist were set, eventually check potential base address inconsistencies. Signed-off-by: Eric

[RFC v2 06/12] KVM: arm/arm64: Helper to register a new redistributor region

2018-03-27 Thread Eric Auger
We introduce a new helper that creates and inserts a new redistributor region into the rdist region list. This helper both handles the case where the redistributor region size is known at registration time and the legacy case where it is not (eventually depending on the number of online vcpus).

[RFC v2 10/12] KVM: arm/arm64: Add KVM_VGIC_V3_ADDR_TYPE_REDIST_REGION

2018-03-27 Thread Eric Auger
This new attribute allows the userspace to set the base address of a reditributor region, relaxing the constraint of having all consecutive redistibutor frames contiguous. Signed-off-by: Eric Auger --- arch/arm/include/uapi/asm/kvm.h | 7 ---

[RFC v2 01/12] KVM: arm/arm64: Set dist->spis to NULL after kfree

2018-03-27 Thread Eric Auger
in case kvm_vgic_map_resources() fails, typically if the vgic distributor is not defined, __kvm_vgic_destroy will be called several times. Indeed kvm_vgic_map_resources() is called on first vcpu run. As a result dist->spis is freeed more than once and on the second time it causes a "kernel BUG at

[RFC v2 00/12] KVM: arm/arm64: Allow multiple GICv3 redistributor regions

2018-03-27 Thread Eric Auger
At the moment the KVM VGICv3 only supports a single redistributor region (whose base address is set through the GICv3 kvm device KVM_DEV_ARM_VGIC_GRP_ADDR/KVM_VGIC_V3_ADDR_TYPE_REDIST). There, all the redistributors are laid out contiguously. The size of this single redistributor region is not set

[RFC v2 05/12] KVM: arm/arm64: Revisit Redistributor TYPER last bit computation

2018-03-27 Thread Eric Auger
The TYPER of an redistributor reflects whether the rdist is the last one of the redistributor region. Let's compare the TYPER GPA against the address of the last occupied slot within the redistributor region. Signed-off-by: Eric Auger --- virt/kvm/arm/vgic/vgic-mmio-v3.c

[RFC v2 04/12] KVM: arm/arm64: Helper to locate free rdist index

2018-03-27 Thread Eric Auger
We introduce vgic_v3_rdist_free_slot to help identifying where we can place a new 2x64KB redistributor. Signed-off-by: Eric Auger --- virt/kvm/arm/vgic/vgic-mmio-v3.c | 3 +-- virt/kvm/arm/vgic/vgic-v3.c | 17 + virt/kvm/arm/vgic/vgic.h | 11

[RFC v2 08/12] KVM: arm/arm64: Check vcpu redist base before registering an iodev

2018-03-27 Thread Eric Auger
As we are going to register several redist regions, vgic_register_all_redist_iodevs() may be called several times. We need to register a redist_iodev for a given vcpu only once. So let's check if the base address has already been set. Initialize this latter in kvm_vgic_vcpu_early_init().

[RFC v2 07/12] KVM: arm/arm64: Adapt vgic_v3_check_base to multiple rdist regions

2018-03-27 Thread Eric Auger
We introduce a new helper to check there is no overlap between dist region (if set) and registered rdist regions. This both handles the case of legacy single rdist region (implicitly sized with the number of online vcpus) and the new case of multiple explicitly sized rdist regions. Signed-off-by:

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

2018-03-27 Thread Eric Auger
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 attribute allows to declare several separate redistributor

[RFC v2 03/12] KVM: arm/arm64: Replace the single rdist region by a list

2018-03-27 Thread Eric Auger
At the moment KVM supports a single rdist region. We want to support several separate rdist regions so let's introduce a list of them. This patch currently only cares about a single entry in this list as the functionality to register several redist regions is not yet there. So this only translates

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

2018-03-27 Thread Andrey Konovalov
On Sat, Mar 24, 2018 at 9:43 AM, Ingo Molnar wrote: > > * Andrey Konovalov wrote: > >> 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);

Re: [RFC v2 01/12] KVM: arm/arm64: Set dist->spis to NULL after kfree

2018-03-27 Thread Marc Zyngier
On 27/03/18 15:04, Eric Auger wrote: > in case kvm_vgic_map_resources() fails, typically if the vgic > distributor is not defined, __kvm_vgic_destroy will be called > several times. Indeed kvm_vgic_map_resources() is called on > first vcpu run. As a result dist->spis is freeed more than once > and

Re: [PATCH 02/11] ACPI / APEI: Generalise the estatus queue's add/remove and notify code

2018-03-27 Thread Borislav Petkov
Hi James, On Mon, Mar 19, 2018 at 02:29:13PM +, James Morse wrote: > I don't think the die_lock really helps here, do we really want to wait for a > remote CPU to finish printing an OOPs about user-space's bad memory accesses, > before we bring the machine down due to this system-wide fatal

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

2018-03-27 Thread Ingo Molnar
* Andrey Konovalov wrote: > On Sat, Mar 24, 2018 at 9:43 AM, Ingo Molnar wrote: > > > > * Andrey Konovalov wrote: > > > >> This commit splits the current CONFIG_KASAN config option into two: > >> 1. CONFIG_KASAN_CLASSIC, that

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

2018-03-27 Thread Ingo Molnar
* Andrey Konovalov wrote: > On Sat, Mar 24, 2018 at 9:29 AM, Ingo Molnar wrote: > > > > * Andrey Konovalov wrote: > > > >> The krealloc function checks where the same buffer was reused or a new one > >> allocated by comparing