Re: [RFC PATCH 00/62] Linux as SEV-ES Guest Support

2020-02-11 Thread Andy Lutomirski
> On Feb 11, 2020, at 5:53 AM, Joerg Roedel wrote: > > >* Putting some NMI-load on the guest will make it crash usually > within a minute Suppose you do CPUID or some MMIO and get #VC. You fill in the GHCB to ask for help. Some time between when you start filling it out and when

Re: [PATCH V2 3/5] vDPA: introduce vDPA bus

2020-02-11 Thread Jason Wang
On 2020/2/11 下午9:47, Jason Gunthorpe wrote: On Mon, Feb 10, 2020 at 11:56:06AM +0800, Jason Wang wrote: +/** + * vdpa_register_device - register a vDPA device + * Callers must have a succeed call of vdpa_init_device() before. + * @vdev: the vdpa device to be registered to vDPA bus + * + *

Re: [PATCH 50/62] x86/sev-es: Handle VMMCALL Events

2020-02-11 Thread Andy Lutomirski
> On Feb 11, 2020, at 5:53 AM, Joerg Roedel wrote: > > 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.

Re: [PATCH 46/62] x86/sev-es: Handle INVD Events

2020-02-11 Thread Andy Lutomirski
> On Feb 11, 2020, at 5:53 AM, Joerg Roedel wrote: > > From: Tom Lendacky > > Implement a handler for #VC exceptions caused by INVD instructions. Uh, what? Surely the #VC code can have a catch-all OOPS path for things like this. Linux should never ever do INVD.

Re: [PATCH v2] drm/virtio: add drm_driver.release callback.

2020-02-11 Thread Daniel Vetter
On Mon, Feb 10, 2020 at 11:08:19AM +0100, Gerd Hoffmann wrote: > Split virtio_gpu_deinit(), move the drm shutdown and release to > virtio_gpu_release(). Also free vbufs in case we can't queue them. > > Signed-off-by: Gerd Hoffmann > --- > drivers/gpu/drm/virtio/virtgpu_drv.h | 1 + >

Re: vhost changes (batched) in linux-next after 12/13 trigger random crashes in KVM guests after reboot

2020-02-11 Thread Christian Borntraeger
On 11.02.20 10:33, Eugenio Pérez wrote: > On Mon, 2020-02-10 at 12:01 +0100, Christian Borntraeger wrote: >> >> On 10.02.20 10:47, Eugenio Perez Martin wrote: >>> Hi Christian. >>> >>> I'm not able to reproduce the failure with >>> eccb852f1fe6bede630e2e4f1a121a81e34354ab commit. Could you add

[PATCH v3] drm/bochs: add drm_driver.release callback.

2020-02-11 Thread Gerd Hoffmann
Call bochs_unload via drm_driver.release to make sure we release stuff when it is safe to do so. Use drm_dev_{enter,exit,unplug} to avoid touching hardware after device removal. Tidy up here and there. Signed-off-by: Gerd Hoffmann --- drivers/gpu/drm/bochs/bochs_drv.c | 6 +++---

Re: [PATCH] virtio: Work around frames incorrectly marked as gso

2020-02-11 Thread Michael S. Tsirkin
On Tue, Feb 11, 2020 at 07:42:37AM +, Anton Ivanov wrote: > On 11/02/2020 02:51, Jason Wang wrote: > > > > On 2020/2/11 上午12:55, Anton Ivanov wrote: > > > > > > > > > On 09/12/2019 10:48, anton.iva...@cambridgegreys.com wrote: > > > > From: Anton Ivanov > > > > > > > > Some of the frames

[PATCH v3] drm/virtio: add drm_driver.release callback.

2020-02-11 Thread Gerd Hoffmann
Split virtio_gpu_deinit(), move the drm shutdown and release to virtio_gpu_release(). Drop vqs_ready variable, instead use drm_dev_{enter,exit,unplug} to avoid touching hardware after device removal. Tidy up here and there. Signed-off-by: Gerd Hoffmann --- drivers/gpu/drm/virtio/virtgpu_drv.h

Re: [PATCH v2] drm/cirrus: add drm_driver.release callback.

2020-02-11 Thread Daniel Vetter
On Mon, Feb 10, 2020 at 10:53:10AM +0100, Gerd Hoffmann wrote: > Move final cleanups from cirrus_pci_remove() to the new callback. > Add drm_atomic_helper_shutdown() call to cirrus_pci_remove(). > > Set pointers to NULL after iounmap() and check them before using > them to make sure we don't

Re: vhost changes (batched) in linux-next after 12/13 trigger random crashes in KVM guests after reboot

2020-02-11 Thread Christian Borntraeger
On 11.02.20 10:56, Christian Borntraeger wrote: > > > On 11.02.20 10:33, Eugenio Pérez wrote: >> On Mon, 2020-02-10 at 12:01 +0100, Christian Borntraeger wrote: >>> >>> On 10.02.20 10:47, Eugenio Perez Martin wrote: Hi Christian. I'm not able to reproduce the failure with

[PATCH v3] drm/cirrus: add drm_driver.release callback.

2020-02-11 Thread Gerd Hoffmann
Move final cleanups from cirrus_pci_remove() to the new callback. Add drm_atomic_helper_shutdown() call to cirrus_pci_remove(). Use drm_dev_{enter,exit,unplug} to avoid touching hardware after device removal. Signed-off-by: Gerd Hoffmann --- drivers/gpu/drm/cirrus/cirrus.c | 43

[PATCH] drm/virtio: rework batching

2020-02-11 Thread Gerd Hoffmann
Drop the virtio_gpu_{disable,enable}_notify(). Add a new virtio_gpu_notify() call instead, which must be called whenever the driver wants make sure the host is notified needed. Drop notification from command submission. Add virtio_gpu_notify() calls everywhere instead. This results in more

Re: vhost changes (batched) in linux-next after 12/13 trigger random crashes in KVM guests after reboot

2020-02-11 Thread Christian Borntraeger
On 11.02.20 14:04, Eugenio Pérez wrote: > On Mon, 2020-02-10 at 12:01 +0100, Christian Borntraeger wrote: >> >> On 10.02.20 10:47, Eugenio Perez Martin wrote: >>> Hi Christian. >>> >>> I'm not able to reproduce the failure with >>> eccb852f1fe6bede630e2e4f1a121a81e34354ab commit. Could you add

[PATCH v4] drm/cirrus: add drm_driver.release callback.

2020-02-11 Thread Gerd Hoffmann
Move final cleanups from cirrus_pci_remove() to the new callback. Add drm_atomic_helper_shutdown() call to cirrus_pci_remove(). Use drm_dev_{enter,exit,unplug} to avoid touching hardware after device removal. v4: add changelog. v3: use drm_dev*. v2: stop touching hardware after pci_remove().

[PATCH 50/62] x86/sev-es: Handle VMMCALL Events

2020-02-11 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 38/62] x86/sev-es: Handle instruction fetches from user-space

2020-02-11 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 es_fetch_insn_byte() to safely fetch kernel and user instruction bytes. Signed-off-by: Joerg Roedel --- arch/x86/kernel/sev-es.c | 30

[PATCH 48/62] x86/sev-es: Handle MONITOR/MONITORX Events

2020-02-11 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 | 18

[PATCH 41/62] x86/sev-es: Handle MSR events

2020-02-11 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 57/62] x86/realmode: Setup AP jump table

2020-02-11 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 54/62] x86/kvm: Add KVM specific VMMCALL handling under SEV-ES

2020-02-11 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

Re: [PATCH v4] drm/cirrus: add drm_driver.release callback.

2020-02-11 Thread Daniel Vetter
On Tue, Feb 11, 2020 at 02:55:22PM +0100, Gerd Hoffmann wrote: > Move final cleanups from cirrus_pci_remove() to the new callback. > Add drm_atomic_helper_shutdown() call to cirrus_pci_remove(). > > Use drm_dev_{enter,exit,unplug} to avoid touching hardware after > device removal. > > v4: add

[PATCH 1/2] drm/virtio: fix virtio_gpu_execbuffer_ioctl locking

2020-02-11 Thread Gerd Hoffmann
Lockdep says we can't call vmemdup() while having objects reserved because it needs the mmap semaphore. So reorder the calls reserve the objects later. Signed-off-by: Gerd Hoffmann --- drivers/gpu/drm/virtio/virtgpu_ioctl.c | 20 ++-- 1 file changed, 10 insertions(+), 10

[PATCH 61/62] x86/cpufeature: Add SEV_ES_GUEST CPU Feature

2020-02-11 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 62/62] x86/sev-es: Add NMI state tracking

2020-02-11 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 52/62] x86/sev-es: Handle #DB Events

2020-02-11 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 46/62] x86/sev-es: Handle INVD Events

2020-02-11 Thread Joerg Roedel
From: Tom Lendacky Implement a handler for #VC exceptions caused by INVD 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 | 8 1 file changed, 8

[PATCH 56/62] x86/realmode: Add SEV-ES specific trampoline entry point

2020-02-11 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 44/62] x86/sev-es: Handle RDTSC Events

2020-02-11 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 59/62] x86/head/64: Rename start_cpu0

2020-02-11 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 60/62] x86/sev-es: Support CPU offline/online

2020-02-11 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 45/62] x86/sev-es: Handle RDPMC Events

2020-02-11 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 55/62] x86/vmware: Add VMware specific handling for VMMCALL under SEV-ES

2020-02-11 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 49/62] x86/sev-es: Handle MWAIT/MWAITX Events

2020-02-11 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 | 11 +++ 1

[PATCH 43/62] x86/sev-es: Handle WBINVD Events

2020-02-11 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 51/62] x86/sev-es: Handle #AC Events

2020-02-11 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 42/62] x86/sev-es: Handle DR7 read/write events

2020-02-11 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 47/62] x86/sev-es: Handle RDTSCP Events

2020-02-11 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 | 14 ++ 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/sev-es.c b/arch/x86/kernel/sev-es.c index

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

2020-02-11 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

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

2020-02-11 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

Re: [PATCH v4] drm/bochs: add drm_driver.release callback.

2020-02-11 Thread Daniel Vetter
On Tue, Feb 11, 2020 at 02:52:18PM +0100, Gerd Hoffmann wrote: > Call bochs_unload via drm_driver.release to make sure we release stuff > when it is safe to do so. Use drm_dev_{enter,exit,unplug} to avoid > touching hardware after device removal. Tidy up here and there. > > v4: add changelog. >

Re: [PATCH V2 3/5] vDPA: introduce vDPA bus

2020-02-11 Thread Jason Gunthorpe
On Mon, Feb 10, 2020 at 11:56:06AM +0800, Jason Wang wrote: > +/** > + * vdpa_register_device - register a vDPA device > + * Callers must have a succeed call of vdpa_init_device() before. > + * @vdev: the vdpa device to be registered to vDPA bus > + * > + * Returns an error when fail to add to

Re: vhost changes (batched) in linux-next after 12/13 trigger random crashes in KVM guests after reboot

2020-02-11 Thread Michael S. Tsirkin
On Tue, Feb 11, 2020 at 02:04:54PM +0100, Eugenio Pérez wrote: > On Mon, 2020-02-10 at 12:01 +0100, Christian Borntraeger wrote: > > > > On 10.02.20 10:47, Eugenio Perez Martin wrote: > > > Hi Christian. > > > > > > I'm not able to reproduce the failure with > > >

[PATCH v4] drm/virtio: add drm_driver.release callback.

2020-02-11 Thread Gerd Hoffmann
Split virtio_gpu_deinit(), move the drm shutdown and release to virtio_gpu_release(). Drop vqs_ready variable, instead use drm_dev_{enter,exit,unplug} to avoid touching hardware after device removal. Tidy up here and there. v4: add changelog. v3: use drm_dev_*(). Signed-off-by: Gerd Hoffmann

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

2020-02-11 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 35/62] x86/sev-es: Setup per-cpu GHCBs for the runtime handler

2020-02-11 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 | 25 -

[PATCH 20/62] x86/fpu: Move xgetbv()/xsetbv() into separate header

2020-02-11 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 39/62] x86/sev-es: Harden runtime #VC handler for exceptions from user-space

2020-02-11 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 07/62] x86/boot/compressed/64: Disable red-zone usage

2020-02-11 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 36/62] x86/sev-es: Add Runtime #VC Exception Handler

2020-02-11 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

[PATCH 28/62] x86/head/64: Switch to initial stack earlier

2020-02-11 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 40/62] x86/sev-es: Filter exceptions not supported from user-space

2020-02-11 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 12/62] x86/boot/compressed/64: Don't pre-map memory in KASLR code

2020-02-11 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 37/62] x86/sev-es: Wire up existing #VC exit-code handlers

2020-02-11 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 | 9 +++-- arch/x86/kernel/sev-es.c| 9 + 2 files changed, 12 insertions(+), 6 deletions(-) diff

[PATCH 08/62] x86/boot/compressed/64: Add IDT Infrastructure

2020-02-11 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 02/62] KVM: SVM: Add GHCB Accessor functions

2020-02-11 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 31/62] x86/sev-es: Add SEV-ES Feature Detection

2020-02-11 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 +++

[RFC PATCH 00/62] Linux as SEV-ES Guest Support

2020-02-11 Thread Joerg Roedel
Hi, here is the first public post of the patch-set to enable Linux to run under SEV-ES enabled hypervisors. The code is mostly feature-complete, but there are still a couple of bugs to fix. Nevertheless, given the size of the patch-set, I think it is about time to ask for initial feedback of the

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

2020-02-11 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 10/62] x86/boot/compressed/64: Add page-fault handler

2020-02-11 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 30/62] x86/head/64: Move early exception dispatch to C code

2020-02-11 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. Signed-off-by: Joerg Roedel --- arch/x86/kernel/head64.c | 20 arch/x86/kernel/head_64.S | 11 +-- 2 files

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

2020-02-11 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 01/62] KVM: SVM: Add GHCB definitions

2020-02-11 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 27/62] x86/head/64: Load segment registers earlier

2020-02-11 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 17/62] x86/boot/compressed/64: Add function to map a page unencrypted

2020-02-11 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 24/62] x86/idt: Split idt_data setup out of set_intr_gate()

2020-02-11 Thread Joerg Roedel
From: Joerg Roedel The code to setup idt_data is needed for early exception handling, but set_intr_gate() can't be used that early because it has pv-ops in its code path, which don't work that early. Split out the idt_data initialization part from set_intr_gate() so that it can be used

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

2020-02-11 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 09/62] x86/boot/compressed/64: Rename kaslr_64.c to ident_map_64.c

2020-02-11 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 +- arch/x86/boot/compressed/{kaslr_64.c => ident_map_64.c} | 9

[PATCH 29/62] x86/head/64: Load IDT earlier

2020-02-11 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/include/asm/desc.h | 1 + arch/x86/kernel/head64.c| 7 +++ arch/x86/kernel/head_64.S | 17

[PATCH 25/62] x86/head/64: Install boot GDT

2020-02-11 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 | 26 ++ 1 file changed, 26 insertions(+) diff --git

Re: [PATCH RFC] virtio_balloon: conservative balloon page shrinking

2020-02-11 Thread Tetsuo Handa
On 2020/02/10 16:27, Wang, Wei W wrote: >> Well, my comment is rather: "Do not try to reserve guest's memory. In other >> words, do not try to maintain balloons on the guest side. Since host would >> be able to cache file data on the host's cache, guests would be able to >> quickly fetch file data

Re: [PATCH V2 5/5] vdpasim: vDPA device simulator

2020-02-11 Thread Jason Gunthorpe
On Mon, Feb 10, 2020 at 11:56:08AM +0800, Jason Wang wrote: > + > +static struct vdpasim *vdpasim_create(void) > +{ > + struct vdpasim *vdpasim; > + struct virtio_net_config *config; > + struct vdpa_device *vdpa; > + struct device *dev; > + int ret = -ENOMEM; > + > +

[PATCH v4] drm/bochs: add drm_driver.release callback.

2020-02-11 Thread Gerd Hoffmann
Call bochs_unload via drm_driver.release to make sure we release stuff when it is safe to do so. Use drm_dev_{enter,exit,unplug} to avoid touching hardware after device removal. Tidy up here and there. v4: add changelog. v3: use drm_dev_*(). v2: move hardware deinit to pci_remove().

[PATCH 22/62] x86/sev-es: Add handler for MMIO events

2020-02-11 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 16/62] x86/boot/compressed/64: Check return value of kernel_ident_mapping_init()

2020-02-11 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 19/62] x86/sev-es: Add support for handling IOIO exceptions

2020-02-11 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 | 3 +

[PATCH 33/62] x86/sev-es: Setup early #VC handler

2020-02-11 Thread Joerg Roedel
From: Joerg Roedel Setup an early handler for #VC exceptions. There is no GHCB mapped yet, so just re-use the no_ghcb_vc_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 26/62] x86/head/64: Reload GDT after switch to virtual addresses

2020-02-11 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/62] x86/cpufeatures: Add SEV-ES CPU feature

2020-02-11 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/62] x86/idt: Move IDT to data segment

2020-02-11 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 | 2 +- 1 file changed, 1

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

2020-02-11 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 04/62] x86/traps: Move some definitions to

2020-02-11 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/62] x86/boot/compressed: Fix debug_puthex() parameter type

2020-02-11 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 14/62] x86/boot/compressed/64: Add stage1 #VC handler

2020-02-11 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 13/62] x86/boot/compressed/64: Change add_identity_map() to take start and end

2020-02-11 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

[PATCH 15/62] x86/boot/compressed/64: Call set_sev_encryption_mask earlier

2020-02-11 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 18/62] x86/boot/compressed/64: Setup GHCB Based VC Exception handler

2020-02-11 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

Re: [PATCH v4] drm/virtio: add drm_driver.release callback.

2020-02-11 Thread Daniel Vetter
On Tue, Feb 11, 2020 at 02:58:04PM +0100, Gerd Hoffmann wrote: > Split virtio_gpu_deinit(), move the drm shutdown and release to > virtio_gpu_release(). Drop vqs_ready variable, instead use > drm_dev_{enter,exit,unplug} to avoid touching hardware after > device removal. Tidy up here and there. >

Re: [RFC PATCH 00/62] Linux as SEV-ES Guest Support

2020-02-11 Thread Peter Zijlstra
On Tue, Feb 11, 2020 at 02:51:54PM +0100, Joerg Roedel wrote: > NMI Special Handling > > > The last thing that needs special handling with SEV-ES are NMIs. > Hypervisors usually start to intercept IRET instructions when an NMI got > injected to find out when the NMI window is

Re: [RFC PATCH 00/62] Linux as SEV-ES Guest Support

2020-02-11 Thread Joerg Roedel
On Tue, Feb 11, 2020 at 03:50:08PM +0100, Peter Zijlstra wrote: > Oh gawd; so instead of improving the whole NMI situation, AMD went and > made it worse still ?!? Well, depends on how you want to see it. Under SEV-ES an IRET will not re-open the NMI window, but the guest has to tell the

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

2020-02-11 Thread Andy Lutomirski
On Tue, Feb 11, 2020 at 5:53 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. This patch is overcomplicated IMO. Just do the magic incantation in C from do_nmi or from here: /*

[PATCH] char: virtio: Replace zero-length array with flexible-array member

2020-02-11 Thread Gustavo A. R. Silva
The current codebase makes use of the zero-length array language extension to the C90 standard, but the preferred mechanism to declare variable-length types such as these ones is a flexible array member[1][2], introduced in C99: struct foo { int stuff; struct boo array[]; }; By

Re: [PATCH] drm/virtio: rework batching

2020-02-11 Thread Gurchetan Singh
On Tue, Feb 11, 2020 at 4:58 AM Gerd Hoffmann wrote: > > Drop the virtio_gpu_{disable,enable}_notify(). Add a new > virtio_gpu_notify() call instead, which must be called whenever > the driver wants make sure the host is notified needed. > > Drop notification from command submission. Add

Re: [PATCH 14/62] x86/boot/compressed/64: Add stage1 #VC handler

2020-02-11 Thread Andy Lutomirski
On Tue, Feb 11, 2020 at 5:53 AM Joerg Roedel wrote: > > 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

Re: [PATCH 19/62] x86/sev-es: Add support for handling IOIO exceptions

2020-02-11 Thread Andy Lutomirski
On Tue, Feb 11, 2020 at 5:53 AM Joerg Roedel wrote: > > 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:

Re: [PATCH 25/62] x86/head/64: Install boot GDT

2020-02-11 Thread Andy Lutomirski
On Tue, Feb 11, 2020 at 5:53 AM Joerg Roedel wrote: > > 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 | 26

Re: [PATCH 30/62] x86/head/64: Move early exception dispatch to C code

2020-02-11 Thread Andy Lutomirski
On Tue, Feb 11, 2020 at 5:53 AM Joerg Roedel wrote: > > 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. > > Signed-off-by: Joerg Roedel > --- > arch/x86/kernel/head64.c | 20

Re: [PATCH 07/62] x86/boot/compressed/64: Disable red-zone usage

2020-02-11 Thread Andy Lutomirski
On Tue, Feb 11, 2020 at 5:53 AM Joerg Roedel wrote: > > 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

Re: [RFC PATCH 00/62] Linux as SEV-ES Guest Support

2020-02-11 Thread Andy Lutomirski
On Tue, Feb 11, 2020 at 7:43 AM Joerg Roedel wrote: > > On Tue, Feb 11, 2020 at 03:50:08PM +0100, Peter Zijlstra wrote: > > > Oh gawd; so instead of improving the whole NMI situation, AMD went and > > made it worse still ?!? > > Well, depends on how you want to see it. Under SEV-ES an IRET will

Re: [PATCH 08/62] x86/boot/compressed/64: Add IDT Infrastructure

2020-02-11 Thread Andy Lutomirski
On Tue, Feb 11, 2020 at 5:53 AM Joerg Roedel wrote: > > 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

  1   2   >