From: "Huang, Kai" <kai.huang@intel.com>
To: "kirill.shutemov@linux.intel.com"
<kirill.shutemov@linux.intel.com>,
"tglx@linutronix.de" <tglx@linutronix.de>,
"peterz@infradead.org" <peterz@infradead.org>,
"Hansen, Dave" <dave.hansen@intel.com>,
"mingo@redhat.com" <mingo@redhat.com>,
"bp@alien8.de" <bp@alien8.de>
Cc: "hpa@zytor.com" <hpa@zytor.com>,
"thomas.lendacky@amd.com" <thomas.lendacky@amd.com>,
"pbonzini@redhat.com" <pbonzini@redhat.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"luto@kernel.org" <luto@kernel.org>,
"x86@kernel.org" <x86@kernel.org>,
"seanjc@google.com" <seanjc@google.com>
Subject: Re: [PATCH v5 2/5] x86/kexec: do unconditional WBINVD for bare-metal in relocate_kernel()
Date: Thu, 15 Aug 2024 23:45:17 +0000 [thread overview]
Message-ID: <3d7ec1cd218e835f730fca7cf9e3b4d300df6830.camel@intel.com> (raw)
In-Reply-To: <47d9f1150a6852c9a403b9e25858f5658c50a51d.1723723470.git.kai.huang@intel.com>
>
> #define ARCH_HAS_KIMAGE_ARCH
> diff --git a/arch/x86/kernel/machine_kexec_64.c b/arch/x86/kernel/machine_kexec_64.c
> index 9c9ac606893e..07ca9d3361a3 100644
> --- a/arch/x86/kernel/machine_kexec_64.c
> +++ b/arch/x86/kernel/machine_kexec_64.c
> @@ -392,7 +392,7 @@ void machine_kexec(struct kimage *image)
> (unsigned long)page_list,
> image->start,
> image->preserve_context,
> - host_mem_enc_active);
> + !boot_cpu_has(X86_FEATURE_HYPERVISOR));
>
>
LKP reported below warning:
All warnings (new ones prefixed by >>):
arch/x86/kernel/machine_kexec_64.c: In function 'machine_kexec':
>> arch/x86/kernel/machine_kexec_64.c:325:22: warning: variable
'host_mem_enc_active' set but not used [-Wunused-but-set-variable]
325 | unsigned int host_mem_enc_active;
| ^~~~~~~~~~~~~~~~~~~
This is due to while rebasing I didn't pay enough attention to the recent code
from commit
93c1800b3799f ("x86/kexec: Fix bug with call depth tracking")
which introduced the host_mem_enc_active variable in order to avoid
cc_platform_has() function call after load_segments() to resolve a problem
when call depth tracking is on.
A 100% safe way is to replace
host_mem_enc_active = cc_platform_has(CC_ATTR_HOST_MEM_ENCRYPT);
... with
bare_metal = !boot_cpu_has(X86_FEATURE_HYPERVISOR);
but I think we can just remove that variable and directly use
!boot_cpu_has(X86_FEATURE_HYPERVISOR)
as the last argument of calling the relocate_kernel(), because AFAICT the
above X86_FEATURE_HYPERVISOR bit test will always generate inline code thus
there will be no additional CALL/RET.
The incremental diff will be:
--- a/arch/x86/kernel/machine_kexec_64.c
+++ b/arch/x86/kernel/machine_kexec_64.c
@@ -331,16 +331,9 @@ static void kexec_save_processor_start(struct kimage
*image)
void machine_kexec(struct kimage *image)
{
unsigned long page_list[PAGES_NR];
- unsigned int host_mem_enc_active;
int save_ftrace_enabled;
void *control_page;
- /*
- * This must be done before load_segments() since if call depth
tracking
- * is used then GS must be valid to make any function calls.
- */
- host_mem_enc_active = cc_platform_has(CC_ATTR_HOST_MEM_ENCRYPT);
-
Am I missing anything?
I'll send out a new version with the above and put some explanation to the
changelog if I don't see any other feedback on the rest TDX patches in the
coming days. Thanks!
next prev parent reply other threads:[~2024-08-15 23:45 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-15 12:29 [PATCH v5 0/5] TDX host: kexec() support Kai Huang
2024-08-15 12:29 ` [PATCH v5 1/5] x86/kexec: do unconditional WBINVD for bare-metal in stop_this_cpu() Kai Huang
2024-08-15 12:29 ` [PATCH v5 2/5] x86/kexec: do unconditional WBINVD for bare-metal in relocate_kernel() Kai Huang
2024-08-15 23:45 ` Huang, Kai [this message]
2024-09-04 15:30 ` Borislav Petkov
2024-09-04 23:55 ` Huang, Kai
2024-08-15 12:29 ` [PATCH v5 3/5] x86/virt/tdx: Make module initializatiton state immutable in reboot notifier Kai Huang
2024-08-15 12:29 ` [PATCH v5 4/5] x86/kexec: Reset TDX private memory on platforms with TDX erratum Kai Huang
2024-08-15 12:29 ` [PATCH v5 5/5] x86/virt/tdx: Remove the !KEXEC_CORE dependency Kai Huang
2024-08-19 21:21 ` [PATCH v5 0/5] TDX host: kexec() support Sagi Shahar
2024-08-19 22:16 ` Huang, Kai
2024-08-19 22:28 ` Sagi Shahar
2024-08-19 22:43 ` Huang, Kai
2024-08-23 16:15 ` Sagi Shahar
2024-08-24 9:31 ` Huang, Kai
2024-08-26 19:22 ` Sagi Shahar
2024-08-26 22:50 ` Huang, Kai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3d7ec1cd218e835f730fca7cf9e3b4d300df6830.camel@intel.com \
--to=kai.huang@intel.com \
--cc=bp@alien8.de \
--cc=dave.hansen@intel.com \
--cc=hpa@zytor.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peterz@infradead.org \
--cc=seanjc@google.com \
--cc=tglx@linutronix.de \
--cc=thomas.lendacky@amd.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox