Re: [PATCH v3 2/4] arm64: KVM: add accessors to track guest/host only counters

2018-12-03 Thread Andrew Murray
On Mon, Dec 03, 2018 at 04:58:43PM +, Will Deacon wrote: > On Mon, Dec 03, 2018 at 03:05:52PM +, Andrew Murray wrote: > > On Mon, Dec 03, 2018 at 02:31:14PM +, Will Deacon wrote: > > > On Thu, Nov 22, 2018 at 11:25:48AM +, Andrew Murray wrote: > > > > In order to effeciently

Re: [PATCH v3 3/4] arm64: arm_pmu: Add support for exclude_host/exclude_guest attributes

2018-12-03 Thread Andrew Murray
On Mon, Dec 03, 2018 at 03:04:14PM +, Will Deacon wrote: > Hi Andrew, > > On Thu, Nov 22, 2018 at 11:25:49AM +, Andrew Murray wrote: > > Add support for the :G and :H attributes in perf by handling the > > exclude_host/exclude_guest event attributes. > > > > We notify KVM of counters

Re: [PATCH v2 0/8] Workaround for Cortex-A76 erratum 1165522

2018-12-03 Thread Will Deacon
Hi Marc, On Fri, Nov 23, 2018 at 06:40:59PM +, Marc Zyngier wrote: > Early Cortex-A76 suffer from an erratum that can result in invalid > TLBs when the CPU speculatively executes an AT instruction in the > middle of a guest world switch, while the guest virtual memory > configuration is in an

[PATCH v7 25/25] ACPI / APEI: Add support for the SDEI GHES Notification type

2018-12-03 Thread James Morse
If the GHES notification type is SDEI, register the provided event using the SDEI-GHES helper. SDEI may be one of two types of event, normal and critical. Critical events can interrupt normal events, so these must have separate fixmap slots and locks in case both event types are in use.

[PATCH v7 23/25] arm64: acpi: Make apei_claim_sea() synchronise with APEI's irq work

2018-12-03 Thread James Morse
APEI is unable to do all of its error handling work in nmi-context, so it defers non-fatal work onto the irq_work queue. arch_irq_work_raise() sends an IPI to the calling cpu, but this is not guaranteed to be taken before returning to user-space. Unless the exception interrupted a context with

[PATCH v7 24/25] firmware: arm_sdei: Add ACPI GHES registration helper

2018-12-03 Thread James Morse
APEI's Generic Hardware Error Source structures do not describe whether the SDEI event is shared or private, as this information is discoverable via the API. GHES needs to know whether an event is normal or critical to avoid sharing locks or fixmap entries, but GHES shouldn't have to know about

[PATCH v7 20/25] ACPI / APEI: Use separate fixmap pages for arm64 NMI-like notifications

2018-12-03 Thread James Morse
Now that ghes notification helpers provide the fixmap slots and take the lock themselves, multiple NMI-like notifications can be used on arm64. These should be named after their notification method as they can't all be called 'NMI'. x86's NOTIFY_NMI already is, change the SEA fixmap entry to be

[PATCH v7 14/25] arm64: KVM/mm: Move SEA handling behind a single 'claim' interface

2018-12-03 Thread James Morse
To split up APEIs in_nmi() path, the caller needs to always be in_nmi(). Add a helper to do the work and claim the notification. When KVM or the arch code takes an exception that might be a RAS notification, it asks the APEI firmware-first code whether it wants to claim the exception. A future

[PATCH v7 22/25] ACPI / APEI: Kick the memory_failure() queue for synchronous errors

2018-12-03 Thread James Morse
memory_failure() offlines or repairs pages of memory that have been discovered to be corrupt. These may be detected by an external component, (e.g. the memory controller), and notified via an IRQ. In this case the work is queued as not all of memory_failure()s work can happen in IRQ context. If

[PATCH v7 21/25] mm/memory-failure: Add memory_failure_queue_kick()

2018-12-03 Thread James Morse
The GHES code calls memory_failure_queue() from IRQ context to schedule work on the current CPU so that memory_failure() can sleep. For synchronous memory errors the arch code needs to know any signals that memory_failure() will trigger are pending before it returns to user-space, possibly when

[PATCH v7 11/25] ACPI / APEI: Move NOTIFY_SEA between the estatus-queue and NOTIFY_NMI

2018-12-03 Thread James Morse
The estatus-queue code is currently hidden by the NOTIFY_NMI #ifdefs. Once NOTIFY_SEA starts using the estatus-queue we can stop hiding it as each architecture has a user that can't be turned off. Split the existing CONFIG_HAVE_ACPI_APEI_NMI block in two, and move the SEA code into the gap. This

[PATCH v7 13/25] KVM: arm/arm64: Add kvm_ras.h to collect kvm specific RAS plumbing

2018-12-03 Thread James Morse
To split up APEIs in_nmi() path, the caller needs to always be in_nmi(). KVM shouldn't have to know about this, pull the RAS plumbing out into a header file. Currently guest synchronous external aborts are claimed as RAS notifications by handle_guest_sea(), which is hidden in the arch codes

[PATCH v7 15/25] ACPI / APEI: Move locking to the notification helper

2018-12-03 Thread James Morse
ghes_copy_tofrom_phys() takes different locks depending on in_nmi(). This doesn't work if there are multiple NMI-like notifications, that can interrupt each other. Now that NOTIFY_SEA is always called in the same context, move the lock-taking to the notification helper. The helper will always

[PATCH v7 19/25] ACPI / APEI: Only use queued estatus entry during _in_nmi_notify_one()

2018-12-03 Thread James Morse
Each struct ghes has an worst-case sized buffer for storing the estatus. If an error is being processed by ghes_proc() in process context this buffer will be in use. If the error source then triggers an NMI-like notification, the same buffer will be used by _in_nmi_notify_one() to stage the

[PATCH v7 12/25] ACPI / APEI: Switch NOTIFY_SEA to use the estatus queue

2018-12-03 Thread James Morse
Now that the estatus queue can be used by more than one notification method, we can move notifications that have NMI-like behaviour over. Switch NOTIFY_SEA over to use the estatus queue. This makes it behave in the same way as x86's NOTIFY_NMI. Remove Kconfig's ability to turn ACPI_APEI_SEA off

[PATCH v7 18/25] ACPI / APEI: Split ghes_read_estatus() to allow a peek at the CPER length

2018-12-03 Thread James Morse
ghes_read_estatus() reads the record address, then the record's header, then performs some sanity checks before reading the records into the provided estatus buffer. To provide this estatus buffer the caller must know the size of the records in advance, or always provide a worst-case sized buffer

[PATCH v7 17/25] ACPI / APEI: Pass ghes and estatus separately to avoid a later copy

2018-12-03 Thread James Morse
The NMI-like notifications scribble over ghes->estatus, before copying it somewhere else. If this interrupts the ghes_probe() code calling ghes_proc() on each struct ghes, the data is corrupted. All the NMI-like notifications should use a queued estatus entry from the beginning, instead of the

[PATCH v7 10/25] ACPI / APEI: Tell firmware the estatus queue consumed the records

2018-12-03 Thread James Morse
ACPI has a GHESv2 which is used on hardware reduced platforms to explicitly acknowledge that the memory for CPER records has been consumed. This lets an external agent know it can re-use this memory for something else. Previously notify_nmi and the estatus queue didn't do this as they were never

[PATCH v7 16/25] ACPI / APEI: Let the notification helper specify the fixmap slot

2018-12-03 Thread James Morse
ghes_copy_tofrom_phys() uses a different fixmap slot depending on in_nmi(). This doesn't work when there are multiple NMI-like notifications, that could interrupt each other. As with the locking, move the chosen fixmap_idx to the notification helper. This only matters for NMI-like notifications,

[PATCH v7 07/25] ACPI / APEI: Remove spurious GHES_TO_CLEAR check

2018-12-03 Thread James Morse
ghes_notify_nmi() checks ghes->flags for GHES_TO_CLEAR before going on to __process_error(). This is pointless as ghes_read_estatus() will always set this flag if it returns success, which was checked earlier in the loop. Remove it. Signed-off-by: James Morse --- drivers/acpi/apei/ghes.c | 3

[PATCH v7 04/25] ACPI / APEI: Make hest.c manage the estatus memory pool

2018-12-03 Thread James Morse
ghes.c has a memory pool it uses for the estatus cache and the estatus queue. The cache is initialised when registering the platform driver. For the queue, an NMI-like notification has to grow/shrink the pool as it is registered and unregistered. This is all pretty noisy when adding new NMI-like

[PATCH v7 01/25] ACPI / APEI: Don't wait to serialise with oops messages when panic()ing

2018-12-03 Thread James Morse
oops_begin() exists to group printk() messages with the oops message printed by die(). To reach this caller we know that platform firmware took this error first, then notified the OS via NMI with a 'panic' severity. Don't wait for another CPU to release the die-lock before panic()ing, our only

[PATCH v7 09/25] ACPI / APEI: Generalise the estatus queue's notify code

2018-12-03 Thread James Morse
Refactor the estatus queue's pool notification routine from NOTIFY_NMI's handlers. This will allow another notification method to use the estatus queue without duplicating this code. This patch adds rcu_read_lock()/rcu_read_unlock() around the list list_for_each_entry_rcu() walker. These aren't

[PATCH v7 08/25] ACPI / APEI: Don't update struct ghes' flags in read/clear estatus

2018-12-03 Thread James Morse
ghes_read_estatus() sets a flag in struct ghes if the buffer of CPER records needs to be cleared once the records have been processed. This flag value is a problem if a struct ghes can be processed concurrently, as happens at probe time if an NMI arrives for the same error source. The NMI clears

[PATCH v7 05/25] ACPI / APEI: Make estatus pool allocation a static size

2018-12-03 Thread James Morse
Adding new NMI-like notifications duplicates the calls that grow and shrink the estatus pool. This is all pretty pointless, as the size is capped to 64K. Allocate this for each ghes and drop the code that grows and shrinks the pool. Suggested-by: Borislav Petkov Signed-off-by: James Morse ---

[PATCH v7 06/25] ACPI / APEI: Don't store CPER records physical address in struct ghes

2018-12-03 Thread James Morse
When CPER records are found the address of the records is stashed in the struct ghes. Once the records have been processed, this address is overwritten with zero so that it won't be processed again without being re-populated by firmware. This goes wrong if a struct ghes can be processed

[PATCH v7 03/25] ACPI / APEI: Switch estatus pool to use vmalloc memory

2018-12-03 Thread James Morse
The ghes code is careful to parse and round firmware's advertised memory requirements for CPER records, up to a maximum of 64K. However when ghes_estatus_pool_expand() does its work, it splits the requested size into PAGE_SIZE granules. This means if firmware generates 5K of CPER records, and

[PATCH v7 02/25] ACPI / APEI: Remove silent flag from ghes_read_estatus()

2018-12-03 Thread James Morse
Subsequent patches will split up ghes_read_estatus(), at which point passing around the 'silent' flag gets annoying. This is to suppress prink() messages, which prior to commit 42a0bb3f7138 ("printk/nmi: generic solution for safe printk in NMI"), were unsafe in NMI context. This is no longer

[PATCH v7 00/25] APEI in_nmi() rework and SDEI wire-up

2018-12-03 Thread James Morse
Hello, This series aims to wire-up arm64's fancy new software-NMI notifications for firmware-first RAS. These need to use the estatus-queue, which is also needed for notifications via emulated-SError. All of these things take the 'in_nmi()' path through ghes_copy_tofrom_phys(), and so will

Re: [PATCH v3 2/4] arm64: KVM: add accessors to track guest/host only counters

2018-12-03 Thread Will Deacon
On Mon, Dec 03, 2018 at 03:05:52PM +, Andrew Murray wrote: > On Mon, Dec 03, 2018 at 02:31:14PM +, Will Deacon wrote: > > On Thu, Nov 22, 2018 at 11:25:48AM +, Andrew Murray wrote: > > > In order to effeciently enable/disable guest/host only perf counters > > > at guest entry/exit we

Re: [PATCH 02/12] KVM: arm/arm64: Factor out hypercall handling from PSCI code

2018-12-03 Thread Andrew Jones
On Wed, Nov 28, 2018 at 02:45:17PM +, Steven Price wrote: > From: Christoffer Dall > > We currently intertwine the KVM PSCI implementation with the general > dispatch of hypercall handling, which makes perfect sense because PSCI > is the only category of hypercalls we support. > > However,

Re: [PATCH 01/12] KVM: arm64: Document PV-time interface

2018-12-03 Thread Andrew Jones
On Mon, Dec 03, 2018 at 03:23:41PM +, Marc Zyngier wrote: > On 03/12/2018 15:16, Andrew Jones wrote: > > On Mon, Dec 03, 2018 at 02:18:25PM +, Marc Zyngier wrote: > >> On 03/12/2018 13:50, Andrew Jones wrote: > >>> On Wed, Nov 28, 2018 at 02:45:16PM +, Steven Price wrote: > +The

Re: [PATCH v9 8/8] KVM: arm64: Add support for creating PUD hugepages at stage 2

2018-12-03 Thread Anshuman Khandual
On 10/31/2018 11:27 PM, Punit Agrawal wrote: > KVM only supports PMD hugepages at stage 2. Now that the various page > handling routines are updated, extend the stage 2 fault handling to > map in PUD hugepages. > > Addition of PUD hugepage support enables additional page sizes (e.g., > 1G with

Re: [PATCH v9 4/8] KVM: arm64: Support dirty page tracking for PUD hugepages

2018-12-03 Thread Anshuman Khandual
On 10/31/2018 11:27 PM, Punit Agrawal wrote: > In preparation for creating PUD hugepages at stage 2, add support for > write protecting PUD hugepages when they are encountered. Write > protecting guest tables is used to track dirty pages when migrating > VMs. > > Also, provide trivial

Re: [PATCH v9 7/8] KVM: arm64: Update age handlers to support PUD hugepages

2018-12-03 Thread Anshuman Khandual
On 10/31/2018 11:27 PM, Punit Agrawal wrote: > In preparation for creating larger hugepages at Stage 2, add support > to the age handling notifiers for PUD hugepages when encountered. > > Provide trivial helpers for arm32 to allow sharing code. > > Signed-off-by: Punit Agrawal > Reviewed-by:

Re: [PATCH v9 3/8] KVM: arm/arm64: Introduce helpers to manipulate page table entries

2018-12-03 Thread Anshuman Khandual
On 10/31/2018 11:27 PM, Punit Agrawal wrote: > Introduce helpers to abstract architectural handling of the conversion > of pfn to page table entries and marking a PMD page table entry as a > block entry. Why is this necessary ? we would still need to access PMD, PUD as is without any

Re: [PATCH v9 6/8] KVM: arm64: Support handling access faults for PUD hugepages

2018-12-03 Thread Anshuman Khandual
On 10/31/2018 11:27 PM, Punit Agrawal wrote: > In preparation for creating larger hugepages at Stage 2, extend the > access fault handling at Stage 2 to support PUD hugepages when > encountered. > > Provide trivial helpers for arm32 to allow sharing of code. > > Signed-off-by: Punit Agrawal

Re: [PATCH v9 2/8] KVM: arm/arm64: Re-factor setting the Stage 2 entry to exec on fault

2018-12-03 Thread Anshuman Khandual
On 10/31/2018 11:27 PM, Punit Agrawal wrote: > Stage 2 fault handler marks a page as executable if it is handling an > execution fault or if it was a permission fault in which case the > executable bit needs to be preserved. > > The logic to decide if the page should be marked executable is >

Re: [PATCH v9 5/8] KVM: arm64: Support PUD hugepage in stage2_is_exec()

2018-12-03 Thread Anshuman Khandual
On 10/31/2018 11:27 PM, Punit Agrawal wrote: > In preparation for creating PUD hugepages at stage 2, add support for > detecting execute permissions on PUD page table entries. Faults due to > lack of execute permissions on page table entries is used to perform > i-cache invalidation on first

Re: [PATCH 01/12] KVM: arm64: Document PV-time interface

2018-12-03 Thread Marc Zyngier
On 03/12/2018 15:16, Andrew Jones wrote: > On Mon, Dec 03, 2018 at 02:18:25PM +, Marc Zyngier wrote: >> On 03/12/2018 13:50, Andrew Jones wrote: >>> On Wed, Nov 28, 2018 at 02:45:16PM +, Steven Price wrote: +The structure pointed to by the PV_TIME_LPT hypercall is as follows: +

Re: [PATCH v9 1/8] KVM: arm/arm64: Share common code in user_mem_abort()

2018-12-03 Thread Anshuman Khandual
On 10/31/2018 11:27 PM, Punit Agrawal wrote: > The code for operations such as marking the pfn as dirty, and > dcache/icache maintenance during stage 2 fault handling is duplicated > between normal pages and PMD hugepages. > > Instead of creating another copy of the operations when we

Re: [PATCH 01/12] KVM: arm64: Document PV-time interface

2018-12-03 Thread Andrew Jones
On Mon, Dec 03, 2018 at 02:18:25PM +, Marc Zyngier wrote: > On 03/12/2018 13:50, Andrew Jones wrote: > > On Wed, Nov 28, 2018 at 02:45:16PM +, Steven Price wrote: > >> +The structure pointed to by the PV_TIME_LPT hypercall is as follows: > >> + > >> + Field | Byte Length | Byte

Re: [PATCH v3 3/4] arm64: arm_pmu: Add support for exclude_host/exclude_guest attributes

2018-12-03 Thread Will Deacon
Hi Andrew, On Thu, Nov 22, 2018 at 11:25:49AM +, Andrew Murray wrote: > Add support for the :G and :H attributes in perf by handling the > exclude_host/exclude_guest event attributes. > > We notify KVM of counters that we wish to be enabled or disabled on > guest entry/exit and thus defer

Re: [PATCH v3 2/4] arm64: KVM: add accessors to track guest/host only counters

2018-12-03 Thread Andrew Murray
On Mon, Dec 03, 2018 at 02:31:14PM +, Will Deacon wrote: > On Thu, Nov 22, 2018 at 11:25:48AM +, Andrew Murray wrote: > > In order to effeciently enable/disable guest/host only perf counters > > at guest entry/exit we add bitfields to kvm_cpu_context for guest and > > host only events as

Re: [PATCH 00/12] arm64: Paravirtualized time support

2018-12-03 Thread Marc Zyngier
On 03/12/2018 13:25, Andrew Jones wrote: > On Wed, Nov 28, 2018 at 02:45:15PM +, Steven Price wrote: [...] >> It implements support for Live Physical Time (LPT) which provides the >> guest with a method to derive a stable counter of time during which the >> guest is executing even when the

Re: [PATCH v3 2/4] arm64: KVM: add accessors to track guest/host only counters

2018-12-03 Thread Will Deacon
On Thu, Nov 22, 2018 at 11:25:48AM +, Andrew Murray wrote: > In order to effeciently enable/disable guest/host only perf counters > at guest entry/exit we add bitfields to kvm_cpu_context for guest and > host only events as well as accessors for updating them. > > Signed-off-by: Andrew Murray

Re: [PATCH v9 4/8] KVM: arm64: Support dirty page tracking for PUD hugepages

2018-12-03 Thread Suzuki K Poulose
On 03/12/2018 14:17, Anshuman Khandual wrote: On 10/31/2018 11:27 PM, Punit Agrawal wrote: In preparation for creating PUD hugepages at stage 2, add support for write protecting PUD hugepages when they are encountered. Write protecting guest tables is used to track dirty pages when

Re: [PATCH 01/12] KVM: arm64: Document PV-time interface

2018-12-03 Thread Marc Zyngier
Hi Drew, On 03/12/2018 13:50, Andrew Jones wrote: > On Wed, Nov 28, 2018 at 02:45:16PM +, Steven Price wrote: >> We introduce a paravirtualization interface for KVM/arm64 based on the >> "Arm Paravirtualized Time for Arm-Base Systems" specification DEN 0057A. >> >> User space can specify a

Re: [PATCH v9 3/8] KVM: arm/arm64: Introduce helpers to manipulate page table entries

2018-12-03 Thread Suzuki K Poulose
Hi Anshuman, On 03/12/2018 13:50, Anshuman Khandual wrote: On 10/31/2018 11:27 PM, Punit Agrawal wrote: Introduce helpers to abstract architectural handling of the conversion of pfn to page table entries and marking a PMD page table entry as a block entry. Why is this necessary ? we would

Re: [PATCH 01/12] KVM: arm64: Document PV-time interface

2018-12-03 Thread Andrew Jones
On Wed, Nov 28, 2018 at 02:45:16PM +, Steven Price wrote: > We introduce a paravirtualization interface for KVM/arm64 based on the > "Arm Paravirtualized Time for Arm-Base Systems" specification DEN 0057A. > > User space can specify a reserved area of memory for the guest and > inform KVM to

Re: [PATCH v9 1/8] KVM: arm/arm64: Share common code in user_mem_abort()

2018-12-03 Thread Suzuki K Poulose
Hi Anshuman, On 03/12/2018 12:11, Anshuman Khandual wrote: On 10/31/2018 11:27 PM, Punit Agrawal wrote: The code for operations such as marking the pfn as dirty, and dcache/icache maintenance during stage 2 fault handling is duplicated between normal pages and PMD hugepages. Instead of

Re: [PATCH v5 0/7] Add virtio-iommu driver

2018-12-03 Thread Auger Eric
Hi Michael, On 11/27/18 6:16 PM, Michael S. Tsirkin wrote: > On Tue, Nov 27, 2018 at 06:09:25PM +0100, Auger Eric wrote: >> Hi Michael, >> >> On 11/27/18 5:53 PM, Michael S. Tsirkin wrote: >>> On Thu, Nov 22, 2018 at 07:37:54PM +, Jean-Philippe Brucker wrote: Implement the virtio-iommu

Re: [PATCH 00/12] arm64: Paravirtualized time support

2018-12-03 Thread Andrew Jones
On Wed, Nov 28, 2018 at 02:45:15PM +, Steven Price wrote: > This series add support for paravirtualized time for Arm64 guests and > KVM hosts following the specification in Arm's document DEN 0057A: > > https://developer.arm.com/docs/den0057/a Hi Steven, As that specification is still a