2019-05-27 06:55:01 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2007-02-08 07:33:55 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2006 Michael Ellerman, IBM Corporation
|
|
|
|
*/
|
|
|
|
|
2011-04-04 03:46:58 +00:00
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
|
2007-02-08 07:33:55 +00:00
|
|
|
#include <asm/machdep.h>
|
|
|
|
#include <asm/page.h>
|
|
|
|
#include <asm/firmware.h>
|
|
|
|
#include <asm/kexec.h>
|
2011-04-04 03:46:58 +00:00
|
|
|
#include <asm/xics.h>
|
powerpc/xive: guest exploitation of the XIVE interrupt controller
This is the framework for using XIVE in a PowerVM guest. The support
is very similar to the native one in a much simpler form.
Each source is associated with an Event State Buffer (ESB). This is a
two bit state machine which is used to trigger events. The bits are
named "P" (pending) and "Q" (queued) and can be controlled by MMIO.
The Guest OS registers event (or notifications) queues on which the HW
will post event data for a target to notify.
Instead of OPAL calls, a set of Hypervisors call are used to configure
the interrupt sources and the event/notification queues of the guest:
- H_INT_GET_SOURCE_INFO
used to obtain the address of the MMIO page of the Event State
Buffer (PQ bits) entry associated with the source.
- H_INT_SET_SOURCE_CONFIG
assigns a source to a "target".
- H_INT_GET_SOURCE_CONFIG
determines to which "target" and "priority" is assigned to a source
- H_INT_GET_QUEUE_INFO
returns the address of the notification management page associated
with the specified "target" and "priority".
- H_INT_SET_QUEUE_CONFIG
sets or resets the event queue for a given "target" and "priority".
It is also used to set the notification config associated with the
queue, only unconditional notification for the moment. Reset is
performed with a queue size of 0 and queueing is disabled in that
case.
- H_INT_GET_QUEUE_CONFIG
returns the queue settings for a given "target" and "priority".
- H_INT_RESET
resets all of the partition's interrupt exploitation structures to
their initial state, losing all configuration set via the hcalls
H_INT_SET_SOURCE_CONFIG and H_INT_SET_QUEUE_CONFIG.
- H_INT_SYNC
issue a synchronisation on a source to make sure sure all
notifications have reached their queue.
As for XICS, the XIVE interface for the guest is described in the
device tree under the "interrupt-controller" node. A couple of new
properties are specific to XIVE :
- "reg"
contains the base address and size of the thread interrupt
managnement areas (TIMA), also called rings, for the User level and
for the Guest OS level. Only the Guest OS level is taken into
account today.
- "ibm,xive-eq-sizes"
the size of the event queues. One cell per size supported, contains
log2 of size, in ascending order.
- "ibm,xive-lisn-ranges"
the interrupt numbers ranges assigned to the guest. These are
allocated using a simple bitmap.
and also :
- "/ibm,plat-res-int-priorities"
contains a list of priorities that the hypervisor has reserved for
its own use.
Tested with a QEMU XIVE model for pseries and with the Power hypervisor.
Signed-off-by: Cédric Le Goater <clg@kaod.org>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2017-08-30 19:46:11 +00:00
|
|
|
#include <asm/xive.h>
|
2007-05-10 12:17:18 +00:00
|
|
|
#include <asm/smp.h>
|
2013-08-22 09:53:52 +00:00
|
|
|
#include <asm/plpar_wrappers.h>
|
2007-02-08 07:33:55 +00:00
|
|
|
|
|
|
|
#include "pseries.h"
|
|
|
|
|
2016-05-30 06:18:13 +00:00
|
|
|
void pseries_kexec_cpu_down(int crash_shutdown, int secondary)
|
2007-02-08 07:33:55 +00:00
|
|
|
{
|
2018-02-13 15:08:13 +00:00
|
|
|
/*
|
|
|
|
* Don't risk a hypervisor call if we're crashing
|
|
|
|
* XXX: Why? The hypervisor is not crashing. It might be better
|
|
|
|
* to at least attempt unregister to avoid the hypervisor stepping
|
|
|
|
* on our memory.
|
|
|
|
*/
|
2007-02-08 07:33:55 +00:00
|
|
|
if (firmware_has_feature(FW_FEATURE_SPLPAR) && !crash_shutdown) {
|
2011-07-25 01:46:32 +00:00
|
|
|
int ret;
|
2011-07-25 01:46:34 +00:00
|
|
|
int cpu = smp_processor_id();
|
|
|
|
int hwcpu = hard_smp_processor_id();
|
2011-07-25 01:46:32 +00:00
|
|
|
|
|
|
|
if (get_lppaca()->dtl_enable_mask) {
|
2011-07-25 01:46:34 +00:00
|
|
|
ret = unregister_dtl(hwcpu);
|
2011-07-25 01:46:32 +00:00
|
|
|
if (ret) {
|
|
|
|
pr_err("WARNING: DTL deregistration for cpu "
|
|
|
|
"%d (hw %d) failed with %d\n",
|
2011-07-25 01:46:34 +00:00
|
|
|
cpu, hwcpu, ret);
|
2011-07-25 01:46:32 +00:00
|
|
|
}
|
|
|
|
}
|
2007-02-08 07:33:55 +00:00
|
|
|
|
2011-07-25 01:46:34 +00:00
|
|
|
ret = unregister_slb_shadow(hwcpu);
|
2011-07-25 01:46:33 +00:00
|
|
|
if (ret) {
|
|
|
|
pr_err("WARNING: SLB shadow buffer deregistration "
|
|
|
|
"for cpu %d (hw %d) failed with %d\n",
|
2011-07-25 01:46:34 +00:00
|
|
|
cpu, hwcpu, ret);
|
2011-07-25 01:46:33 +00:00
|
|
|
}
|
2007-02-08 07:33:55 +00:00
|
|
|
|
2011-07-25 01:46:34 +00:00
|
|
|
ret = unregister_vpa(hwcpu);
|
2011-07-25 01:46:33 +00:00
|
|
|
if (ret) {
|
|
|
|
pr_err("WARNING: VPA deregistration for cpu %d "
|
2011-07-25 01:46:34 +00:00
|
|
|
"(hw %d) failed with %d\n", cpu, hwcpu, ret);
|
2007-02-08 07:33:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-08 07:05:16 +00:00
|
|
|
if (xive_enabled()) {
|
2018-04-11 05:18:01 +00:00
|
|
|
xive_teardown_cpu();
|
2018-05-08 07:05:16 +00:00
|
|
|
|
|
|
|
if (!secondary)
|
|
|
|
xive_shutdown();
|
|
|
|
} else
|
powerpc/xive: guest exploitation of the XIVE interrupt controller
This is the framework for using XIVE in a PowerVM guest. The support
is very similar to the native one in a much simpler form.
Each source is associated with an Event State Buffer (ESB). This is a
two bit state machine which is used to trigger events. The bits are
named "P" (pending) and "Q" (queued) and can be controlled by MMIO.
The Guest OS registers event (or notifications) queues on which the HW
will post event data for a target to notify.
Instead of OPAL calls, a set of Hypervisors call are used to configure
the interrupt sources and the event/notification queues of the guest:
- H_INT_GET_SOURCE_INFO
used to obtain the address of the MMIO page of the Event State
Buffer (PQ bits) entry associated with the source.
- H_INT_SET_SOURCE_CONFIG
assigns a source to a "target".
- H_INT_GET_SOURCE_CONFIG
determines to which "target" and "priority" is assigned to a source
- H_INT_GET_QUEUE_INFO
returns the address of the notification management page associated
with the specified "target" and "priority".
- H_INT_SET_QUEUE_CONFIG
sets or resets the event queue for a given "target" and "priority".
It is also used to set the notification config associated with the
queue, only unconditional notification for the moment. Reset is
performed with a queue size of 0 and queueing is disabled in that
case.
- H_INT_GET_QUEUE_CONFIG
returns the queue settings for a given "target" and "priority".
- H_INT_RESET
resets all of the partition's interrupt exploitation structures to
their initial state, losing all configuration set via the hcalls
H_INT_SET_SOURCE_CONFIG and H_INT_SET_QUEUE_CONFIG.
- H_INT_SYNC
issue a synchronisation on a source to make sure sure all
notifications have reached their queue.
As for XICS, the XIVE interface for the guest is described in the
device tree under the "interrupt-controller" node. A couple of new
properties are specific to XIVE :
- "reg"
contains the base address and size of the thread interrupt
managnement areas (TIMA), also called rings, for the User level and
for the Guest OS level. Only the Guest OS level is taken into
account today.
- "ibm,xive-eq-sizes"
the size of the event queues. One cell per size supported, contains
log2 of size, in ascending order.
- "ibm,xive-lisn-ranges"
the interrupt numbers ranges assigned to the guest. These are
allocated using a simple bitmap.
and also :
- "/ibm,plat-res-int-priorities"
contains a list of priorities that the hypervisor has reserved for
its own use.
Tested with a QEMU XIVE model for pseries and with the Power hypervisor.
Signed-off-by: Cédric Le Goater <clg@kaod.org>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2017-08-30 19:46:11 +00:00
|
|
|
xics_kexec_teardown_cpu(secondary);
|
2007-02-08 07:33:55 +00:00
|
|
|
}
|