Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1481555 > unrolled thread

Re: [RFC PATCH v2 19/20] x86: Access the setup data through debugfs un-encrypted

Started byBorislav Petkov <bp@alien8.de>
First post2016-09-12 19:00 +0200
Last post2016-09-16 09:20 +0200
Articles 3 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [RFC PATCH v2 19/20] x86: Access the setup data through debugfs  un-encrypted Borislav Petkov <bp@alien8.de> - 2016-09-12 19:00 +0200
    Re: [RFC PATCH v2 19/20] x86: Access the setup data through debugfs  un-encrypted Borislav Petkov <bp@alien8.de> - 2016-09-14 17:00 +0200
      Re: [RFC PATCH v2 19/20] x86: Access the setup data through debugfs  un-encrypted Borislav Petkov <bp@alien8.de> - 2016-09-16 09:20 +0200

#1481555 — Re: [RFC PATCH v2 19/20] x86: Access the setup data through debugfs un-encrypted

FromBorislav Petkov <bp@alien8.de>
Date2016-09-12 19:00 +0200
SubjectRe: [RFC PATCH v2 19/20] x86: Access the setup data through debugfs un-encrypted
Message-ID<sgCKl-5RJ-17@gated-at.bofh.it>
On Mon, Aug 22, 2016 at 05:38:59PM -0500, Tom Lendacky wrote:
> Since the setup data is in memory in the clear, it must be accessed as
> un-encrypted.  Always use ioremap (similar to sysfs setup data support)
> to map the data.
> 
> Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
> ---
>  arch/x86/kernel/kdebugfs.c |   30 +++++++++++-------------------
>  1 file changed, 11 insertions(+), 19 deletions(-)
> 
> diff --git a/arch/x86/kernel/kdebugfs.c b/arch/x86/kernel/kdebugfs.c
> index bdb83e4..a58a82e 100644
> --- a/arch/x86/kernel/kdebugfs.c
> +++ b/arch/x86/kernel/kdebugfs.c
> @@ -48,17 +48,13 @@ static ssize_t setup_data_read(struct file *file, char __user *user_buf,
>  
>  	pa = node->paddr + sizeof(struct setup_data) + pos;
>  	pg = pfn_to_page((pa + count - 1) >> PAGE_SHIFT);
> -	if (PageHighMem(pg)) {

Why is it ok to get rid of the PageHighMem() check?

Btw, we did talk earlier in the thread about making __va() clear the SME
mask and then you won't really need to change stuff here. Or?

-- 
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.

[toc] | [next] | [standalone]


#1483418

FromBorislav Petkov <bp@alien8.de>
Date2016-09-14 17:00 +0200
Message-ID<shjPk-27U-19@gated-at.bofh.it>
In reply to#1481555
On Wed, Sep 14, 2016 at 09:29:41AM -0500, Tom Lendacky wrote:
> This is still required because just using the __va() would still cause
> the mapping created to have the encryption bit set. The ioremap call
> will result in the mapping not having the encryption bit set.

I meant this: https://lkml.kernel.org/r/20160902181447.GA25328@nazgul.tnic

Wouldn't simply clearing the SME mask work?

#define __va(x)			((void *)(((unsigned long)(x)+PAGE_OFFSET) & ~sme_me_mask))

Or are you saying, one needs the whole noodling through ioremap_cache()
because the data is already encrypted and accessing it with sme_me_mask
cleared would simply give you the encrypted garbage?

-- 
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.
--

[toc] | [prev] | [next] | [standalone]


#1484719

FromBorislav Petkov <bp@alien8.de>
Date2016-09-16 09:20 +0200
Message-ID<shVBf-1un-15@gated-at.bofh.it>
In reply to#1483418
On Thu, Sep 15, 2016 at 12:08:04PM -0500, Tom Lendacky wrote:
> The problem is that this physical address does not contain the
> encryption bit, and even if it did, it wouldn't matter.  The __va()
> define creates a virtual address that will be mapped as encrypted given
> the current approach (which is how I found this).  It's only ioremap()
> that would create a mapping without the encryption attribute and since
> this is unencrypted data it needs to be access accordingly.

I see. So since this is not obvious, please add this explanation to maybe

Documentation/x86/amd-memory-encryption.txt

and point in there to an example or so so.

Thanks.

-- 
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.
--

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web