Re: [PATCH] drm/virtio: fix OOB in virtio_gpu_object_create

2020-03-19 Thread Gerd Hoffmann
On Thu, Mar 19, 2020 at 11:04:21AM +0100, Jiri Slaby wrote: > After commit f651c8b05542, virtio_gpu_create_object allocates too small > space to fit everything in. It is because it allocates struct > virtio_gpu_object, but should allocate a newly added struct > virtio_gpu_object_shmem which has 2

[PATCH] drm/virtio: fix OOB in virtio_gpu_object_create

2020-03-19 Thread Jiri Slaby
After commit f651c8b05542, virtio_gpu_create_object allocates too small space to fit everything in. It is because it allocates struct virtio_gpu_object, but should allocate a newly added struct virtio_gpu_object_shmem which has 2 more members. So fix that by using correct type in

Re: [PATCH 63/70] x86/vmware: Add VMware specific handling for VMMCALL under SEV-ES

2020-03-19 Thread Thomas Hellstrom via Virtualization
On Thu, 2020-03-19 at 10:14 +0100, Joerg Roedel wrote: > From: Doug Covelli > > This change adds VMware specific handling for #VC faults caused by > VMMCALL instructions. > > Signed-off-by: Doug Covelli > Signed-off-by: Tom Lendacky > [ jroe...@suse.de: - Adapt to different paravirt interface

Re: [PATCH v3] drm/bochs: downgrade pci_request_region failure from error to warning

2020-03-19 Thread Daniel Vetter
On Wed, Mar 18, 2020 at 7:49 AM Gerd Hoffmann wrote: > > On Tue, Mar 17, 2020 at 05:49:41PM +0100, Daniel Vetter wrote: > > On Fri, Mar 13, 2020 at 09:41:52AM +0100, Gerd Hoffmann wrote: > > > Shutdown of firmware framebuffer has a bunch of problems. Because > > > of this the framebuffer region

[PATCH 48/70] x86/sev-es: Handle MMIO String Instructions

2020-03-19 Thread Joerg Roedel
From: Joerg Roedel Add handling for emulation the MOVS instruction on MMIO regions, as done by the memcpy_toio() and memcpy_fromio() functions. Signed-off-by: Joerg Roedel --- arch/x86/kernel/sev-es.c | 78 1 file changed, 78 insertions(+) diff --git

[PATCH 46/70] x86/sev-es: Filter exceptions not supported from user-space

2020-03-19 Thread Joerg Roedel
From: Joerg Roedel Currently only CPUID caused #VC exceptions are supported from user-space. Filter the others out early. Signed-off-by: Joerg Roedel --- arch/x86/kernel/sev-es.c | 24 1 file changed, 24 insertions(+) diff --git a/arch/x86/kernel/sev-es.c

[PATCH 68/70] x86/sev-es: Support CPU offline/online

2020-03-19 Thread Joerg Roedel
From: Joerg Roedel Add a play_dead handler when running under SEV-ES. This is needed because the hypervisor can't deliver an SIPI request to restart the AP. Instead the kernel has to issue a VMGEXIT to halt the VCPU. When the hypervisor would deliver and SIPI is wakes up the VCPU instead.

[PATCH 70/70] x86/sev-es: Add NMI state tracking

2020-03-19 Thread Joerg Roedel
From: Joerg Roedel Keep NMI state in SEV-ES code so the kernel can re-enable NMIs for the vCPU when it reaches IRET. Signed-off-by: Joerg Roedel --- arch/x86/entry/entry_64.S | 48 + arch/x86/include/asm/sev-es.h | 27 +++

[PATCH 66/70] x86/head/64: Don't call verify_cpu() on starting APs

2020-03-19 Thread Joerg Roedel
From: Joerg Roedel The APs are not ready to handle exceptions when verify_cpu() is called in secondary_startup_64. Signed-off-by: Joerg Roedel --- arch/x86/include/asm/realmode.h | 1 + arch/x86/kernel/head_64.S | 1 + arch/x86/realmode/init.c| 6 ++ 3 files changed, 8

[PATCH 47/70] x86/sev-es: Handle MMIO events

2020-03-19 Thread Joerg Roedel
From: Tom Lendacky Add handler for VC exceptions caused by MMIO intercepts. These intercepts come along as nested page faults on pages with reserved bits set. TODO: - Add return values of helper functions - Check permissions on page-table walks - Check data segments

[PATCH 49/70] x86/sev-es: Handle MSR events

2020-03-19 Thread Joerg Roedel
From: Tom Lendacky Implement a handler for #VC exceptions caused by RDMSR/WRMSR instructions. Signed-off-by: Tom Lendacky [ jroe...@suse.de: Adapt to #VC handling infrastructure ] Co-developed-by: Joerg Roedel Signed-off-by: Joerg Roedel --- arch/x86/kernel/sev-es.c | 32

[PATCH 51/70] x86/sev-es: Handle WBINVD Events

2020-03-19 Thread Joerg Roedel
From: Tom Lendacky Implement a handler for #VC exceptions caused by WBINVD instructions. Signed-off-by: Tom Lendacky [ jroe...@suse.de: Adapt to #VC handling framework ] Co-developed-by: Joerg Roedel Signed-off-by: Joerg Roedel --- arch/x86/kernel/sev-es.c | 9 + 1 file changed, 9

[PATCH 40/70] x86/sev-es: Setup per-cpu GHCBs for the runtime handler

2020-03-19 Thread Joerg Roedel
From: Tom Lendacky The runtime handler needs a GHCB per CPU. Set them up and map them unencrypted. Signed-off-by: Tom Lendacky Signed-off-by: Joerg Roedel --- arch/x86/include/asm/mem_encrypt.h | 2 ++ arch/x86/kernel/sev-es.c | 28 +++-

[PATCH 58/70] x86/sev-es: Handle VMMCALL Events

2020-03-19 Thread Joerg Roedel
From: Tom Lendacky Implement a handler for #VC exceptions caused by VMMCALL instructions. This patch is only a starting point, VMMCALL emulation under SEV-ES needs further hypervisor-specific changes to provide additional state. Signed-off-by: Tom Lendacky [ jroe...@suse.de: Adapt to #VC

[PATCH 44/70] x86/sev-es: Handle instruction fetches from user-space

2020-03-19 Thread Joerg Roedel
From: Joerg Roedel When a #VC exception is triggered by user-space the instruction decoder needs to read the instruction bytes from user addresses. Enhance vc_decode_insn() to safely fetch kernel and user instructions. Signed-off-by: Joerg Roedel --- arch/x86/kernel/sev-es.c | 31

[PATCH 69/70] x86/cpufeature: Add SEV_ES_GUEST CPU Feature

2020-03-19 Thread Joerg Roedel
From: Joerg Roedel The feature bit will indicate whether the kernel runs as an SEV-ES guest. This can be used to apply alternatives at boot for SEV-ES guests and provides a way for user-space to detect whether it runs as an SEV-ES guest. Signed-off-by: Joerg Roedel ---

[PATCH 52/70] x86/sev-es: Handle RDTSC Events

2020-03-19 Thread Joerg Roedel
From: Tom Lendacky Implement a handler for #VC exceptions caused by RDTSC instructions. Signed-off-by: Tom Lendacky [ jroe...@suse.de: Adapt to #VC handling infrastructure ] Co-developed-by: Joerg Roedel Signed-off-by: Joerg Roedel --- arch/x86/kernel/sev-es.c | 20 1

[PATCH 56/70] x86/sev-es: Handle MONITOR/MONITORX Events

2020-03-19 Thread Joerg Roedel
From: Tom Lendacky Implement a handler for #VC exceptions caused by MONITOR and MONITORX instructions. Signed-off-by: Tom Lendacky [ jroe...@suse.de: Adapt to #VC handling infrastructure ] Co-developed-by: Joerg Roedel Signed-off-by: Joerg Roedel --- arch/x86/kernel/sev-es.c | 19

[PATCH 60/70] x86/sev-es: Handle #DB Events

2020-03-19 Thread Joerg Roedel
From: Joerg Roedel Handle #VC exceptions caused by #DB exceptions in the guest. Do not forward them to the hypervisor and handle them with do_debug() instead. Signed-off-by: Joerg Roedel --- arch/x86/kernel/sev-es.c | 12 1 file changed, 12 insertions(+) diff --git

[PATCH 43/70] x86/sev-es: Wire up existing #VC exit-code handlers

2020-03-19 Thread Joerg Roedel
From: Joerg Roedel Re-use the handlers for CPUID and IOIO caused #VC exceptions in the early boot handler. Signed-off-by: Joerg Roedel --- arch/x86/kernel/sev-es-shared.c | 7 +++ arch/x86/kernel/sev-es.c| 6 ++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git

[PATCH 54/70] x86/sev-es: Handle INVD Events

2020-03-19 Thread Joerg Roedel
From: Tom Lendacky Implement a handler for #VC exceptions caused by INVD instructions. Since Linux should never use INVD, just mark it as unsupported. Signed-off-by: Tom Lendacky [ jroe...@suse.de: Adapt to #VC handling infrastructure ] Co-developed-by: Joerg Roedel Signed-off-by: Joerg

[PATCH 57/70] x86/sev-es: Handle MWAIT/MWAITX Events

2020-03-19 Thread Joerg Roedel
From: Tom Lendacky Implement a handler for #VC exceptions caused by MWAIT and MWAITX instructions. Signed-off-by: Tom Lendacky [ jroe...@suse.de: Adapt to #VC handling infrastructure ] Co-developed-by: Joerg Roedel Signed-off-by: Joerg Roedel --- arch/x86/kernel/sev-es.c | 12

[PATCH 42/70] x86/sev-es: Support nested #VC exceptions

2020-03-19 Thread Joerg Roedel
From: Joerg Roedel Handle #VC exceptions that happen while the GHCB is in use. This can happen when an NMI happens in the #VC exception handler and the NMI handler causes a #VC exception itself. Save the contents of the GHCB when nesting is detected and restore it when the GHCB is no longer

[PATCH 55/70] x86/sev-es: Handle RDTSCP Events

2020-03-19 Thread Joerg Roedel
From: Joerg Roedel Extend the RDTSC handler to also handle RDTSCP events. Signed-off-by: Joerg Roedel --- arch/x86/kernel/sev-es.c | 15 +++ 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/sev-es.c b/arch/x86/kernel/sev-es.c index

[PATCH 62/70] x86/kvm: Add KVM specific VMMCALL handling under SEV-ES

2020-03-19 Thread Joerg Roedel
From: Tom Lendacky Implement the callbacks to copy the processor state required by KVM to the GHCB. Signed-off-by: Tom Lendacky [ jroe...@suse.de: - Split out of a larger patch - Adapt to different callback functions ] Co-developed-by: Joerg Roedel Signed-off-by: Joerg

[PATCH 50/70] x86/sev-es: Handle DR7 read/write events

2020-03-19 Thread Joerg Roedel
From: Tom Lendacky Add code to handle #VC exceptions on DR7 register reads and writes. This is needed early because show_regs() reads DR7 to print it out. Signed-off-by: Tom Lendacky [ jroe...@suse.de: - Adapt to #VC handling framework - Support early usage ]

[PATCH 65/70] x86/realmode: Setup AP jump table

2020-03-19 Thread Joerg Roedel
From: Tom Lendacky Setup the AP jump table to point to the SEV-ES trampoline code so that the APs can boot. Signed-off-by: Tom Lendacky [ jroe...@suse.de: - Adapted to different code base - Moved AP table setup from SIPI sending path to real-mode setup

[PATCH 67/70] x86/head/64: Rename start_cpu0

2020-03-19 Thread Joerg Roedel
From: Joerg Roedel For SEV-ES this entry point will be used for restarting APs after they have been offlined. Remove the '0' from the name to reflect that. Signed-off-by: Joerg Roedel --- arch/x86/include/asm/cpu.h | 2 +- arch/x86/kernel/head_32.S | 4 ++-- arch/x86/kernel/head_64.S | 6

[PATCH 64/70] x86/realmode: Add SEV-ES specific trampoline entry point

2020-03-19 Thread Joerg Roedel
From: Joerg Roedel The code at the trampoline entry point is executed in real-mode. In real-mode #VC exceptions can't be handled, so anything that might cause such an exception must be avoided. In the standard trampoline entry code this is the WBINVD instruction and the call to verify_cpu(),

[PATCH 45/70] x86/sev-es: Harden runtime #VC handler for exceptions from user-space

2020-03-19 Thread Joerg Roedel
From: Joerg Roedel Send SIGBUS to the user-space process that caused the #VC exception instead of killing the machine. Also ratelimit the error messages so that user-space can't flood the kernel log. Signed-off-by: Joerg Roedel --- arch/x86/kernel/sev-es.c | 32

[PATCH 59/70] x86/sev-es: Handle #AC Events

2020-03-19 Thread Joerg Roedel
From: Joerg Roedel Implement a handler for #VC exceptions caused by #AC exceptions. The #AC exception is just forwarded to do_alignment_check() and not pushed down to the hypervisor, as requested by the SEV-ES GHCB Standardization Specification. Signed-off-by: Joerg Roedel ---

[PATCH 53/70] x86/sev-es: Handle RDPMC Events

2020-03-19 Thread Joerg Roedel
From: Tom Lendacky Implement a handler for #VC exceptions caused by RDPMC instructions. Signed-off-by: Tom Lendacky [ jroe...@suse.de: Adapt to #VC handling infrastructure ] Co-developed-by: Joerg Roedel Signed-off-by: Joerg Roedel --- arch/x86/kernel/sev-es.c | 22 ++ 1

[PATCH 63/70] x86/vmware: Add VMware specific handling for VMMCALL under SEV-ES

2020-03-19 Thread Joerg Roedel
From: Doug Covelli This change adds VMware specific handling for #VC faults caused by VMMCALL instructions. Signed-off-by: Doug Covelli Signed-off-by: Tom Lendacky [ jroe...@suse.de: - Adapt to different paravirt interface ] Co-developed-by: Joerg Roedel Signed-off-by: Joerg Roedel ---

[PATCH 11/70] x86/boot/compressed/64: Disable red-zone usage

2020-03-19 Thread Joerg Roedel
From: Joerg Roedel The x86-64 ABI defines a red-zone on the stack: The 128-byte area beyond the location pointed to by %rsp is considered to be reserved and shall not be modified by signal or interrupt handlers. 10 Therefore, functions may use this area for temporary data that is not

[PATCH 18/70] x86/boot/compressed/64: Add stage1 #VC handler

2020-03-19 Thread Joerg Roedel
From: Joerg Roedel Add the first handler for #VC exceptions. At stage 1 there is no GHCB yet becaue we might still be on the EFI page table and thus can't map memory unencrypted. The stage 1 handler is limited to the MSR based protocol to talk to the hypervisor and can only support CPUID

[PATCH 21/70] x86/boot/compressed/64: Add function to map a page unencrypted

2020-03-19 Thread Joerg Roedel
From: Joerg Roedel This function is needed to map the GHCB for SEV-ES guests. The GHCB is used for communication with the hypervisor, so its content must not be encrypted. Signed-off-by: Joerg Roedel --- arch/x86/boot/compressed/ident_map_64.c | 125

[PATCH 19/70] x86/boot/compressed/64: Call set_sev_encryption_mask earlier

2020-03-19 Thread Joerg Roedel
From: Joerg Roedel Call set_sev_encryption_mask() while still on the stage 1 #VC-handler, because the stage 2 handler needs our own page-tables to be set up, to which calling set_sev_encryption_mask() is a prerequisite. Signed-off-by: Joerg Roedel --- arch/x86/boot/compressed/head_64.S |

[PATCH 12/70] x86/boot/compressed/64: Add IDT Infrastructure

2020-03-19 Thread Joerg Roedel
From: Joerg Roedel Add code needed to setup an IDT in the early pre-decompression boot-code. The IDT is loaded first in startup_64, which is after EfiExitBootServices() has been called, and later reloaded when the kernel image has been relocated to the end of the decompression area. This allows

[PATCH 33/70] x86/head/64: Build k/head64.c with -fno-stack-protector

2020-03-19 Thread Joerg Roedel
From: Joerg Roedel The code inserted by the stack protector does not work in the early boot environment because it uses the GS segment, at least with memory encryption enabled. Make sure the early code is compiled without this feature enabled. Signed-off-by: Joerg Roedel ---

[PATCH 28/70] x86/idt: Move two function from k/idt.c to i/a/desc.h

2020-03-19 Thread Joerg Roedel
From: Joerg Roedel Move these two functions from kernel/idt.c to include/asm/desc.h: * init_idt_data() * idt_init_desc() These functions are needed to setup IDT entries very early and need to be called from head64.c. To be usable this early these functions need to be compiled

[PATCH 37/70] x86/sev-es: Compile early handler code into kernel image

2020-03-19 Thread Joerg Roedel
From: Joerg Roedel Setup sev-es.c and include the code from the pre-decompression stage to also build it into the image of the running kernel. Temporarily add __maybe_unused annotations to avoid build warnings until the functions get used. Signed-off-by: Joerg Roedel ---

[PATCH 14/70] x86/boot/compressed/64: Add page-fault handler

2020-03-19 Thread Joerg Roedel
From: Joerg Roedel Install a page-fault handler to add an identity mapping to addresses not yet mapped. Also do some checking whether the error code is sane. This makes non SEV-ES machines use the exception handling infrastructure in the pre-decompressions boot code too, making it less likely

[PATCH 31/70] x86/head/64: Load segment registers earlier

2020-03-19 Thread Joerg Roedel
From: Joerg Roedel Make sure segments are properly set up before setting up an IDT and doing anything that might cause a #VC exception. This is later needed for early exception handling. Signed-off-by: Joerg Roedel --- arch/x86/kernel/head_64.S | 52 +++ 1

[PATCH 02/70] KVM: SVM: Add GHCB Accessor functions

2020-03-19 Thread Joerg Roedel
From: Joerg Roedel Building a correct GHCB for the hypervisor requires setting valid bits in the GHCB. Simplify that process by providing accessor functions to set values and to update the valid bitmap. Signed-off-by: Joerg Roedel --- arch/x86/include/asm/svm.h | 61

[PATCH 04/70] x86/traps: Move some definitions to

2020-03-19 Thread Joerg Roedel
From: Joerg Roedel Move the definition of x86 trap vector numbers and the page-fault error code bits to the new header file asm/trap_defs.h. This makes it easier to include them into pre-decompression boot code. No functional changes. Signed-off-by: Joerg Roedel ---

[PATCH 06/70] x86/umip: Factor out instruction fetch

2020-03-19 Thread Joerg Roedel
From: Joerg Roedel Factor out the code to fetch the instruction from user-space to a helper function. Signed-off-by: Joerg Roedel --- arch/x86/include/asm/insn-eval.h | 2 ++ arch/x86/kernel/umip.c | 26 +- arch/x86/lib/insn-eval.c | 38

[PATCH 05/70] x86/insn: Make inat-tables.c suitable for pre-decompression code

2020-03-19 Thread Joerg Roedel
From: Joerg Roedel The inat-tables.c file has some arrays in it that contain pointers to other arrays. These pointers need to be relocated when the kernel image is moved to a different location. The pre-decompression boot-code has no support for applying ELF relocations, so initialize these

[PATCH 13/70] x86/boot/compressed/64: Rename kaslr_64.c to ident_map_64.c

2020-03-19 Thread Joerg Roedel
From: Joerg Roedel The file contains only code related to identity mapped page-tables. Rename the file and compile it always in. Signed-off-by: Joerg Roedel --- arch/x86/boot/compressed/Makefile| 2 +- .../boot/compressed/{kaslr_64.c => ident_map_64.c} | 12

[PATCH 24/70] x86/fpu: Move xgetbv()/xsetbv() into separate header

2020-03-19 Thread Joerg Roedel
From: Joerg Roedel The xgetbv() function is needed in pre-decompression boot code, but asm/fpu/internal.h can't be included there directly. Doing so opens the door to include-hell due to various include-magic in boot/compressed/misc.h. Avoid that by moving xgetbv()/xsetbv() to a separate header

[PATCH 34/70] x86/head/64: Load IDT earlier

2020-03-19 Thread Joerg Roedel
From: Joerg Roedel Load the IDT right after switching to virtual addresses in head_64.S so that the kernel can handle #VC exceptions. Signed-off-by: Joerg Roedel --- arch/x86/kernel/head64.c | 15 +++ arch/x86/kernel/head_64.S | 17 + 2 files changed, 32

[PATCH 29/70] x86/head/64: Install boot GDT

2020-03-19 Thread Joerg Roedel
From: Joerg Roedel Handling exceptions during boot requires a working GDT. The kernel GDT is not yet ready for use, so install a temporary boot GDT. Signed-off-by: Joerg Roedel --- arch/x86/kernel/head_64.S | 32 1 file changed, 32 insertions(+) diff --git

[PATCH 39/70] x86/sev-es: Setup GHCB based boot #VC handler

2020-03-19 Thread Joerg Roedel
From: Joerg Roedel Add the infrastructure to handle #VC exceptions when the kernel runs on virtual addresses and has a GHCB mapped. This handler will be used until the runtime #VC handler takes over. Signed-off-by: Joerg Roedel --- arch/x86/include/asm/segment.h | 2 +-

[PATCH 61/70] x86/paravirt: Allow hypervisor specific VMMCALL handling under SEV-ES

2020-03-19 Thread Joerg Roedel
From: Joerg Roedel Add two new paravirt callbacks to provide hypervisor specific processor state in the GHCB and to copy state from the hypervisor back to the processor. Signed-off-by: Joerg Roedel --- arch/x86/include/asm/x86_init.h | 16 +++- arch/x86/kernel/sev-es.c| 12

Re: [PATCH V6 8/8] virtio: Intel IFC VF driver for VDPA

2020-03-19 Thread Jason Wang
On 2020/3/18 下午8:22, Jason Gunthorpe wrote: On Wed, Mar 18, 2020 at 04:03:27PM +0800, Jason Wang wrote: From: Zhu Lingshan + +static int ifcvf_vdpa_attach(struct ifcvf_adapter *adapter) +{ + int ret; + + adapter->vdpa_dev = vdpa_alloc_device(adapter->dev, adapter->dev, +

[PATCH 16/70] x86/boot/compressed/64: Don't pre-map memory in KASLR code

2020-03-19 Thread Joerg Roedel
From: Joerg Roedel With the page-fault handler in place the identity mapping can be built on-demand. So remove the code which manually creates the mappings and unexport/remove the functions used for it. Signed-off-by: Joerg Roedel --- arch/x86/boot/compressed/ident_map_64.c | 16

[PATCH 25/70] x86/sev-es: Add CPUID handling to #VC handler

2020-03-19 Thread Joerg Roedel
From: Tom Lendacky Handle #VC exceptions caused by CPUID instructions. These happen in early boot code when the KASLR code checks for RDTSC. Signed-off-by: Tom Lendacky [ jroe...@suse.de: Adapt to #VC handling framework ] Co-developed-by: Joerg Roedel Signed-off-by: Joerg Roedel ---

[PATCH 26/70] x86/idt: Move IDT to data segment

2020-03-19 Thread Joerg Roedel
From: Joerg Roedel With SEV-ES, exception handling is needed very early, even before the kernel has cleared the bss segment. In order to prevent clearing the currently used IDT, move the IDT to the data segment. Signed-off-by: Joerg Roedel --- arch/x86/kernel/idt.c | 8 ++-- 1 file

[PATCH 07/70] x86/umip: Factor out instruction decoding

2020-03-19 Thread Joerg Roedel
From: Joerg Roedel Factor out the code used to decode an instruction with the correct address and operand sizes to a helper function. Signed-off-by: Joerg Roedel --- arch/x86/include/asm/insn-eval.h | 2 ++ arch/x86/kernel/umip.c | 23 +--- arch/x86/lib/insn-eval.c

[PATCH 15/70] x86/boot/compressed/64: Always switch to own page-table

2020-03-19 Thread Joerg Roedel
From: Joerg Roedel When booted through startup_64 the kernel keeps running on the EFI page-table until the KASLR code sets up its own page-table. Without KASLR the pre-decompression boot code never switches off the EFI page-table. Change that by unconditionally switching to our own page-table

[PATCH 41/70] x86/sev-es: Add Runtime #VC Exception Handler

2020-03-19 Thread Joerg Roedel
From: Tom Lendacky Add the handler for #VC exceptions invoked at runtime. Signed-off-by: Tom Lendacky Signed-off-by: Joerg Roedel --- arch/x86/entry/entry_64.S| 4 ++ arch/x86/include/asm/traps.h | 7 arch/x86/kernel/idt.c| 4 +- arch/x86/kernel/sev-es.c | 77

[RFC PATCH 00/70 v2] x86: SEV-ES Guest Support

2020-03-19 Thread Joerg Roedel
Hi, here is an updated version of the patch-set to enable Linux to run as a guest in an SEV-ES enabled Hypervisor. The first version can be found here: https://lore.kernel.org/lkml/20200211135256.24617-1-j...@8bytes.org/ The first post also includes a more elaborate description of the

[PATCH 36/70] x86/sev-es: Add SEV-ES Feature Detection

2020-03-19 Thread Joerg Roedel
From: Joerg Roedel Add the sev_es_active function for checking whether SEV-ES is enabled. Also cache the value of MSR_AMD64_SEV at boot to speed up the feature checking in the running code. Signed-off-by: Joerg Roedel --- arch/x86/include/asm/mem_encrypt.h | 3 +++

[PATCH 10/70] x86/boot/compressed: Fix debug_puthex() parameter type

2020-03-19 Thread Joerg Roedel
From: Joerg Roedel In the CONFIG_X86_VERBOSE_BOOTUP=Y case the debug_puthex() macro just turns into __puthex, which takes 'unsigned long' as parameter. But in the CONFIG_X86_VERBOSE_BOOTUP=N case it is a function which takes 'unsigned char *', causing compile warnings when the function is used.

[PATCH 30/70] x86/head/64: Reload GDT after switch to virtual addresses

2020-03-19 Thread Joerg Roedel
From: Joerg Roedel Reload the GDT after switching to virtual addresses to make sure it will not go away when the lower mappings are removed. Signed-off-by: Joerg Roedel --- arch/x86/kernel/head_64.S | 5 + 1 file changed, 5 insertions(+) diff --git a/arch/x86/kernel/head_64.S

[PATCH 03/70] x86/cpufeatures: Add SEV-ES CPU feature

2020-03-19 Thread Joerg Roedel
From: Tom Lendacky Add CPU feature detection for Secure Encrypted Virtualization with Encrypted State. This feature enhances SEV by also encrypting the guest register state, making it in-accessible to the hypervisor. Signed-off-by: Tom Lendacky Signed-off-by: Joerg Roedel ---

[PATCH 23/70] x86/sev-es: Add support for handling IOIO exceptions

2020-03-19 Thread Joerg Roedel
From: Tom Lendacky Add support for decoding and handling #VC exceptions for IOIO events. Signed-off-by: Tom Lendacky [ jroe...@suse.de: Adapted code to #VC handling framework ] Co-developed-by: Joerg Roedel Signed-off-by: Joerg Roedel --- arch/x86/boot/compressed/sev-es.c | 32 +

[PATCH 38/70] x86/sev-es: Setup early #VC handler

2020-03-19 Thread Joerg Roedel
From: Joerg Roedel Setup an early handler for #VC exceptions. There is no GHCB mapped yet, so just re-use the vc_no_ghcb_handler. It can only handle CPUID exit-codes, but that should be enough to get the kernel through verify_cpu() and __startup_64() until it runs on virtual addresses.

[PATCH 22/70] x86/boot/compressed/64: Setup GHCB Based VC Exception handler

2020-03-19 Thread Joerg Roedel
From: Joerg Roedel Install an exception handler for #VC exception that uses a GHCB. Also add the infrastructure for handling different exit-codes by decoding the instruction that caused the exception and error handling. Signed-off-by: Joerg Roedel --- arch/x86/Kconfig

[PATCH 32/70] x86/head/64: Switch to initial stack earlier

2020-03-19 Thread Joerg Roedel
From: Joerg Roedel Make sure there is a stack once the kernel runs from virual addresses. At this stage any secondary CPU which boots will have lost its stack because the kernel switched to a new page-table which does not map the real-mode stack anymore. This is also needed for handling early

[PATCH 08/70] x86/insn: Add insn_get_modrm_reg_off()

2020-03-19 Thread Joerg Roedel
From: Joerg Roedel Add a function to the instruction decoder which returns the pt_regs offset of the register specified in the reg field of the modrm byte. Signed-off-by: Joerg Roedel --- arch/x86/include/asm/insn-eval.h | 1 + arch/x86/lib/insn-eval.c | 23 +++ 2

[PATCH 01/70] KVM: SVM: Add GHCB definitions

2020-03-19 Thread Joerg Roedel
From: Tom Lendacky Extend the vmcb_safe_area with SEV-ES fields and add a new 'struct ghcb' which will be used for guest-hypervisor communication. Signed-off-by: Tom Lendacky Signed-off-by: Joerg Roedel --- arch/x86/include/asm/svm.h | 42 ++ 1 file

[PATCH 20/70] x86/boot/compressed/64: Check return value of kernel_ident_mapping_init()

2020-03-19 Thread Joerg Roedel
From: Joerg Roedel The function can fail to create an identity mapping, check for that and bail out if it happens. Signed-off-by: Joerg Roedel --- arch/x86/boot/compressed/ident_map_64.c | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git

[PATCH 35/70] x86/head/64: Move early exception dispatch to C code

2020-03-19 Thread Joerg Roedel
From: Joerg Roedel Move the assembly coded dispatch between page-faults and all other exceptions to C code to make it easier to maintain and extend. Also change the return-type of early_make_pgtable() to bool and make it static. Signed-off-by: Joerg Roedel --- arch/x86/include/asm/pgtable.h

[PATCH 17/70] x86/boot/compressed/64: Change add_identity_map() to take start and end

2020-03-19 Thread Joerg Roedel
From: Joerg Roedel Changing the function to take start and end as parameters instead of start and size simplifies the callers, which don't need to calculate the size if they already have start and end. Signed-off-by: Joerg Roedel --- arch/x86/boot/compressed/ident_map_64.c | 15

Re: [PATCH 13/15] iommu/qcom: Use accessor functions for iommu private data

2020-03-19 Thread Joerg Roedel
Hi Jean-Philippe, On Mon, Mar 16, 2020 at 04:52:23PM +0100, Jean-Philippe Brucker wrote: > Should be: > > if (!dev_iommu_priv_set(dev)) Thanks a lot for your reviews! I made the changes to arm-smmu and the qcom driver you requested and will post a new version later today. Thanks,

Re: [PATCH v1 0/3] drm: drm_encoder_init() => drm_encoder_init_funcs()

2020-03-19 Thread Sam Ravnborg
On Fri, Mar 13, 2020 at 09:17:41PM +0100, Sam Ravnborg wrote: > Thomas Zimmermann had made a nice patch-set that introduced > drm_simple_encoder_init() which is already present in drm-misc-next. > > While looking at this it was suddenly obvious to me that > this was functionalty that really

Re: [PATCH V6 8/8] virtio: Intel IFC VF driver for VDPA

2020-03-19 Thread Jason Gunthorpe
On Thu, Mar 19, 2020 at 04:14:37PM +0800, Jason Wang wrote: > > On 2020/3/18 下午8:22, Jason Gunthorpe wrote: > > On Wed, Mar 18, 2020 at 04:03:27PM +0800, Jason Wang wrote: > > > From: Zhu Lingshan > > > + > > > +static int ifcvf_vdpa_attach(struct ifcvf_adapter *adapter) > > > +{ > > > + int

Re: [PATCH 70/70] x86/sev-es: Add NMI state tracking

2020-03-19 Thread Andy Lutomirski
On Thu, Mar 19, 2020 at 2:14 AM Joerg Roedel wrote: > > From: Joerg Roedel > > Keep NMI state in SEV-ES code so the kernel can re-enable NMIs for the > vCPU when it reaches IRET. IIRC I suggested just re-enabling NMI in C from do_nmi(). What was wrong with that approach? > +#ifdef

Re: [PATCH 41/70] x86/sev-es: Add Runtime #VC Exception Handler

2020-03-19 Thread Andy Lutomirski
On Thu, Mar 19, 2020 at 2:14 AM Joerg Roedel wrote: > > From: Tom Lendacky > > Add the handler for #VC exceptions invoked at runtime. If I read this correctly, this does not use IST. If that's true, I don't see how this can possibly work. There at least two nasty cases that come to mind: 1.

Re: [PATCH 42/70] x86/sev-es: Support nested #VC exceptions

2020-03-19 Thread Andy Lutomirski
On Thu, Mar 19, 2020 at 2:14 AM Joerg Roedel wrote: > > From: Joerg Roedel > > Handle #VC exceptions that happen while the GHCB is in use. This can > happen when an NMI happens in the #VC exception handler and the NMI > handler causes a #VC exception itself. Save the contents of the GHCB > when

Re: [PATCH 70/70] x86/sev-es: Add NMI state tracking

2020-03-19 Thread Joerg Roedel
Hi Andy, On Thu, Mar 19, 2020 at 08:35:59AM -0700, Andy Lutomirski wrote: > On Thu, Mar 19, 2020 at 2:14 AM Joerg Roedel wrote: > > > > From: Joerg Roedel > > > > Keep NMI state in SEV-ES code so the kernel can re-enable NMIs for the > > vCPU when it reaches IRET. > > IIRC I suggested just

Re: [PATCH 41/70] x86/sev-es: Add Runtime #VC Exception Handler

2020-03-19 Thread Joerg Roedel
On Thu, Mar 19, 2020 at 08:44:03AM -0700, Andy Lutomirski wrote: > On Thu, Mar 19, 2020 at 2:14 AM Joerg Roedel wrote: > > > > From: Tom Lendacky > > > > Add the handler for #VC exceptions invoked at runtime. > > If I read this correctly, this does not use IST. If that's true, I > don't see

Re: [PATCH v1 0/3] drm: drm_encoder_init() => drm_encoder_init_funcs()

2020-03-19 Thread Sam Ravnborg
On Thu, Mar 19, 2020 at 03:19:54PM +0100, Sam Ravnborg wrote: > On Fri, Mar 13, 2020 at 09:17:41PM +0100, Sam Ravnborg wrote: > > Thomas Zimmermann had made a nice patch-set that introduced > > drm_simple_encoder_init() which is already present in drm-misc-next. > > > > While looking at this it

Re: [PATCH 42/70] x86/sev-es: Support nested #VC exceptions

2020-03-19 Thread Joerg Roedel
On Thu, Mar 19, 2020 at 08:46:36AM -0700, Andy Lutomirski wrote: > This can't possibly end well. Maybe have a little percpu list of > GHCBs and make sure there are enough for any possible nesting? Yeah, it is not entirely robust yet. Without NMI nesting the number of possible #VC nesting levels

Re: [PATCH 70/70] x86/sev-es: Add NMI state tracking

2020-03-19 Thread Andy Lutomirski
On Thu, Mar 19, 2020 at 9:07 AM Joerg Roedel wrote: > > Hi Andy, > > On Thu, Mar 19, 2020 at 08:35:59AM -0700, Andy Lutomirski wrote: > > On Thu, Mar 19, 2020 at 2:14 AM Joerg Roedel wrote: > > > > > > From: Joerg Roedel > > > > > > Keep NMI state in SEV-ES code so the kernel can re-enable NMIs

Re: [PATCH 41/70] x86/sev-es: Add Runtime #VC Exception Handler

2020-03-19 Thread Andy Lutomirski
On Thu, Mar 19, 2020 at 9:24 AM Joerg Roedel wrote: > > On Thu, Mar 19, 2020 at 08:44:03AM -0700, Andy Lutomirski wrote: > > On Thu, Mar 19, 2020 at 2:14 AM Joerg Roedel wrote: > > > > > > From: Tom Lendacky > > > > > > Add the handler for #VC exceptions invoked at runtime. > > > > If I read

Re: [PATCH 70/70] x86/sev-es: Add NMI state tracking

2020-03-19 Thread Joerg Roedel
On Thu, Mar 19, 2020 at 11:40:39AM -0700, Andy Lutomirski wrote: > Nope. A nested NMI will reset the interrupted NMI's return frame to > cause it to run again when it's done. I don't think this will have > any real interaction with #VC. There's no longjmp() here. Ahh, so I misunderstood that

Re: [PATCH 41/70] x86/sev-es: Add Runtime #VC Exception Handler

2020-03-19 Thread Joerg Roedel
On Thu, Mar 19, 2020 at 11:43:20AM -0700, Andy Lutomirski wrote: > Or future generations could have enough hardware support for debugging > that #DB doesn't need to be intercepted or can be re-injected > correctly with the #DB vector. Yeah, the problem is, the GHCB spec suggests the

Re: [PATCH 70/70] x86/sev-es: Add NMI state tracking

2020-03-19 Thread Joerg Roedel
On Thu, Mar 19, 2020 at 06:53:29PM +0200, Mika Penttilä wrote: > > +SYM_CODE_START(sev_es_iret_user) > > > What makes kernel jump here? Can't see this referenced from anywhere? Sorry, it is just a left-over from a previous version of this patch (which implemented the single-step-over-iret).

Re: [PATCH] iommu/virtio: Reject IOMMU page granule larger than PAGE_SIZE

2020-03-19 Thread Alex Williamson
On Wed, 18 Mar 2020 17:14:05 +0100 Auger Eric wrote: > Hi, > > On 3/18/20 1:00 PM, Robin Murphy wrote: > > On 2020-03-18 11:40 am, Jean-Philippe Brucker wrote: > >> We don't currently support IOMMUs with a page granule larger than the > >> system page size. The IOVA allocator has a BUG_ON()

Re: [PATCH 70/70] x86/sev-es: Add NMI state tracking

2020-03-19 Thread Andy Lutomirski
On Thu, Mar 19, 2020 at 12:26 PM Joerg Roedel wrote: > > On Thu, Mar 19, 2020 at 11:40:39AM -0700, Andy Lutomirski wrote: > > > Nope. A nested NMI will reset the interrupted NMI's return frame to > > cause it to run again when it's done. I don't think this will have > > any real interaction