From patchwork Fri Dec 16 15:17:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Borislav Petkov X-Patchwork-Id: 9478025 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 69C5560827 for ; Fri, 16 Dec 2016 15:19:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 59E82285C4 for ; Fri, 16 Dec 2016 15:19:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4C7BB27F86; Fri, 16 Dec 2016 15:19:57 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id AA0BD27F86 for ; Fri, 16 Dec 2016 15:19:56 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cHuGS-0000w4-Uo; Fri, 16 Dec 2016 15:17:40 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cHuGR-0000vv-Pv for xen-devel@lists.xenproject.org; Fri, 16 Dec 2016 15:17:39 +0000 Received: from [85.158.143.35] by server-3.bemta-6.messagelabs.com id 7C/D3-09053-39504585; Fri, 16 Dec 2016 15:17:39 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrNIsWRWlGSWpSXmKPExsVyuP0Ov+4k1pA Ig0M/5S2+b5nM5MDocfjDFZYAxijWzLyk/IoE1owr/d2MBdPUKp7emczcwNgu38XIySEhYCTx duI/JhBbSGAho8TCx8oQdrrE9+WvWEFsFgFViWOXVzCD2GwCShK/P61jB7FFBAwk3l+fxNbFy MXBLNDNKNF64DJQAweHsICVxObXaSA1vAKmElMeLWMGqRESuMEscW71SmaIhKDEyZlPWEBsZg F1iT/zLjGD9DILSEss/8cBEZaXaN46GyzMKWAn8fEs2MmiAioSsy7PYZnAKDALyaBZSAbNQhg 0C8mgBYwsqxg1ilOLylKLdI0M9JKKMtMzSnITM3N0DQ3M9HJTi4sT01NzEpOK9ZLzczcxAgOW AQh2MP5aFnCIUZKDSUmUd/mO4AghvqT8lMqMxOKM+KLSnNTiQ4waHBwCm9euvsAoxZKXn5eqJ MH7lTkkQkiwKDU9tSItMwcYUzClEhw8SiK8p0DSvMUFibnFmekQqVOMilLivDosQAkBkERGaR 5cGyyOLzHKSgnzMgIdJcRTkFqUm1mCKv+KUZyDUUmYdyHIFJ7MvBK46a+AFjMBLbaYFwyyuCQ RISXVwLg/OalucrG5T/g0l0uSK856pK5bNe3BwgerIkXWfvjpXxCc9eZWRvjjJNGww19eh1mZ vZBWmy2wLHvW643PFH+6phbHfvm+N/CYNO+RR9oS31zdvA9obX+/JXr1O40WzfTnygu8Zkpzl obnTJdZl+Su+TCqJzk+tfGcqbTrDG9p3XUrI5wuVSixFGckGmoxFxUnAgBYp8/m3gIAAA== X-Env-Sender: bp@suse.de X-Msg-Ref: server-7.tower-21.messagelabs.com!1481901457!48706249!1 X-Originating-IP: [195.135.220.15] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.1.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 23366 invoked from network); 16 Dec 2016 15:17:38 -0000 Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by server-7.tower-21.messagelabs.com with DHE-RSA-CAMELLIA256-SHA encrypted SMTP; 16 Dec 2016 15:17:38 -0000 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 21E58ABB0; Fri, 16 Dec 2016 15:17:35 +0000 (UTC) Received: by pd.tnic (Postfix, from userid 1000) id D8207160EE6; Fri, 16 Dec 2016 16:17:30 +0100 (CET) Date: Fri, 16 Dec 2016 16:17:30 +0100 From: Borislav Petkov To: Boris Ostrovsky Message-ID: <20161216151730.4y7orcyjknr6ljph@pd.tnic> References: <20161216090228.ri4alokiaagqtibt@pd.tnic> <29d252b8-67ff-bd61-f274-0ed75708cd55@suse.com> <20161216094326.bnkr5a2k3njmdeyi@pd.tnic> <7ca8a9b9-e374-8052-6be3-d3eda78c891a@suse.com> <20161216104505.lk3s7fc7brrnmbq3@pd.tnic> <37c027ee-c6af-2aa2-364b-ed3dcdf8d966@suse.com> <20161216121903.nyskwt2jw2zvpsf6@pd.tnic> <20161216130729.kl5plazudqa5w66d@pd.tnic> <24632cb2-b0e1-fb45-c814-8d567da5bc8a@oracle.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <24632cb2-b0e1-fb45-c814-8d567da5bc8a@oracle.com> User-Agent: NeoMutt/20161014 (1.7.1) Cc: Juergen Gross , xen-devel , Linux Kernel Mailing List Subject: Re: [Xen-devel] Can't boot as Xen dom0 due to commit fe055896 X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP On Fri, Dec 16, 2016 at 09:40:59AM -0500, Boris Ostrovsky wrote: > It works Thanks. Added your Tested-by. > but I think both of the bugs we talked about yesterday still > need to be fixed, they are not related to Xen. For the one issue with the eq_id, I have the below cleanup for all the args passing lined up for testing. For native_cpuid() you could send me a patch. Unless you don't have time, then I can do it myself. diff --git a/arch/x86/kernel/cpu/microcode/amd.c b/arch/x86/kernel/cpu/microcode/amd.c index 6f353bdb3a25..122ed2249367 100644 --- a/arch/x86/kernel/cpu/microcode/amd.c +++ b/arch/x86/kernel/cpu/microcode/amd.c @@ -116,10 +116,11 @@ static inline u16 find_equiv_id(struct equiv_cpu_entry *equiv_cpu_table, /* * This scans the ucode blob for the proper container as we can have multiple - * containers glued together. + * containers glued together. Returns the equivalence ID from the equivalence + * table. */ -static struct container -find_proper_container(u8 *ucode, size_t size, u16 *ret_id) +static u16 +find_proper_container(u8 *ucode, size_t size, struct container *ret_cont) { struct container ret = { NULL, 0 }; u32 eax, ebx, ecx, edx; @@ -138,7 +139,7 @@ find_proper_container(u8 *ucode, size_t size, u16 *ret_id) if (header[0] != UCODE_MAGIC || header[1] != UCODE_EQUIV_CPU_TABLE_TYPE || /* type */ header[2] == 0) /* size */ - return ret; + return eq_id; eax = 0x00000001; ecx = 0; @@ -163,8 +164,9 @@ find_proper_container(u8 *ucode, size_t size, u16 *ret_id) * ucode update loop below */ left = ret.size - offset; - *ret_id = eq_id; - return ret; + + *ret_cont = ret; + return eq_id; } /* @@ -189,7 +191,7 @@ find_proper_container(u8 *ucode, size_t size, u16 *ret_id) ucode = data; } - return ret; + return eq_id; } static int __apply_microcode_amd(struct microcode_amd *mc_amd) @@ -214,17 +216,18 @@ static int __apply_microcode_amd(struct microcode_amd *mc_amd) * and on 32-bit during save_microcode_in_initrd_amd() -- we can call * load_microcode_amd() to save equivalent cpu table and microcode patches in * kernel heap memory. + * + * Returns true if container found (sets @ret_cont), false otherwise. */ -static struct container -apply_microcode_early_amd(void *ucode, size_t size, bool save_patch) +static bool apply_microcode_early_amd(void *ucode, size_t size, bool save_patch, + struct container *ret_cont) { - struct container ret = { NULL, 0 }; u8 (*patch)[PATCH_MAX_SIZE]; + u32 rev, *header, *new_rev; + struct container ret; int offset, left; - u32 rev, *header; - u8 *data; u16 eq_id = 0; - u32 *new_rev; + u8 *data; #ifdef CONFIG_X86_32 new_rev = (u32 *)__pa_nodebug(&ucode_new_rev); @@ -235,11 +238,11 @@ apply_microcode_early_amd(void *ucode, size_t size, bool save_patch) #endif if (check_current_patch_level(&rev, true)) - return (struct container){ NULL, 0 }; + return false; - ret = find_proper_container(ucode, size, &eq_id); + eq_id = find_proper_container(ucode, size, &ret); if (!eq_id) - return (struct container){ NULL, 0 }; + return false; this_equiv_id = eq_id; header = (u32 *)ret.data; @@ -273,7 +276,11 @@ apply_microcode_early_amd(void *ucode, size_t size, bool save_patch) data += offset; left -= offset; } - return ret; + + if (ret_cont) + *ret_cont = ret; + + return true; } static bool get_builtin_microcode(struct cpio_data *cp, unsigned int family) @@ -317,7 +324,7 @@ void __init load_ucode_amd_bsp(unsigned int family) /* Get BSP's CPUID.EAX(1), needed in load_microcode_amd() */ uci->cpu_sig.sig = cpuid_eax(1); - apply_microcode_early_amd(cp.data, cp.size, true); + apply_microcode_early_amd(cp.data, cp.size, true, NULL); } #ifdef CONFIG_X86_32 @@ -349,7 +356,7 @@ void load_ucode_amd_ap(unsigned int family) * This would set amd_ucode_patch above so that the following APs can * use it directly instead of going down this path again. */ - apply_microcode_early_amd(cp.data, cp.size, true); + apply_microcode_early_amd(cp.data, cp.size, true, NULL); } #else void load_ucode_amd_ap(unsigned int family) @@ -387,8 +394,7 @@ void load_ucode_amd_ap(unsigned int family) } } - cont = apply_microcode_early_amd(cp.data, cp.size, false); - if (!(cont.data && cont.size)) { + if (apply_microcode_early_amd(cp.data, cp.size, false, &cont)) { cont.size = -1; return; } @@ -443,7 +449,7 @@ int __init save_microcode_in_initrd_amd(unsigned int fam) return -EINVAL; } - cont = find_proper_container(cp.data, cp.size, &eq_id); + eq_id = find_proper_container(cp.data, cp.size, &cont); if (!eq_id) { cont.size = -1; return -EINVAL;