Message ID | 1557758315-12667-3-git-send-email-alexandre.chartre@oracle.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | KVM Address Space Isolation | expand |
On Mon, May 13, 2019 at 7:39 AM Alexandre Chartre <alexandre.chartre@oracle.com> wrote: > > From: Liran Alon <liran.alon@oracle.com> > > Add the address_space_isolation parameter to the kvm module. > > When set to true, KVM #VMExit handlers run in isolated address space > which maps only KVM required code and per-VM information instead of > entire kernel address space. Does the *entry* also get isolated? If not, it seems less useful for side-channel mitigation.
On 5/13/19 5:46 PM, Andy Lutomirski wrote: > On Mon, May 13, 2019 at 7:39 AM Alexandre Chartre > <alexandre.chartre@oracle.com> wrote: >> >> From: Liran Alon <liran.alon@oracle.com> >> >> Add the address_space_isolation parameter to the kvm module. >> >> When set to true, KVM #VMExit handlers run in isolated address space >> which maps only KVM required code and per-VM information instead of >> entire kernel address space. > > Does the *entry* also get isolated? If not, it seems less useful for > side-channel mitigation. > Yes, context is switched before VM entry. We switch back to kernel address space if VM-exit handler needs it or when exiting the KVM_RUN ioctl. alex.
diff --git a/arch/x86/kvm/Makefile b/arch/x86/kvm/Makefile index 31ecf7a..9f404e9 100644 --- a/arch/x86/kvm/Makefile +++ b/arch/x86/kvm/Makefile @@ -10,7 +10,7 @@ kvm-$(CONFIG_KVM_ASYNC_PF) += $(KVM)/async_pf.o kvm-y += x86.o mmu.o emulate.o i8259.o irq.o lapic.o \ i8254.o ioapic.o irq_comm.o cpuid.o pmu.o mtrr.o \ - hyperv.o page_track.o debugfs.o + hyperv.o page_track.o debugfs.o isolation.o kvm-intel-y += vmx/vmx.o vmx/vmenter.o vmx/pmu_intel.o vmx/vmcs12.o vmx/evmcs.o vmx/nested.o kvm-amd-y += svm.o pmu_amd.o diff --git a/arch/x86/kvm/isolation.c b/arch/x86/kvm/isolation.c new file mode 100644 index 0000000..e25f663 --- /dev/null +++ b/arch/x86/kvm/isolation.c @@ -0,0 +1,26 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * + * KVM Address Space Isolation + */ + +#include <linux/module.h> +#include <linux/moduleparam.h> + +/* + * When set to true, KVM #VMExit handlers run in isolated address space + * which maps only KVM required code and per-VM information instead of + * entire kernel address space. + * + * This mechanism is meant to mitigate memory-leak side-channels CPU + * vulnerabilities (e.g. Spectre, L1TF and etc.) but can also be viewed + * as security in-depth as it also helps generically against info-leaks + * vulnerabilities in KVM #VMExit handlers and reduce the available + * gadgets for ROP attacks. + * + * This is set to false by default because it incurs a performance hit + * which some users will not want to take for security gain. + */ +static bool __read_mostly address_space_isolation; +module_param(address_space_isolation, bool, 0444);