From: Sasha Levin <sasha.levin@oracle.com>
To: stable@vger.kernel.org, stable-commits@vger.kernel.org
Cc: Christoffer Dall <christoffer.dall@linaro.org>,
Shannon Zhao <shannon.zhao@linaro.org>,
Sasha Levin <sasha.levin@oracle.com>
Subject: [added to the 3.18 stable tree] arm/arm64: KVM: Turn off vcpus on PSCI shutdown/reboot
Date: Mon, 11 May 2015 07:16:28 -0400 [thread overview]
Message-ID: <1431343152-19437-7-git-send-email-sasha.levin@oracle.com> (raw)
In-Reply-To: <1431343152-19437-1-git-send-email-sasha.levin@oracle.com>
From: Christoffer Dall <christoffer.dall@linaro.org>
commit cf5d318865e25f887d49a0c6083bbc6dcd1905b1 upstream.
When a vcpu calls SYSTEM_OFF or SYSTEM_RESET with PSCI v0.2, the vcpus
should really be turned off for the VM adhering to the suggestions in
the PSCI spec, and it's the sane thing to do.
Also, clarify the behavior and expectations for exits to user space with
the KVM_EXIT_SYSTEM_EVENT case.
Acked-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
Documentation/virtual/kvm/api.txt | 9 +++++++++
arch/arm/kvm/psci.c | 18 ++++++++++++++++++
arch/arm64/include/asm/kvm_host.h | 1 +
3 files changed, 28 insertions(+)
diff --git a/Documentation/virtual/kvm/api.txt b/Documentation/virtual/kvm/api.txt
index bb82a90..702bb25 100644
--- a/Documentation/virtual/kvm/api.txt
+++ b/Documentation/virtual/kvm/api.txt
@@ -2952,6 +2952,15 @@ HVC instruction based PSCI call from the vcpu. The 'type' field describes
the system-level event type. The 'flags' field describes architecture
specific flags for the system-level event.
+Valid values for 'type' are:
+ KVM_SYSTEM_EVENT_SHUTDOWN -- the guest has requested a shutdown of the
+ VM. Userspace is not obliged to honour this, and if it does honour
+ this does not need to destroy the VM synchronously (ie it may call
+ KVM_RUN again before shutdown finally occurs).
+ KVM_SYSTEM_EVENT_RESET -- the guest has requested a reset of the VM.
+ As with SHUTDOWN, userspace can choose to ignore the request, or
+ to schedule the reset to occur in the future and may call KVM_RUN again.
+
/* Fix the size of the union. */
char padding[256];
};
diff --git a/arch/arm/kvm/psci.c b/arch/arm/kvm/psci.c
index 09cf377..58cb324 100644
--- a/arch/arm/kvm/psci.c
+++ b/arch/arm/kvm/psci.c
@@ -15,6 +15,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <linux/preempt.h>
#include <linux/kvm_host.h>
#include <linux/wait.h>
@@ -166,6 +167,23 @@ static unsigned long kvm_psci_vcpu_affinity_info(struct kvm_vcpu *vcpu)
static void kvm_prepare_system_event(struct kvm_vcpu *vcpu, u32 type)
{
+ int i;
+ struct kvm_vcpu *tmp;
+
+ /*
+ * The KVM ABI specifies that a system event exit may call KVM_RUN
+ * again and may perform shutdown/reboot at a later time that when the
+ * actual request is made. Since we are implementing PSCI and a
+ * caller of PSCI reboot and shutdown expects that the system shuts
+ * down or reboots immediately, let's make sure that VCPUs are not run
+ * after this call is handled and before the VCPUs have been
+ * re-initialized.
+ */
+ kvm_for_each_vcpu(i, tmp, vcpu->kvm) {
+ tmp->arch.pause = true;
+ kvm_vcpu_kick(tmp);
+ }
+
memset(&vcpu->run->system_event, 0, sizeof(vcpu->run->system_event));
vcpu->run->system_event.type = type;
vcpu->run->exit_reason = KVM_EXIT_SYSTEM_EVENT;
diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h
index 2012c4b..dbd3212 100644
--- a/arch/arm64/include/asm/kvm_host.h
+++ b/arch/arm64/include/asm/kvm_host.h
@@ -200,6 +200,7 @@ struct kvm_vcpu *kvm_arm_get_running_vcpu(void);
struct kvm_vcpu * __percpu *kvm_get_running_vcpus(void);
u64 kvm_call_hyp(void *hypfn, ...);
+void force_vm_exit(const cpumask_t *mask);
int handle_exit(struct kvm_vcpu *vcpu, struct kvm_run *run,
int exception_index);
--
2.1.0
next prev parent reply other threads:[~2015-05-11 11:19 UTC|newest]
Thread overview: 106+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-11 11:16 [added to the 3.18 stable tree] kvm: add a memslot flag for incoherent memory regions Sasha Levin
2015-05-11 11:16 ` [added to the 3.18 stable tree] arm, arm64: KVM: allow forced dcache flush on page faults Sasha Levin
2015-05-11 11:16 ` [added to the 3.18 stable tree] arm, arm64: KVM: handle potential incoherency of readonly memslots Sasha Levin
2015-05-11 11:16 ` [added to the 3.18 stable tree] arm/arm64: KVM: Don't clear the VCPU_POWER_OFF flag Sasha Levin
2015-05-11 11:16 ` [added to the 3.18 stable tree] arm/arm64: KVM: Correct KVM_ARM_VCPU_INIT power off option Sasha Levin
2015-05-11 11:16 ` [added to the 3.18 stable tree] arm/arm64: KVM: Reset the HCR on each vcpu when resetting the vcpu Sasha Levin
2015-05-11 11:16 ` Sasha Levin [this message]
2015-05-11 11:16 ` [added to the 3.18 stable tree] arm/arm64: KVM: Introduce stage2_unmap_vm Sasha Levin
2015-05-11 11:16 ` [added to the 3.18 stable tree] arm/arm64: KVM: vgic: move reset initialization into vgic_init_maps() Sasha Levin
2015-05-11 11:16 ` [added to the 3.18 stable tree] arm/arm64: KVM: Don't allow creating VCPUs after vgic_initialized Sasha Levin
2015-05-11 11:16 ` [added to the 3.18 stable tree] arm/arm64: KVM: vgic: kick the specific vcpu instead of iterating through all Sasha Levin
2015-05-11 11:16 ` [added to the 3.18 stable tree] arm/arm64: KVM: Initialize the vgic on-demand when injecting IRQs Sasha Levin
2015-05-11 11:16 ` [added to the 3.18 stable tree] arm/arm64: KVM: Require in-kernel vgic for the arch timers Sasha Levin
2015-05-11 11:16 ` [added to the 3.18 stable tree] KVM: arm/arm64: vgic: vgic_init returns -ENODEV when no online vcpu Sasha Levin
2015-05-11 11:16 ` [added to the 3.18 stable tree] arm64: KVM: Fix TLB invalidation by IPA/VMID Sasha Levin
2015-05-11 11:16 ` [added to the 3.18 stable tree] arm64: KVM: Fix HCR setting for 32bit guests Sasha Levin
2015-05-11 11:16 ` [added to the 3.18 stable tree] arm/arm64: KVM: Invalidate data cache on unmap Sasha Levin
2015-05-11 11:16 ` [added to the 3.18 stable tree] arm/arm64: KVM: Use kernel mapping to perform invalidation on page fault Sasha Levin
2015-05-11 11:16 ` [added to the 3.18 stable tree] ARM: KVM: Fix size check in __coherent_cache_guest_page Sasha Levin
2015-05-11 11:16 ` [added to the 3.18 stable tree] arm64: KVM: Fix stage-2 PGD allocation to have per-page refcounting Sasha Levin
2015-05-11 11:16 ` [added to the 3.18 stable tree] arm64: KVM: Do not use pgd_index to index stage-2 pgd Sasha Levin
2015-05-11 11:16 ` [added to the 3.18 stable tree] arm/arm64: KVM: Keep elrsr/aisr in sync with software model Sasha Levin
2015-05-11 11:16 ` [added to the 3.18 stable tree] mlx4: Fix tx ring affinity_mask creation Sasha Levin
2015-05-11 11:16 ` [added to the 3.18 stable tree] net/mlx4_en: Schedule napi when RX buffers allocation fails Sasha Levin
2015-05-11 11:16 ` [added to the 3.18 stable tree] ipv4: Missing sk_nulls_node_init() in ping_unhash() Sasha Levin
2015-05-11 11:16 ` [added to the 3.18 stable tree] ip_forward: Drop frames with attached skb->sk Sasha Levin
2015-05-11 11:16 ` [added to the 3.18 stable tree] net: add skb_checksum_complete_unset Sasha Levin
2015-05-11 11:16 ` [added to the 3.18 stable tree] ppp: call skb_checksum_complete_unset in ppp_receive_frame Sasha Levin
2015-05-11 11:16 ` [added to the 3.18 stable tree] tcp: fix possible deadlock in tcp_send_fin() Sasha Levin
2015-05-11 11:16 ` [added to the 3.18 stable tree] tcp: avoid looping " Sasha Levin
2015-05-11 11:16 ` [added to the 3.18 stable tree] net: do not deplete pfmemalloc reserve Sasha Levin
2015-05-11 11:16 ` [added to the 3.18 stable tree] net: fix crash in build_skb() Sasha Levin
2015-05-11 11:16 ` [added to the 3.18 stable tree] x86/asm/decoder: Fix and enforce max instruction size in the insn decoder Sasha Levin
2015-05-11 11:16 ` [added to the 3.18 stable tree] sched/idle/x86: Restore mwait_idle() to fix boot hangs, to improve power savings and to improve performance Sasha Levin
2015-05-11 11:16 ` [added to the 3.18 stable tree] sched/idle/x86: Optimize unnecessary mwait_idle() resched IPIs Sasha Levin
2015-05-11 11:16 ` [added to the 3.18 stable tree] KVM: x86: Fix MSR_IA32_BNDCFGS in msrs_to_save Sasha Levin
2015-05-11 11:16 ` [added to the 3.18 stable tree] Btrfs: fix log tree corruption when fs mounted with -o discard Sasha Levin
2015-05-11 11:16 ` [added to the 3.18 stable tree] btrfs: don't accept bare namespace as a valid xattr Sasha Levin
2015-05-11 11:17 ` [added to the 3.18 stable tree] Btrfs: fix inode eviction infinite loop after cloning into it Sasha Levin
2015-05-11 11:17 ` [added to the 3.18 stable tree] Btrfs: fix inode eviction infinite loop after extent_same ioctl Sasha Levin
2015-05-11 11:17 ` [added to the 3.18 stable tree] usb: gadget: printer: enqueue printer's response for setup request Sasha Levin
2015-05-11 11:17 ` [added to the 3.18 stable tree] KVM: s390: fix handling of write errors in the tpi handler Sasha Levin
2015-05-11 11:17 ` [added to the 3.18 stable tree] KVM: s390: reinjection of irqs can fail " Sasha Levin
2015-05-11 11:17 ` [added to the 3.18 stable tree] KVM: s390: Zero out current VMDB of STSI before including level3 data Sasha Levin
2015-05-11 11:17 ` [added to the 3.18 stable tree] KVM: s390: no need to hold the kvm->mutex for floating interrupts Sasha Levin
2015-05-11 11:17 ` [added to the 3.18 stable tree] KVM: s390: fix get_all_floating_irqs Sasha Levin
2015-05-11 11:17 ` [added to the 3.18 stable tree] s390/hibernate: fix save and restore of kernel text section Sasha Levin
2015-05-11 11:17 ` [added to the 3.18 stable tree] KVM: use slowpath for cross page cached accesses Sasha Levin
2015-05-11 11:17 ` [added to the 3.18 stable tree] KVM: arm/arm64: check IRQ number on userland injection Sasha Levin
2015-05-11 11:17 ` [added to the 3.18 stable tree] MIPS: KVM: Handle MSA Disabled exceptions from guest Sasha Levin
2015-05-11 11:17 ` [added to the 3.18 stable tree] MIPS: lose_fpu(): Disable FPU when MSA enabled Sasha Levin
2015-05-11 11:17 ` [added to the 3.18 stable tree] MIPS: Malta: Detect and fix bad memsize values Sasha Levin
2015-05-11 11:17 ` [added to the 3.18 stable tree] MIPS: asm: asm-eva: Introduce kernel load/store variants Sasha Levin
2015-05-11 11:17 ` [added to the 3.18 stable tree] MIPS: Loongson-3: Add IRQF_NO_SUSPEND to Cascade irqaction Sasha Levin
2015-05-11 11:17 ` [added to the 3.18 stable tree] MIPS: Hibernate: flush TLB entries earlier Sasha Levin
2015-05-11 11:17 ` [added to the 3.18 stable tree] staging: panel: fix lcd type Sasha Levin
2015-05-11 11:17 ` [added to the 3.18 stable tree] staging: android: sync: Fix memory corruption in sync_timeline_signal() Sasha Levin
2015-05-11 11:17 ` [added to the 3.18 stable tree] md/raid0: fix bug with chunksize not a power of 2 Sasha Levin
2015-05-11 11:17 ` [added to the 3.18 stable tree] cdc-wdm: fix endianness bug in debug statements Sasha Levin
2015-05-11 11:17 ` [added to the 3.18 stable tree] mmc: sunxi: Use devm_reset_control_get_optional() for reset control Sasha Levin
2015-05-11 11:17 ` [added to the 3.18 stable tree] spi: imx: read back the RX/TX watermark levels earlier Sasha Levin
2015-05-11 11:17 ` [added to the 3.18 stable tree] spi: spidev: fix possible arithmetic overflow for multi-transfer message Sasha Levin
2015-05-11 11:17 ` [added to the 3.18 stable tree] compal-laptop: Fix leaking hwmon device Sasha Levin
2015-05-11 11:17 ` [added to the 3.18 stable tree] compal-laptop: Check return value of power_supply_register Sasha Levin
2015-05-11 11:17 ` [added to the 3.18 stable tree] ring-buffer: Replace this_cpu_*() with __this_cpu_*() Sasha Levin
2015-05-11 11:17 ` [added to the 3.18 stable tree] power_supply: twl4030_madc: Check return value of power_supply_register Sasha Levin
2015-05-11 11:17 ` [added to the 3.18 stable tree] power_supply: lp8788-charger: Fix leaked power supply on probe fail Sasha Levin
2015-05-11 11:17 ` [added to the 3.18 stable tree] power_supply: ipaq_micro_battery: Fix leaking workqueue Sasha Levin
2015-05-11 11:17 ` [added to the 3.18 stable tree] power_supply: ipaq_micro_battery: Check return values in probe Sasha Levin
2015-05-11 11:17 ` [added to the 3.18 stable tree] NFS: fix BUG() crash in notify_change() with patch to chown_common() Sasha Levin
2015-05-11 11:17 ` [added to the 3.18 stable tree] ARM: fix broken hibernation Sasha Levin
2015-05-11 11:17 ` [added to the 3.18 stable tree] ARM: 8320/1: fix integer overflow in ELF_ET_DYN_BASE Sasha Levin
2015-05-11 11:17 ` [added to the 3.18 stable tree] ARM: mvebu: Disable CPU Idle on Armada 38x Sasha Levin
2015-05-11 11:17 ` [added to the 3.18 stable tree] ARM: S3C64XX: Use fixed IRQ bases to avoid conflicts on Cragganmore Sasha Levin
2015-05-11 11:17 ` [added to the 3.18 stable tree] ARM: dts: dove: Fix uart[23] reg property Sasha Levin
2015-05-11 11:17 ` [added to the 3.18 stable tree] usb: musb: core: fix TX/RX endpoint order Sasha Levin
2015-05-11 11:17 ` [added to the 3.18 stable tree] usb: phy: Find the right match in devm_usb_phy_match Sasha Levin
2015-05-11 11:17 ` [added to the 3.18 stable tree] usb: define a generic USB_RESUME_TIMEOUT macro Sasha Levin
2015-05-11 11:17 ` [added to the 3.18 stable tree] usb: musb: use new USB_RESUME_TIMEOUT Sasha Levin
2015-05-11 11:17 ` [added to the 3.18 stable tree] usb: host: oxu210hp: " Sasha Levin
2015-05-11 11:17 ` [added to the 3.18 stable tree] usb: host: fusbh200: " Sasha Levin
2015-05-11 11:17 ` [added to the 3.18 stable tree] usb: host: uhci: " Sasha Levin
2015-05-11 11:17 ` [added to the 3.18 stable tree] usb: host: fotg210: " Sasha Levin
2015-05-11 11:17 ` [added to the 3.18 stable tree] usb: host: r8a66597: " Sasha Levin
2015-05-11 11:17 ` [added to the 3.18 stable tree] usb: host: isp116x: " Sasha Levin
2015-05-11 11:17 ` [added to the 3.18 stable tree] usb: host: xhci: " Sasha Levin
2015-05-11 11:17 ` [added to the 3.18 stable tree] usb: host: ehci: " Sasha Levin
2015-05-11 11:17 ` [added to the 3.18 stable tree] usb: host: sl811: " Sasha Levin
2015-05-11 11:17 ` [added to the 3.18 stable tree] usb: core: hub: " Sasha Levin
2015-05-11 11:17 ` [added to the 3.18 stable tree] clk: at91: usb: propagate rate modification to the parent clk Sasha Levin
2015-05-15 7:16 ` Boris Brezillon
2015-05-16 0:11 ` Sasha Levin
2015-05-11 11:17 ` [added to the 3.18 stable tree] ALSA: hda - Add dock support for ThinkPad X250 (17aa:2226) Sasha Levin
2015-05-11 11:17 ` [added to the 3.18 stable tree] ALSA: emu10k1: don't deadlock in proc-functions Sasha Levin
2015-05-11 11:17 ` [added to the 3.18 stable tree] ALSA: hda/realtek - Enable the ALC292 dock fixup on the Thinkpad T450 Sasha Levin
2015-05-11 11:17 ` [added to the 3.18 stable tree] ALSA: hda - fix "num_steps = 0" error on ALC256 Sasha Levin
2015-05-11 11:17 ` [added to the 3.18 stable tree] ALSA: hda/realtek - Fix Headphone Mic doesn't recording for ALC256 Sasha Levin
2015-05-11 11:17 ` [added to the 3.18 stable tree] Input: elantech - fix absolute mode setting on some ASUS laptops Sasha Levin
2015-05-11 11:17 ` [added to the 3.18 stable tree] fs/binfmt_elf.c: fix bug in loading of PIE binaries Sasha Levin
2015-05-11 11:17 ` [added to the 3.18 stable tree] ptrace: fix race between ptrace_resume() and wait_task_stopped() Sasha Levin
2015-05-11 11:18 ` [added to the 3.18 stable tree] NFC: st21nfcb: Retry i2c_master_send if it returns a negative value Sasha Levin
2015-05-11 11:18 ` [added to the 3.18 stable tree] rtlwifi: rtl8192cu: Add new USB ID Sasha Levin
2015-05-11 11:18 ` [added to the 3.18 stable tree] rtlwifi: rtl8192cu: Add new device ID Sasha Levin
2015-05-11 11:18 ` [added to the 3.18 stable tree] ext4: make fsync to sync parent dir in no-journal for real this time Sasha Levin
2015-05-11 11:18 ` [added to the 3.18 stable tree] mnt: Improve the umount_tree flags Sasha Levin
2015-05-11 11:18 ` [added to the 3.18 stable tree] mnt: Don't propagate umounts in __detach_mounts Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1431343152-19437-7-git-send-email-sasha.levin@oracle.com \
--to=sasha.levin@oracle.com \
--cc=christoffer.dall@linaro.org \
--cc=shannon.zhao@linaro.org \
--cc=stable-commits@vger.kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox