lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <98ca8669-ddf0-b77c-8608-99bb5188cf73@amd.com>
Date:   Fri, 17 Mar 2017 14:54:56 -0500
From:   Tom Lendacky <thomas.lendacky@....com>
To:     Dave Young <dyoung@...hat.com>
CC:     <linux-arch@...r.kernel.org>, <linux-efi@...r.kernel.org>,
        <kvm@...r.kernel.org>, <linux-doc@...r.kernel.org>,
        <x86@...nel.org>, <linux-kernel@...r.kernel.org>,
        <kasan-dev@...glegroups.com>, <linux-mm@...ck.org>,
        <iommu@...ts.linux-foundation.org>, Rik van Riel <riel@...hat.com>,
        Radim Krčmář <rkrcmar@...hat.com>,
        Toshimitsu Kani <toshi.kani@....com>,
        Arnd Bergmann <arnd@...db.de>,
        Jonathan Corbet <corbet@....net>,
        Matt Fleming <matt@...eblueprint.co.uk>,
        "Michael S. Tsirkin" <mst@...hat.com>,
        Joerg Roedel <joro@...tes.org>,
        Konrad Rzeszutek Wilk <konrad.wilk@...cle.com>,
        Paolo Bonzini <pbonzini@...hat.com>,
        Brijesh Singh <brijesh.singh@....com>,
        Ingo Molnar <mingo@...hat.com>,
        Alexander Potapenko <glider@...gle.com>,
        Andy Lutomirski <luto@...nel.org>,
        "H. Peter Anvin" <hpa@...or.com>, Borislav Petkov <bp@...en8.de>,
        Andrey Ryabinin <aryabinin@...tuozzo.com>,
        Thomas Gleixner <tglx@...utronix.de>,
        Larry Woodman <lwoodman@...hat.com>,
        Dmitry Vyukov <dvyukov@...gle.com>
Subject: Re: [RFC PATCH v4 24/28] x86: Access the setup data through debugfs
 decrypted

On 3/8/2017 1:04 AM, Dave Young wrote:
> On 02/16/17 at 09:47am, Tom Lendacky wrote:
>> Use memremap() to map the setup data.  This simplifies the code and will
>> make the appropriate decision as to whether a RAM remapping can be done
>> or if a fallback to ioremap_cache() is needed (which includes checking
>> PageHighMem).
>>
>> Signed-off-by: Tom Lendacky <thomas.lendacky@....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..c3d354d 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)) {
>> -		p = ioremap_cache(pa, count);
>> -		if (!p)
>> -			return -ENXIO;
>> -	} else
>> -		p = __va(pa);
>> +	p = memremap(pa, count, MEMREMAP_WB);
>> +	if (!p)
>> +		return -ENXIO;
>
> -ENOMEM looks better for memremap, ditto for other places..

Makes sense, I'll change them.

Thanks,
Tom

>
>>
>>  	remain = copy_to_user(user_buf, p, count);
>>
>> -	if (PageHighMem(pg))
>> -		iounmap(p);
>> +	memunmap(p);
>>
>>  	if (remain)
>>  		return -EFAULT;
>> @@ -127,15 +123,12 @@ static int __init create_setup_data_nodes(struct dentry *parent)
>>  		}
>>
>>  		pg = pfn_to_page((pa_data+sizeof(*data)-1) >> PAGE_SHIFT);
>> -		if (PageHighMem(pg)) {
>> -			data = ioremap_cache(pa_data, sizeof(*data));
>> -			if (!data) {
>> -				kfree(node);
>> -				error = -ENXIO;
>> -				goto err_dir;
>> -			}
>> -		} else
>> -			data = __va(pa_data);
>> +		data = memremap(pa_data, sizeof(*data), MEMREMAP_WB);
>> +		if (!data) {
>> +			kfree(node);
>> +			error = -ENXIO;
>> +			goto err_dir;
>> +		}
>>
>>  		node->paddr = pa_data;
>>  		node->type = data->type;
>> @@ -143,8 +136,7 @@ static int __init create_setup_data_nodes(struct dentry *parent)
>>  		error = create_setup_data_node(d, no, node);
>>  		pa_data = data->next;
>>
>> -		if (PageHighMem(pg))
>> -			iounmap(data);
>> +		memunmap(data);
>>  		if (error)
>>  			goto err_dir;
>>  		no++;
>>
>
> Thanks
> Dave
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ