Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp1669759pxy; Thu, 6 May 2021 12:51:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyjZtYzo/eQEdqHLndAQsE2qH8rNQad+FGR6QInTK0jHJRjfFuOtqTSQnkKIvX41El/zhfH X-Received: by 2002:a17:906:d0c8:: with SMTP id bq8mr6076527ejb.423.1620330669000; Thu, 06 May 2021 12:51:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620330668; cv=none; d=google.com; s=arc-20160816; b=onNkZDs17PqlbU+7gurkT1WWmU8v6Bb0yoaOisivgxizDsEJ7jhoBPBWBfQXq8OxGS qJVeE7JshWCZvN2UhCteACu3mFA4+DlKF2FJ1Vfy9v7rrvQmgckYnzUZj3KuFT/ClWwG 09YK0fWnzwhvpLsFQxjD7f8p3eucgs90DTYGAnTTbYumRd9NLaBy696uGWuOcu7mKYqM 9grcjnxV84IYrp5rJpqJZsxEAJOTWFsygBXetzCO1YROhI0XbpWDyd4baWawPiFKmTBT YOKp6FlDmg5veVjOwxCAMiHFM/uilwpbuM/fi+YpXFwOu22xXAwDlXMUGWlF01ffbIgn pWPg== 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; bh=lZxVKBHAoCzvv8fHJHUO0Q99QGZxucfKUFYmOhe1qe0=; b=1HO5j7fQ8YJb0CkhHVMqUrDcC02514XGJnHe8pa3RKvc1LZknwSE9ISPI4Jvjonfmw Yn71G0QMe/UIw83sc6+rNzPSTK449mGMeqmHWZ1zgl6v135oudZVr4DvT+fLxTh3rtRr m4acZS/t0PN3v0JWDr9JUowoIhBHM/u+renM746Px0ik3trcUWQ9l15N2fhjKxAQKjbo sV/IcUEmEyaWYJHH4hmn2ZANJOCdCmkOH2NyxH3VUtlxkPNYlATZyb6CwcHGTOoD2LEb dW3M2RwKIpWhrJVsPuoJDqySNwMeRJ7AAqVY6p8unin9dtkC1Zi71uaHZXk53LESNkg1 1JPg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id en21si3116416ejc.713.2021.05.06.12.50.44; Thu, 06 May 2021 12:51:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236397AbhEFSmJ (ORCPT + 99 others); Thu, 6 May 2021 14:42:09 -0400 Received: from mx2.suse.de ([195.135.220.15]:37162 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234219AbhEFSmI (ORCPT ); Thu, 6 May 2021 14:42:08 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 8E651B186; Thu, 6 May 2021 18:41:08 +0000 (UTC) Date: Thu, 6 May 2021 20:41:05 +0200 From: Joerg Roedel To: "Eric W. Biederman" Cc: Joerg Roedel , x86@kernel.org, kexec@lists.infradead.org, stable@vger.kernel.org, hpa@zytor.com, Andy Lutomirski , Dave Hansen , Peter Zijlstra , Jiri Slaby , Dan Williams , Tom Lendacky , Juergen Gross , Kees Cook , David Rientjes , Cfir Cohen , Erdem Aktas , Masami Hiramatsu , Mike Stunes , Sean Christopherson , Martin Radev , Arvind Sankar , linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org Subject: Re: [PATCH 2/2] x86/kexec/64: Forbid kexec when running as an SEV-ES guest Message-ID: References: <20210506093122.28607-1-joro@8bytes.org> <20210506093122.28607-3-joro@8bytes.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 06, 2021 at 12:42:03PM -0500, Eric W. Biederman wrote: > I don't understand this. > > Fundamentally kexec is about doing things more or less inspite of > what the firmware is doing. > > I don't have any idea what a SEV-ES is. But the normal x86 boot doesn't > do anything special. Is cross cpu IPI emulation buggy? Under SEV-ES the normal SIPI-based sequence to re-initialize a CPU does not work anymore. An SEV-ES guest is a special virtual machine where the hardware encrypts the guest memory and the guest register state. The hypervisor can't make any modifications to the guests registers at runtime. Therefore it also can't emulate a SIPI sequence and reset the vCPU. The guest kernel has to reset the vCPU itself and hand it over from the old kernel to the kexec'ed kernel. This isn't currently implemented and therefore kexec needs to be disabled when running as an SEV-ES guest. Implementing this also requires an extension to the guest-hypervisor protocol (the GHCB Spec[1]) which is only available in version 2. So a guest running on a hypervisor supporting only version 1 will never properly support kexec. > What is the actual problem you are trying to avoid? Currently, if someone tries kexec in an SEV-ES guest, the kexec'ed kernel will only be able to bring up the boot CPU, not the others. The others will wake up with the old kernels CPU state in the new kernels memory and do undefined things, most likely triple-fault because their page-table is not existent anymore. So since kexec currently does not work as expected under SEV-ES, it is better to hide it until everything is implemented so it can do what the user expects. > And yes for a temporary hack the suggestion of putting code into > machine_kexec_prepare seems much more reasonable so we don't have to > carry special case infrastructure for the forseeable future. As I said above, for protocol version 1 it will stay disabled, so it is not only a temporary hack. Regards, Joerg [1] https://developer.amd.com/wp-content/resources/56421.pdf