Skip to content

RFC Process-local memory allocations

Julian Stecklina lkml 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest6 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6kvm, vmx: move CR2 context switch out of assembly patharch/x86/kvm/vmx.c+5 -100 replies
2/6kvm, vmx: move register clearing out of assembly patharch/x86/kvm/vmx.c+29 -170 replies
3/6mm, x86: make __kernel_map_pages always availablearch/x86/mm/pageattr.c include/linux/mm.h+3 -30 replies
4/6x86/speculation, mm: add process local virtual memory regionarch/x86/Kconfig arch/x86/include/asm/pgtable_64_types.h arch/x86/include/asm/proclocal.h +6 more+362 -00 replies
5/6x86/speculation, kvm: move guest FPU state into process local memoryarch/x86/include/asm/kvm_host.h arch/x86/kvm/x86.c+37 -150 replies
6/6x86/speculation, kvm: move gprs to process local storagearch/x86/include/asm/kvm_host.h arch/x86/kvm/kvm_cache_regs.h arch/x86/kvm/svm.c +2 more+164 -1280 replies

Reviews trailers per patch

2 of 6 patches have a Reviewed-by or Acked-by.

PatchJan H. SchönherrKonrad Jan MillerJim MattsonSean Christopherson
1/6R-b R-b R-b R-b
2/6R-b R-b R-b
3/6
4/6
5/6
6/6

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 4 reviewers.

Read the v1 thread

Cover letter [RFC RESEND PATCH 0/6] Process-local memory allocations

In a world with processor information leak vulnerabilities, having a treasure trove of information available for leaking in the global kernel address space is starting to be a liability. The biggest offender is the linear mapping of all physical memory and there are already efforts (XPFO) to start addressing this. In this patch series, I'd like to propose breaking up the kernel address space further and introduce process-local mappings in the kernel.

The rationale is that there are allocations in the kernel containing data that should only be accessible when the kernel is executing in the context of a specific process. A prime example is KVM vCPU state. This patch series introduces process-local memory in the kernel address space by claiming a PGD entry for this specific purpose. Then it converts KVM on x86 to use these new primitives to store GPR and FPU registers of vCPUs. KVM is a good testing ground, because it makes sure userspace can only interact with a VM from a single process.

Process-local allocations in the kernel can be part of a robust L1TF mitigation strategy that works even with SMT enabled. The specific goal here is to make it harder for a random thread using cache load gadget (usually a bounds check of a system call argument plus array access suffices) to prefetch interesting data into the L1 cache and use L1TF to leak this data.

The patch set applies to kvm/next [1]. Feedback is very welcome, both about the general approach and the actual implementation. As far as testing goes, the KVM unit tests seem happy on Intel. AMD is only compile tested at the moment.

[1] git://git.kernel.org/pub/scm/virt/kvm/kvm.git

Julian Stecklina (6):
kvm, vmx: move CR2 context switch out of assembly path kvm, vmx: move register clearing out of assembly path
mm, x86: make __kernel_map_pages always available x86/speculation, mm: add process local virtual memory region x86/speculation, kvm: move guest FPU state into process local memory x86/speculation, kvm: move gprs to process local storage

 arch/x86/Kconfig                        |   1 +
 arch/x86/include/asm/kvm_host.h         |  13 +-
 arch/x86/include/asm/pgtable_64_types.h |   6 +
 arch/x86/include/asm/proclocal.h        |  44 ++++
 arch/x86/kvm/kvm_cache_regs.h           |   4 +-
 arch/x86/kvm/svm.c                      | 132 +++++++-----
 arch/x86/kvm/vmx.c                      | 203 ++++++++++--------
 arch/x86/kvm/x86.c                      |  45 ++--
 arch/x86/mm/Makefile                    |   2 +
 arch/x86/mm/dump_pagetables.c           |   3 +
 arch/x86/mm/fault.c                     |  14 ++
 arch/x86/mm/pageattr.c                  |   3 +-
 arch/x86/mm/proclocal.c                 | 269 ++++++++++++++++++++++++
 include/linux/mm.h                      |   3 +-
 include/linux/mm_types.h                |   7 +
 security/Kconfig                        |  16 ++
 16 files changed, 596 insertions(+), 169 deletions(-)
 create mode 100644 arch/x86/include/asm/proclocal.h
 create mode 100644 arch/x86/mm/proclocal.c
Signature · 1 line
2.17.1