From patchwork Sun May 21 07:16:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Borislav Petkov X-Patchwork-Id: 9738905 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2D78E60326 for ; Sun, 21 May 2017 07:17:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1DE7B2869C for ; Sun, 21 May 2017 07:17:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 11F892869F; Sun, 21 May 2017 07:17:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BAAA52869C for ; Sun, 21 May 2017 07:17:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751821AbdEUHRF (ORCPT ); Sun, 21 May 2017 03:17:05 -0400 Received: from mail.skyhub.de ([5.9.137.197]:55530 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750998AbdEUHRD (ORCPT ); Sun, 21 May 2017 03:17:03 -0400 X-Virus-Scanned: Nedap ESD1 at mail.skyhub.de Received: from mail.skyhub.de ([127.0.0.1]) by localhost (blast.alien8.de [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id huZIj1nu-idl; Sun, 21 May 2017 09:17:01 +0200 (CEST) Received: from pd.tnic (p2003008C2F2EA700D00117B391B7F7F2.dip0.t-ipconnect.de [IPv6:2003:8c:2f2e:a700:d001:17b3:91b7:f7f2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 358931EC03B9; Sun, 21 May 2017 09:17:01 +0200 (CEST) Date: Sun, 21 May 2017 09:16:50 +0200 From: Borislav Petkov 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, kexec@lists.infradead.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 , Larry Woodman , Brijesh Singh , Ingo Molnar , Andy Lutomirski , "H. Peter Anvin" , Andrey Ryabinin , Alexander Potapenko , Dave Young , Thomas Gleixner , Dmitry Vyukov Subject: Re: [PATCH v5 17/32] x86/mm: Add support to access boot related data in the clear Message-ID: <20170521071650.pwwmw4agggaazfrh@pd.tnic> References: <20170418211612.10190.82788.stgit@tlendack-t1.amdoffice.net> <20170418211921.10190.1537.stgit@tlendack-t1.amdoffice.net> <20170515183517.mb4k2gp2qobbuvtm@pd.tnic> <4845df29-bae7-9b78-0428-ff96dbef2128@amd.com> <20170518090212.kebstmnjv4h3cjf2@pd.tnic> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Fri, May 19, 2017 at 03:50:32PM -0500, Tom Lendacky wrote: > The "worker" function would be doing the loop through the setup data, > but since the setup data is mapped inside the loop I can't do the __init > calling the non-init function and still hope to consolidate the code. > Maybe I'm missing something here... Hmm, I see what you mean. But the below change ontop doesn't fire any warnings here. Maybe your .config has something set which I don't... diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c index 55317ba3b6dc..199c983192ae 100644 --- a/arch/x86/mm/ioremap.c +++ b/arch/x86/mm/ioremap.c @@ -515,71 +515,50 @@ static bool memremap_is_efi_data(resource_size_t phys_addr, * Examine the physical address to determine if it is boot data by checking * it against the boot params setup_data chain. */ -static bool memremap_is_setup_data(resource_size_t phys_addr, - unsigned long size) +static bool +__memremap_is_setup_data(resource_size_t phys_addr, unsigned long size, bool early) { struct setup_data *data; u64 paddr, paddr_next; + u32 len; paddr = boot_params.hdr.setup_data; while (paddr) { - bool is_setup_data = false; if (phys_addr == paddr) return true; - data = memremap(paddr, sizeof(*data), - MEMREMAP_WB | MEMREMAP_DEC); + if (early) + data = early_memremap_decrypted(paddr, sizeof(*data)); + else + data = memremap(paddr, sizeof(*data), MEMREMAP_WB | MEMREMAP_DEC); paddr_next = data->next; + len = data->len; - if ((phys_addr > paddr) && (phys_addr < (paddr + data->len))) - is_setup_data = true; + if (early) + early_memunmap(data, sizeof(*data)); + else + memunmap(data); - memunmap(data); - if (is_setup_data) + if ((phys_addr > paddr) && (phys_addr < (paddr + data->len))) return true; paddr = paddr_next; } - return false; } -/* - * Examine the physical address to determine if it is boot data by checking - * it against the boot params setup_data chain (early boot version). - */ static bool __init early_memremap_is_setup_data(resource_size_t phys_addr, unsigned long size) { - struct setup_data *data; - u64 paddr, paddr_next; - - paddr = boot_params.hdr.setup_data; - while (paddr) { - bool is_setup_data = false; - - if (phys_addr == paddr) - return true; - - data = early_memremap_decrypted(paddr, sizeof(*data)); - - paddr_next = data->next; - - if ((phys_addr > paddr) && (phys_addr < (paddr + data->len))) - is_setup_data = true; - - early_memunmap(data, sizeof(*data)); - - if (is_setup_data) - return true; - - paddr = paddr_next; - } + return __memremap_is_setup_data(phys_addr, size, true); +} - return false; +static bool memremap_is_setup_data(resource_size_t phys_addr, unsigned long size) +{ + return __memremap_is_setup_data(phys_addr, size, false); } /*