mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Kalra, Ashish" <ashish.kalra@amd.com>
To: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>,
	"Maciej W. Rozycki" <macro@orcam.me.uk>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
	Kevin Loughlin <kevinloughlin@google.com>,
	linux-kernel@vger.kernel.org,
	Rick Edgecombe <rick.p.edgecombe@intel.com>,
	Isaku Yamahata <isaku.yamahata@intel.com>
Subject: Re: [PATCH] x86/tdx: Fix crash on kexec with CONFIG_EISA
Date: Fri, 30 Aug 2024 15:47:50 -0500	[thread overview]
Message-ID: <fe39a04d-2b3a-476f-9505-b874e3ad93b4@amd.com> (raw)
In-Reply-To: <gnxxp3bzk7cc5eidwvqvqb5hz2ojgjdadujpthweufxms2gjsc@ibcbkjst3pzf>

Hello Kirill,

On 8/29/2024 7:53 AM, Kirill A. Shutemov wrote:
> On Wed, Aug 28, 2024 at 02:43:23PM -0500, Kalra, Ashish wrote:
>> Hello Kirill,
>>
>> On 8/28/2024 1:21 AM, Kirill A. Shutemov wrote:
>>>>>> memremap()
>>>>>>   arch_memremap_wb()
>>>>>>     ioremap_cache()
>>>>>>       __ioremap_caller(.encrytped = false)
>>>>>>
>>>>>> I think arch_memremap_wb() should be mapped ioremap_encrypted() in x86
>>>>>> case. See the patch below.
>>>>>>
>>>>>> It seems to be working fine on TDX, but I am not sure about SEV.
>>>>>>
>>>>>> Tom, any comments?
>>>>> I haven't dug through the code that thoroughly, but I don't think making
>>>>> arch_memremap_wb() be ioremap_encrypted() will work for SME, where some
>>>>> data, e.g. setup data, is unencrypted and needs to be mapped shared.
>>>>>
>>>>> Let me add @Ashish to the thread and have him investigate this since he
>>>>> has been working on the kexec support under SNP. Can someone provide the
>>>>> specific kernel options that need to be in place?
>>>> As Tom asked for, please provide the specific kernel options to test
>>>> with this configuration.
>>> It is not about testing a specific configuration. The question is if it
>>> safe for memremap() to map all WB memory as encrypted by default.
>>>
>>> Looks like it is safe for TDX, but I am not sure about SME/SEV.
>> For SEV it may make sense, but for SME we don't want memremap() to map
>> all WB memory as encrypted by default.
> Could you elaborate why?
>
> I mean if it is specific memory ranges that can be identified as such we
> could make exception for them.
Looks like that the exception is already made for some of these memory ranges with MEMREMAP_DEC flag set along with MEMREMAP_WB.
>>> Maybe we want a specific flag to make memremap() map WB memory as
>>> decrypted/shared. Make everything encrypted by default seems like a sane
>>> default.
>> What are MEMREMAP_ENC, MEMREMAP_DEC flags being used for currently ?
> Good question.
>
> I see zero use of MEMREMAP_ENC in the kernel. And MEMREMAP_DEC only used
> for setup data which I believe AMD thing.
>
> If it is the only memory that must be decrypted, I guess we can make it
> work with encrypted by default.

Yes, and this looks pretty much covered with:

arch_memremap_can_ram_remap(..)

-> if (CC_ATTR_HOST_MEM_REMAP)

--> memremap_is_setup_data()

---> memremap(.., MEMREMAP_WB | MEMREMAP_DEC);

It does look like that it can work with encrypted by default and any memory ranges which need special handling and need to be setup as decrypted can use MEMREMAP_WB | MEMREMAP_DEC flag.

Thanks, Ashish


  reply	other threads:[~2024-08-30 20:47 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-22  9:51 Kirill A. Shutemov
2024-08-24 22:29 ` Maciej W. Rozycki
2024-08-26 12:25   ` Kirill A. Shutemov
2024-08-26 15:52     ` Tom Lendacky
2024-08-27 22:15       ` Kalra, Ashish
2024-08-28  6:21         ` Kirill A. Shutemov
2024-08-28 19:43           ` Kalra, Ashish
2024-08-29 12:53             ` Kirill A. Shutemov
2024-08-30 20:47               ` Kalra, Ashish [this message]
2024-09-10 12:58                 ` Kirill A. Shutemov

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=fe39a04d-2b3a-476f-9505-b874e3ad93b4@amd.com \
    --to=ashish.kalra@amd.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=isaku.yamahata@intel.com \
    --cc=kevinloughlin@google.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=macro@orcam.me.uk \
    --cc=mingo@redhat.com \
    --cc=rick.p.edgecombe@intel.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

all inboxes | Powered by JetHome®