[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <b2d1e806-5bb0-44f9-a1be-498ddadd37a3@intel.com>
Date: Thu, 1 Feb 2024 08:57:28 -0800
From: Dave Hansen <dave.hansen@...el.com>
To: "Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>,
"Huang, Kai" <kai.huang@...el.com>
Cc: linux-kernel@...r.kernel.org, x86@...nel.org, tglx@...utronix.de,
bp@...en8.de, mingo@...hat.com, hpa@...or.com, luto@...nel.org,
peterz@...radead.org, thomas.lendacky@....com, chao.gao@...el.com,
bhe@...hat.com, nik.borisov@...e.com, pbonzini@...hat.com
Subject: Re: [PATCH 3/4] x86/kexec(): Reset TDX private memory on platforms
with TDX erratum
On 2/1/24 06:39, Kirill A. Shutemov wrote:
>> On 1/02/2024 6:03 am, Kirill A. Shutemov wrote:
>>> On Wed, Jan 31, 2024 at 01:21:39PM -0800, Dave Hansen wrote:
>>>>> #ifdef CONFIG_KEXEC_JUMP
>>>>> if (image->preserve_context)
>>>>> save_processor_state();
>>>>> + else
>>>>> + tdx_reset_memory();
>>>>> +#else
>>>>> + tdx_reset_memory();
>>>>> #endif
..
> +void save_processor_state(void);
> +void restore_processor_state(void);
> +
> #ifdef CONFIG_SUSPEND
> extern suspend_state_t pm_suspend_target_state;
> extern suspend_state_t mem_sleep_current;
> @@ -491,8 +494,6 @@ static inline int is_hibernate_resume_dev(dev_t dev) { return 0; }
> extern struct mutex system_transition_mutex;
>
> #ifdef CONFIG_PM_SLEEP
> -void save_processor_state(void);
> -void restore_processor_state(void);
It's a little funky that we've got a #ifdef CONFIG_KEXEC_JUMP in the .c
file and then we're dodging around an #ifdef CONFIG_PM_SLEEP in the
header. This is one of the reasons we shouldn't be putting #ifdefs in
c files in the first place. But I digress...
Either way, if you focus on getting the dang #ifdef out of the main code
flow, the rest will fall in place easily. Heck, if you even do this in
the x86 kexec code:
static void kexec_save_processor_start(image)
{
#ifdef CONFIG_KEXEC_JUMP
if (image->preserve_context)
save_processor_state();
#endif
}
it'll leave you with:
kexec_save_processor_start(image);
/* Give a good reason here */
if (!image->preserve_context)
tdx_reset_memory();
which is *FINE*. No funky #ifdefs, indentation or else's dangling about.
Powered by blists - more mailing lists