Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp172285imn; Fri, 29 Jul 2022 03:35:32 -0700 (PDT) X-Google-Smtp-Source: AA6agR53zGw3ngMTosV/u3lRVKMPt0pXV57+7DmTeLv7n9kJUPhHbG0ei3XHhqeM3/w+aV1FM5qx X-Received: by 2002:a17:902:dacf:b0:16d:9d47:dfd1 with SMTP id q15-20020a170902dacf00b0016d9d47dfd1mr3330729plx.52.1659090932641; Fri, 29 Jul 2022 03:35:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659090932; cv=none; d=google.com; s=arc-20160816; b=gFpdUd0WUWkuEkMHpg/RaZyQGvh5YRj1XFUbzr3g4rOn366SMfstjB2luKE5VE335N NJo4bjCWFnc445B5PL7jDo/RRj6Copf7X+DTOyRWh3HxADIOgMBxyNteB4JI9oG56FXu J0NuG45oZxQG01pf0zk0Pc6y+P4rl7Ub5GA0Vjl5FoOzqZJT+y8kUNMLhMY1vP5B3WcK 6B0MPgyKTGbNCGGJfzhpOIleiKKbt+611s9hiuzHT+82YfIJVbhzHH9OOhrX7uyBhk4d NaZMD1omUKIC+rIOHOO0oqNKKMso6Pw2D/pZ/eyiDFlwOMjxY+egq8SXJ3INEiQEK9HD 7B+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=as0dSaDJ9Kz1ka/wV5ZX8Zqed6rUUwP8w5uBz6jTo54=; b=PLx3J5QQSndnbBcxdrabojK5TycskC7g4dBBNSsQeiQAiUQH8ddIV17c8C/ogdFsfx Xm5zjvwgl7O0+kyyodxSHqqPeyynuiZnAi5NOobjhy2j4j0erNQ8QS42b9eJHBmExBMF hiNHm0aNUhXwyxMQ/dXwFfc1o56ZHLojspcCAxaItAaFzGaZ5/8gRivvSTcWojPZxai6 q61SjgguPS+d4bm6N1YaeVveSoMMxAg0ARVpV4V9U8xW2eF7X1Wjx9+CnMQvJhS4aJNL 3hb0/jrZtogcfcC1hpMPeinuKVpB4mMkoKn3PX1JYtYwr5OrXsX7zDL0n/GjWZ714O7Y +FKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Cx4FItA8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nv1-20020a17090b1b4100b001f22986b36esi9427600pjb.168.2022.07.29.03.35.16; Fri, 29 Jul 2022 03:35:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Cx4FItA8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235044AbiG2K23 (ORCPT + 99 others); Fri, 29 Jul 2022 06:28:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230272AbiG2K20 (ORCPT ); Fri, 29 Jul 2022 06:28:26 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0DFFEB6C for ; Fri, 29 Jul 2022 03:28:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659090504; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=as0dSaDJ9Kz1ka/wV5ZX8Zqed6rUUwP8w5uBz6jTo54=; b=Cx4FItA8GTlzS2V+4B/VuSwlcaJ32WcyUZnb2BGIjaiNm3flr6y5sS0/Qu20BV7OqM/kJc YiDfAhx4eFMeusDEqKdbMIsRKiy/D1EUgCaRjQCX2p8xemTHVTCkk6t6yqs7DVzfWX0Sit TNLgsihCjE4LWGD7ycp4Pgr0YEkyPXI= Received: from mail-pj1-f72.google.com (mail-pj1-f72.google.com [209.85.216.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-377-wPobRwnhMy6IoOvknihrCw-1; Fri, 29 Jul 2022 06:28:23 -0400 X-MC-Unique: wPobRwnhMy6IoOvknihrCw-1 Received: by mail-pj1-f72.google.com with SMTP id q5-20020a17090a7a8500b001f0253f5aa3so2241490pjf.4 for ; Fri, 29 Jul 2022 03:28:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=as0dSaDJ9Kz1ka/wV5ZX8Zqed6rUUwP8w5uBz6jTo54=; b=6AYaQEk/myezfyJ4uCrsrUYO4iv4BYh8B591Q56oTpXb/v9Px6sRn5LNxE/txMAE+F EU6uu+iWuDa0oGoPXDQzBmCxAoROFK3JcbPT2A5J0qu36PsdIvKr12wpbikdRcGjWLIG pWN+mgZYESM2GIuXb663vHB9+0pnC+0Wdo6bLQIEnObY/6Q0nCAYJmmDPYkopv1g95qS GrTW/wEAEOe+IHcGhh14PuSUU/NyTfiUNWHwDDOp0rwkIQ5RJFCrxxOE0QL9H8JxDhw4 qm3kZ9AC2lxvajQpOnC0sCHbbir4lGhXdf7fw7RPqYLR38mu2HFTJtd1y2iBOvMCyCMH A30g== X-Gm-Message-State: ACgBeo3o+B3MsWnuAPNc2lHeB9vMhMiKxZOF15929J6TiCsYg0sTEYQ4 5X/jAlVGD8DslwGc2OCsrVpcZhTTWWd7+ZUMibHsbj21T2AheW9fsFjAmzCliTEdzVxFo62M5Yo Q2VT8Zmy/XFB54Zl9WPeikinn X-Received: by 2002:a17:902:b948:b0:16d:93c8:403a with SMTP id h8-20020a170902b94800b0016d93c8403amr3216210pls.45.1659090501909; Fri, 29 Jul 2022 03:28:21 -0700 (PDT) X-Received: by 2002:a17:902:b948:b0:16d:93c8:403a with SMTP id h8-20020a170902b94800b0016d93c8403amr3216163pls.45.1659090501513; Fri, 29 Jul 2022 03:28:21 -0700 (PDT) Received: from localhost.localdomain ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id d14-20020aa797ae000000b005289eafbd08sm2618289pfq.18.2022.07.29.03.28.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Jul 2022 03:28:20 -0700 (PDT) Date: Fri, 29 Jul 2022 18:28:09 +0800 From: Tao Liu To: Tom Lendacky Cc: Joerg Roedel , x86@kernel.org, kvm@vger.kernel.org, Peter Zijlstra , Dave Hansen , virtualization@lists.linux-foundation.org, Arvind Sankar , hpa@zytor.com, Jiri Slaby , David Rientjes , Masami Hiramatsu , Martin Radev , Joerg Roedel , Kees Cook , Cfir Cohen , linux-coco@lists.linux.dev, Andy Lutomirski , Dan Williams , Juergen Gross , Mike Stunes , Sean Christopherson , kexec@lists.infradead.org, linux-kernel@vger.kernel.org, Eric Biederman , Erdem Aktas Subject: Re: [PATCH v3 00/10] x86/sev: KEXEC/KDUMP support for SEV-ES guests Message-ID: References: <20220127101044.13803-1-joro@8bytes.org> <46b27b72-aabf-f37d-7304-29debeefd8ae@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <46b27b72-aabf-f37d-7304-29debeefd8ae@amd.com> X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Tom, On Fri, Apr 29, 2022 at 08:08:28AM -0500, Tom Lendacky wrote: > On 4/29/22 04:06, Tao Liu wrote: > > On Thu, Jan 27, 2022 at 11:10:34AM +0100, Joerg Roedel wrote: > > > > > Hi Joerg, > > > > I tried the patch set with 5.17.0-rc1 kernel, and I have a few questions: > > > > 1) Is it a bug or should qemu-kvm 6.2.0 be patched with specific patch? Because > > I found it will exit with 0 when I tried to reboot the VM with sev-es enabled. > > However with only sev enabled, the VM can do reboot with no problem: > > Qemu was specifically patched to exit on reboot with SEV-ES guests. Qemu > performs a reboot by resetting the vCPU state, which can't be done with an > SEV-ES guest because the vCPU state is encrypted. > Sorry for the late response, and thank you for the explanation! > > > > [root@dell-per7525-03 ~]# virsh start TW-SEV-ES --console > > .... > > Fedora Linux 35 (Server Edition) > > Kernel 5.17.0-rc1 on an x86_64 (ttyS0) > > .... > > [root@fedora ~]# reboot > > ..... > > [ 48.077682] reboot: Restarting system > > [ 48.078109] reboot: machine restart > > ^^^^^^^^^^^^^^^ guest vm reached restart > > [root@dell-per7525-03 ~]# echo $? > > 0 > > ^^^ qemu-kvm exit with 0, no reboot back to normal VM kernel > > [root@dell-per7525-03 ~]# > > > > 2) With sev-es enabled and the 2 patch sets applied: A) [PATCH v3 00/10] x86/sev: > > KEXEC/KDUMP support for SEV-ES guests, and B) [PATCH v6 0/7] KVM: SVM: Add initial > > GHCB protocol version 2 support. I can enable kdump and have vmcore generated: > > > > [root@fedora ~]# dmesg|grep -i sev > > [ 0.030600] SEV: Hypervisor GHCB protocol version support: min=1 max=2 > > [ 0.030602] SEV: Using GHCB protocol version 2 > > [ 0.296144] AMD Memory Encryption Features active: SEV SEV-ES > > [ 0.450991] SEV: AP jump table Blob successfully set up > > [root@fedora ~]# kdumpctl status > > kdump: Kdump is operational > > > > However without the 2 patch sets, I can also enable kdump and have vmcore generated: > > > > [root@fedora ~]# dmesg|grep -i sev > > [ 0.295754] AMD Memory Encryption Features active: SEV SEV-ES > > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ patch set A & B > > not applied, so only have this string. > > [root@fedora ~]# echo c > /proc/sysrq-trigger > > ... > > [ 2.759403] kdump[549]: saving vmcore-dmesg.txt to /sysroot/var/crash/127.0.0.1-2022-04-18-05:58:50/ > > [ 2.804355] kdump[555]: saving vmcore-dmesg.txt complete > > [ 2.806915] kdump[557]: saving vmcore > > ^^^^^^^^^^^^^ vmcore can still be generated > > ... > > [ 7.068981] reboot: Restarting system > > [ 7.069340] reboot: machine restart > > > > [root@dell-per7525-03 ~]# echo $? > > 0 > > ^^^ same exit issue as question 1. > > > > I doesn't have a complete technical background of the patch set, but isn't > > it the issue which this patch set is trying to solve? Or I missed something? > > The main goal of this patch set is to really to solve the ability to perform > a kexec. I would expect kdump to work since kdump shuts down all but the > executing vCPU and performs its operations before "rebooting" (which will > exit Qemu as I mentioned above). But kexec requires the need to restart the > APs from within the guest after they have been stopped. That requires > specific support and actions on the part of the guest kernel in how the APs > are stopped and restarted. Recently I got one sev-es flaged machine borrowed and retested the patch, which worked fine for kexec when sev-es enabled. With the patchset applied in 5.17.0-rc1, kexec'ed kernel can bring up all APs with no problem. However as for kdump, I find one issue. Although kdump kernel can work well on one cpu, but we can still enable multi-cpus by removing the "nr_cpus=1" kernel parameter in kdump sysconfig. I was expecting kdump kernel can bring up all APs as kexec did, however: [ 0.000000] Command line: elfcorehdr=0x5b000000 BOOT_IMAGE=(hd0,gpt2)/vmlinuz-5.17.0-rc1+ ro resume=/dev/mapper/rhel-swap biosdevname=0 net.ifnames=0 console=ttyS0 irqpoll reset_devices cgroup_disable=memory mce=off numa=off udev.children-max=2 panic=10 rootflags=nofail acpi_no_memhotplug transparent_hugepage=never nokaslr novmcoredd hest_disable disable_cpu_apicid=0 iTCO_wdt.pretimeout=0 ... [ 0.376663] smp: Bringing up secondary CPUs ... [ 0.377599] x86: Booting SMP configuration: [ 0.378342] .... node #0, CPUs: #1 [ 10.377698] smpboot: do_boot_cpu failed(-1) to wakeup CPU#1 [ 10.379882] #2 [ 20.379645] smpboot: do_boot_cpu failed(-1) to wakeup CPU#2 [ 20.380648] smp: Brought up 1 node, 1 CPU [ 20.381600] smpboot: Max logical packages: 4 [ 20.382597] smpboot: Total of 1 processors activated (4192.00 BogoMIPS) Turns out for kdump, the APs were not stopped properly, so I modified the following code: --- a/arch/x86/kernel/reboot.c +++ b/arch/x86/kernel/reboot.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -821,6 +822,7 @@ static int crash_nmi_callback(unsigned int val, struct pt_regs *regs) atomic_dec(&waiting_for_crash_ipi); /* Assume hlt works */ + sev_es_stop_this_cpu(); halt(); for (;;) cpu_relax(); [ 0.000000] Command line: elfcorehdr=0x5b000000 BOOT_IMAGE=(hd0,gpt2)/vmlinuz-5.17.0-rc1-hack+ ro resume=/dev/mapper/rhel-swap biosdevname=0 net.ifnames=0 console=ttyS0 irqpoll reset_devices cgroup_disable=memory mce=off numa=off udev.children-max=2 panic=10 rootflags=nofail acpi_no_memhotplug transparent_hugepage=never nokaslr novmcoredd hest_disable disable_cpu_apicid=0 iTCO_wdt.pretimeout=0 ... [ 0.402618] smp: Bringing up secondary CPUs ... [ 0.403308] x86: Booting SMP configuration: [ 0.404171] .... node #0, CPUs: #1 #2 #3 [ 0.407362] smp: Brought up 1 node, 4 CPUs [ 0.408907] smpboot: Max logical packages: 4 [ 0.409172] smpboot: Total of 4 processors activated (16768.01 BogoMIPS) Now all APs can work in kdump kernel. Thanks, Tao Liu > > Thanks, > Tom > > > > > Thanks, > > Tao Liu > > > _______________________________________________ > > > Virtualization mailing list > > > Virtualization@lists.linux-foundation.org > > > https://lists.linuxfoundation.org/mailman/listinfo/virtualization > > >