Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933790AbdCHHKs (ORCPT ); Wed, 8 Mar 2017 02:10:48 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53354 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933376AbdCHHKp (ORCPT ); Wed, 8 Mar 2017 02:10:45 -0500 Date: Wed, 8 Mar 2017 15:09:34 +0800 From: Dave Young To: Tom Lendacky Cc: linux-arch@vger.kernel.org, linux-efi@vger.kernel.org, kvm@vger.kernel.org, linux-doc@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-mm@kvack.org, iommu@lists.linux-foundation.org, Rik van Riel , Radim =?utf-8?B?S3LEjW3DocWZ?= , Toshimitsu Kani , Arnd Bergmann , Jonathan Corbet , Matt Fleming , "Michael S. Tsirkin" , Joerg Roedel , Konrad Rzeszutek Wilk , Paolo Bonzini , Brijesh Singh , Ingo Molnar , Alexander Potapenko , Andy Lutomirski , "H. Peter Anvin" , Borislav Petkov , Andrey Ryabinin , Thomas Gleixner , Larry Woodman , Dmitry Vyukov Subject: Re: [RFC PATCH v4 25/28] x86: Access the setup data through sysfs decrypted Message-ID: <20170308070934.GC11045@dhcp-128-65.nay.redhat.com> References: <20170216154158.19244.66630.stgit@tlendack-t1.amdoffice.net> <20170216154738.19244.37908.stgit@tlendack-t1.amdoffice.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170216154738.19244.37908.stgit@tlendack-t1.amdoffice.net> User-Agent: Mutt/1.7.1 (2016-10-04) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 08 Mar 2017 07:09:53 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3329 Lines: 125 On 02/16/17 at 09:47am, Tom Lendacky wrote: > Use memremap() to map the setup data. This will make the appropriate > decision as to whether a RAM remapping can be done or if a fallback to > ioremap_cache() is needed (similar to the setup data debugfs support). > > Signed-off-by: Tom Lendacky > --- > arch/x86/kernel/ksysfs.c | 27 ++++++++++++++------------- > 1 file changed, 14 insertions(+), 13 deletions(-) > > diff --git a/arch/x86/kernel/ksysfs.c b/arch/x86/kernel/ksysfs.c > index 4afc67f..d653b3e 100644 > --- a/arch/x86/kernel/ksysfs.c > +++ b/arch/x86/kernel/ksysfs.c > @@ -16,6 +16,7 @@ > #include > #include > #include > +#include > > #include > #include > @@ -79,12 +80,12 @@ static int get_setup_data_paddr(int nr, u64 *paddr) > *paddr = pa_data; > return 0; > } > - data = ioremap_cache(pa_data, sizeof(*data)); > + data = memremap(pa_data, sizeof(*data), MEMREMAP_WB); > if (!data) > return -ENOMEM; > > pa_data = data->next; > - iounmap(data); > + memunmap(data); > i++; > } > return -EINVAL; > @@ -97,17 +98,17 @@ static int __init get_setup_data_size(int nr, size_t *size) > u64 pa_data = boot_params.hdr.setup_data; > > while (pa_data) { > - data = ioremap_cache(pa_data, sizeof(*data)); > + data = memremap(pa_data, sizeof(*data), MEMREMAP_WB); > if (!data) > return -ENOMEM; > if (nr == i) { > *size = data->len; > - iounmap(data); > + memunmap(data); > return 0; > } > > pa_data = data->next; > - iounmap(data); > + memunmap(data); > i++; > } > return -EINVAL; > @@ -127,12 +128,12 @@ static ssize_t type_show(struct kobject *kobj, > ret = get_setup_data_paddr(nr, &paddr); > if (ret) > return ret; > - data = ioremap_cache(paddr, sizeof(*data)); > + data = memremap(paddr, sizeof(*data), MEMREMAP_WB); > if (!data) > return -ENOMEM; > > ret = sprintf(buf, "0x%x\n", data->type); > - iounmap(data); > + memunmap(data); > return ret; > } > > @@ -154,7 +155,7 @@ static ssize_t setup_data_data_read(struct file *fp, > ret = get_setup_data_paddr(nr, &paddr); > if (ret) > return ret; > - data = ioremap_cache(paddr, sizeof(*data)); > + data = memremap(paddr, sizeof(*data), MEMREMAP_WB); > if (!data) > return -ENOMEM; > > @@ -170,15 +171,15 @@ static ssize_t setup_data_data_read(struct file *fp, > goto out; > > ret = count; > - p = ioremap_cache(paddr + sizeof(*data), data->len); > + p = memremap(paddr + sizeof(*data), data->len, MEMREMAP_WB); > if (!p) { > ret = -ENOMEM; > goto out; > } > memcpy(buf, p + off, count); > - iounmap(p); > + memunmap(p); > out: > - iounmap(data); > + memunmap(data); > return ret; > } > > @@ -250,13 +251,13 @@ static int __init get_setup_data_total_num(u64 pa_data, int *nr) > *nr = 0; > while (pa_data) { > *nr += 1; > - data = ioremap_cache(pa_data, sizeof(*data)); > + data = memremap(pa_data, sizeof(*data), MEMREMAP_WB); > if (!data) { > ret = -ENOMEM; > goto out; > } > pa_data = data->next; > - iounmap(data); > + memunmap(data); > } > > out: > It would be better that these cleanup patches are sent separately. Acked-by: Dave Young Thanks Dave