Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp697839rdb; Thu, 18 Jan 2024 16:49:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IFsgE39RWTmNlUXzA4ftvntfSc/KZ+1XLWRIlVxt1oFAV5C52rdgj/vuHN1+OdEk5NroICK X-Received: by 2002:ac8:5e11:0:b0:429:e309:e98f with SMTP id h17-20020ac85e11000000b00429e309e98fmr1963251qtx.135.1705625373526; Thu, 18 Jan 2024 16:49:33 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705625373; cv=pass; d=google.com; s=arc-20160816; b=aoVRkZTN3NZm43nySFdA4BWF1jBO2dIvA38y6XcKcnb6z6C1z0EHmJfTt9llOdEq/y FOju/FaroiDmFBG8FNZjzY8f/V7iv7wyHLynT/hpFenx8D610QUUr8rkqICisdqzncLU UOW6kvleQVEqMMNmQVr7Fv66FBM9il+jbc7HgQFxFd6yVbUbVHGjcG71Isnn/PDSQVMN t4JM6uf3EGv+0HzEdfL9BUwfcSeNqOXRi6SOU3hCYpnMWxafMjK0CDd1zAwlNOpnrKCU s39tfEv+CQvM4/o+EhU8ND68IU6rPCNE8blmo7qPPz2st+v61Erpl5knzbz7rxAMp5iA J7sA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=yJn7PDCEsi1flK+Hr69h8xa87hWqbunI7cAobJSuTQg=; fh=HQTZpu1Ty+N/aWWsA7LiXblA2Vt+8k3T1/dcPv6n7Ug=; b=OO0bUHm95YdVB0T7D+SR0n4Y0QWl6fks+K3QllFqBbJS85KXEhj6LpmmYWFB8ube0P FrPqPhWc5nwsvoARWjJyFTPGulA4HAeiESrUqPIa0jsITVpWsqYE4lDFxf3V0YVAutVE AcS3UOiSx31RVKK2QsfTXM5Xd6KEJSGdn8jUYMvRZQMiBOK756RR294lbWfHl5k/YtsU KAZ+pCzwT2qRsAlBuOMVKpRdf28wCUTMpmObjKG8lchbeF9MjW18bbFW4a4jhOIN5A78 sATWVM/+DwQqYmqPLKrvnp5d4QSVihRIfbPuzfzXfIcwTic/m3O75dVKjI36Uj17TbAt StqA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.com header.s=google header.b=DSD1zX89; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel+bounces-30664-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-30664-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id s8-20020a05622a178800b004299d7d03adsi15246368qtk.339.2024.01.18.16.49.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jan 2024 16:49:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-30664-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=google header.b=DSD1zX89; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel+bounces-30664-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-30664-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 3C3E81C225E1 for ; Fri, 19 Jan 2024 00:49:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1E58F1378; Fri, 19 Jan 2024 00:49:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="DSD1zX89" Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3A2D8818 for ; Fri, 19 Jan 2024 00:49:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705625363; cv=none; b=YzQP6hr4eDMmL8ylry2Und8JdlzrBquY/ZDkm93/iSyz0QmaUbJWx9JX681UxfTc7P8CBw9/he5m+R2d5oWZCGHnuHksjm2mjm+Wbqwr17Z7Us4EG3AzNkd/SMGKrMY/anuSidZv89vKbbkgrbDIWKc2Z52LxoM84o9ACc8iYJc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705625363; c=relaxed/simple; bh=rydYd/Y5i8IwNquaHNsrMqfkz0FVri47/DCexZ/mj2A=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=cxtj6XIOA2QJ4wgQQ+byTi1qi3B2yRVeGdlXbOTtnVomNiYZpFImBt7Gay/JGCLSha4W2aYpCHi+L5t/hHOspYd15Zuei2C02vLrGs/z9EJUxu02h/6BHELgl14BDmSxYoWQ7ZueGixm0ELNjiiug1zky5n5sTQv601ZiRYNSJ0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=DSD1zX89; arc=none smtp.client-ip=209.85.167.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Received: by mail-lf1-f49.google.com with SMTP id 2adb3069b0e04-50ea8fbf261so238735e87.2 for ; Thu, 18 Jan 2024 16:49:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1705625358; x=1706230158; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=yJn7PDCEsi1flK+Hr69h8xa87hWqbunI7cAobJSuTQg=; b=DSD1zX893SfFdeEyCLQhSD7rEMinJQshYyP0+5vpCLhQX2rbBnfsnZc7QmTtI7YYUy yvVLz2gUftloO2jbSa5wHWc9YfwLIhqwTCMlM2/zMCOv8wY0yDkKV1husrFSRc52N7b3 b57qYkHs2lYR6bg7SKRsy1S0Dkvb5h1wsq3raIsQ/uOP9fpJltl0ssVu0GINw0UrGctV hUlEVHffGBrR/r6OxpClmUGD/7zdaF0bl65ax43a/ZaBTNVvgWjRlGVtZeYYZ9y1WH1B H1+ocFdgKMeLuY0ve51fZB4+UYgjKPRyCi4Pcv3qQaOPlj4fC+msqtPnb16IETeUQ995 tsyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705625358; x=1706230158; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=yJn7PDCEsi1flK+Hr69h8xa87hWqbunI7cAobJSuTQg=; b=HHs3Q1hQ9du82dXtvDIQ9agCh2vy4gQc8VNE64JBR9nIJdLCBEW9+UjqZX+kygFvcs A6KJqebk7BPGDzZlfRoVP5/8jQ+nso9FzI8d7o9iXVxmLzA1XjlbUFOozG2kMlwNGu6v jogQiGKDY4yCTs4nq65PGPhtFowwtWNkHvS5JQqsTTPgbFSO+q77zi1Fsnfe4R9lnckU d16T0lI9b+iPkpxg9lnSBI/1fB1nRgd1eJ3m3KD0McEA3aFm3/x0fhBFoarvf/F26q8Q XPFm/MZ+q1blqIiDNYlv4EHrNQDxpnbNi8GtTZbaWVpODvhukpDOiVpArzmaaaYXyk0n 5twQ== X-Gm-Message-State: AOJu0YyI+Ljhy/5aWA6TY+8c1QZLfUJ8ruCyOiuki4/OdFavl85+wsNU nuAb9MRI9iVn6XO6wxOHXnLAJngGX1xB8ykJ1hjv74Gs0FJ61Gp79nT76TmYzlM= X-Received: by 2002:ac2:44ba:0:b0:50e:74e1:144a with SMTP id c26-20020ac244ba000000b0050e74e1144amr193290lfm.15.1705625358236; Thu, 18 Jan 2024 16:49:18 -0800 (PST) Received: from ?IPV6:2a10:bac0:b000:7589:26fc:cf3:a5b9:2475? ([2a10:bac0:b000:7589:26fc:cf3:a5b9:2475]) by smtp.gmail.com with ESMTPSA id f16-20020ac24e50000000b0050f09876c12sm810285lfr.208.2024.01.18.16.49.17 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 18 Jan 2024 16:49:18 -0800 (PST) Message-ID: Date: Fri, 19 Jan 2024 02:49:16 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH] x86/virt/tdx: Disable KEXEC in the presence of TDX Content-Language: en-US To: "Huang, Kai" , "linux-kernel@vger.kernel.org" , "kirill.shutemov@linux.intel.com" Cc: "linux-coco@lists.linux.dev" , "x86@kernel.org" , "dave.hansen@linux.intel.com" References: <20240118160118.1899299-1-nik.borisov@suse.com> From: Nikolay Borisov In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit [Adding Kirill as he has a series in flight about KEXEC] On 18.01.24 г. 23:31 ч., Huang, Kai wrote: > On Thu, 2024-01-18 at 18:01 +0200, Nikolay Borisov wrote: >> TDX doesn't currently support kexec so disable the latter when TDX >> is detected at boot time. If kexec must absolutely be supported then >> TDX can be disabled from the bios. >> >> Making this decision at run time rather than as a compile time option >> allows distribution kernels to have both enabled and delegate to the >> user whether they want to use TDX/Kexec. >> >> Signed-off-by: Nikolay Borisov > > Hi Nikolay, > > Thanks for the patch. > > I am working in progress on patches to make kexec() work with TDX. I plan to > send them out soon (e.g., next week), but I think perhaps your patch is > reasonable before that is merged. I thought Kirill's series rectifies this ? > > Acked-by: Kai Huang > >> --- >> >> Sending as RFC as I don't know the reason why initially it was decided to >> enforce the incompaibility between kexec/tdx at build time rather than runtime. >> >> arch/x86/Kconfig | 1 - >> arch/x86/virt/vmx/tdx/tdx.c | 6 ++++++ >> include/linux/kexec.h | 1 + >> kernel/kexec_core.c | 5 +++++ >> 4 files changed, 12 insertions(+), 1 deletion(-) >> >> diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig >> index 92c03cb99b3e..6c2b620b40d8 100644 >> --- a/arch/x86/Kconfig >> +++ b/arch/x86/Kconfig >> @@ -1973,7 +1973,6 @@ config INTEL_TDX_HOST >> depends on X86_X2APIC >> select ARCH_KEEP_MEMBLOCK >> depends on CONTIG_ALLOC >> - depends on !KEXEC_CORE >> depends on X86_MCE >> help >> Intel Trust Domain Extensions (TDX) protects guest VMs from malicious >> diff --git a/arch/x86/virt/vmx/tdx/tdx.c b/arch/x86/virt/vmx/tdx/tdx.c >> index 4d6826a76f78..270090bd7b5e 100644 >> --- a/arch/x86/virt/vmx/tdx/tdx.c >> +++ b/arch/x86/virt/vmx/tdx/tdx.c >> @@ -20,6 +20,7 @@ >> #include >> #include >> #include >> +#include >> #include >> #include >> #include >> @@ -1473,6 +1474,11 @@ void __init tdx_init(void) >> return; >> } >> >> +#ifdef CONFIG_KEXEC_CORE >> + kexec_disable(); >> + pr_info("Disable Kexec. Turn off TDX in the BIOS to use KEXEC.\n"); >> +#endif >> + >> #if defined(CONFIG_ACPI) && defined(CONFIG_SUSPEND) >> pr_info("Disable ACPI S3. Turn off TDX in the BIOS to use ACPI S3.\n"); >> acpi_suspend_lowlevel = NULL; >> diff --git a/include/linux/kexec.h b/include/linux/kexec.h >> index 8227455192b7..c434c8569242 100644 >> --- a/include/linux/kexec.h >> +++ b/include/linux/kexec.h >> @@ -500,6 +500,7 @@ static inline int crash_hotplug_memory_support(void) { return 0; } >> static inline unsigned int crash_get_elfcorehdr_size(void) { return 0; } >> #endif >> >> +extern void kexec_disable(void); >> #else /* !CONFIG_KEXEC_CORE */ >> struct pt_regs; >> struct task_struct; >> diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c >> index be5642a4ec49..8d3a2a04ff4d 100644 >> --- a/kernel/kexec_core.c >> +++ b/kernel/kexec_core.c >> @@ -927,6 +927,11 @@ struct kimage *kexec_image; >> struct kimage *kexec_crash_image; >> static int kexec_load_disabled; >> >> +void kexec_disable(void) >> +{ >> + kexec_load_disabled = 1; >> +} >> + >> #ifdef CONFIG_SYSCTL >> static int kexec_limit_handler(struct ctl_table *table, int write, >> void *buffer, size_t *lenp, loff_t *ppos) >> -- >> 2.34.1 >> >> >