Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp5525921imm; Tue, 19 Jun 2018 11:49:52 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJt/a5hwG2nSwr6R+RmHyZCqUvRRMlvLnB246MRB+J3bVsxCXJJmEnqxZZTTlcIb0MPWIf8 X-Received: by 2002:a65:4607:: with SMTP id v7-v6mr15782652pgq.31.1529434192725; Tue, 19 Jun 2018 11:49:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529434192; cv=none; d=google.com; s=arc-20160816; b=j4MsG6qtCs07/FDMM6zVbrCEzhZahJZi7t8O65O9I7/FdttBNFqeM3sEH+ozdexBdS omcknZm7BUvvwQ17NdkFbCq38IB2zHB+2gNkI/RiJUr0BZDUIFBxMSIrvCSfDpk5VbN3 ZwkYdAvyp6x0dikEz2z7Xs/rrn/Avn/mtvko/ffHIKCTBGPylSVbEDScMnDqoVsGDfx/ vLNqfOLYbf3/QH48k2Fbx9tEfodIwVAqzyNsgORnmtCRIKRoFP+5DWXQmYvu9N9wf3jx nZmUMzLJqI3tR8HTzpE6h4q8pNASGYvNhrkYZrSZ2tyDy9ppI0DscwCpQ79WhCi4pXZC Ezeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=oMOkN0D+lJyJwgWrFk9WQTilrblLmwkOzIEv82YHoyU=; b=VBnmO71Eg00TSeanu5VmL+sViX6mGqi8eBeJfh/eb3SvTgRSav4vuX/13GyQlKxu4T dfzau/gBRT8IAi7cARhhnbpfc4Edqnmw8b5/Tr5Mu7Fm5oUVL8Fvxi2Ow8mSaDx65vU9 hDCuM6XRaL7R3pJpbW4fsgtE/dh66AtHqv4eJqhbL9+U7xOLRWK9bICTAvj2i3NXw6jK Gp60DUwxeYnioSiejUThsS9mMQVlE1Rk0UJSYp2z6BKGzErkzKlH3uytsYIFLtwPDi3/ WFcuxKyf3dxW8nlB2hbwaEnT8Rxgt6FxJdo2XgckDFgK7WVvbJ3YBkRUuuvFUVINLzSE t5kQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l14-v6si311291pgs.155.2018.06.19.11.49.38; Tue, 19 Jun 2018 11:49:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030495AbeFSSr6 (ORCPT + 99 others); Tue, 19 Jun 2018 14:47:58 -0400 Received: from vps-vb.mhejs.net ([37.28.154.113]:39718 "EHLO vps-vb.mhejs.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030443AbeFSSrx (ORCPT ); Tue, 19 Jun 2018 14:47:53 -0400 Received: by vps-vb.mhejs.net with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1fVLfJ-0003WZ-JM; Tue, 19 Jun 2018 20:47:41 +0200 From: "Maciej S. Szmigiero" To: Borislav Petkov Cc: Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 8/9] x86/microcode/AMD: Convert CPU equivalence table variable into a struct Date: Tue, 19 Jun 2018 20:47:38 +0200 Message-Id: <09cccdaaf4683cc962db83b0ea7523ee99381f1b.1529424596.git.mail@maciej.szmigiero.name> X-Mailer: git-send-email 2.17.0 In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Convert pointer to CPU equivalence table global static variable into a struct descriptor in preparation for tracking also the size of this table. Signed-off-by: Maciej S. Szmigiero --- arch/x86/kernel/cpu/microcode/amd.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/arch/x86/kernel/cpu/microcode/amd.c b/arch/x86/kernel/cpu/microcode/amd.c index 9807e27f8fde..10aabd9d3121 100644 --- a/arch/x86/kernel/cpu/microcode/amd.c +++ b/arch/x86/kernel/cpu/microcode/amd.c @@ -38,7 +38,9 @@ #include #include -static struct equiv_cpu_entry *equiv_cpu_table; +static struct equiv_cpu_table { + struct equiv_cpu_entry *table; +} equiv_table; /* * This points to the current valid container of microcode patches which we will @@ -581,18 +583,18 @@ void reload_ucode_amd(void) static u16 __find_equiv_id(unsigned int cpu) { struct ucode_cpu_info *uci = ucode_cpu_info + cpu; - return find_equiv_id(equiv_cpu_table, uci->cpu_sig.sig); + return find_equiv_id(equiv_table.table, uci->cpu_sig.sig); } static u32 find_cpu_family_by_equiv_cpu(u16 equiv_cpu) { int i = 0; - BUG_ON(!equiv_cpu_table); + BUG_ON(!equiv_table.table); - while (equiv_cpu_table[i].equiv_cpu != 0) { - if (equiv_cpu == equiv_cpu_table[i].equiv_cpu) - return equiv_cpu_table[i].installed_cpu; + while (equiv_table.table[i].equiv_cpu != 0) { + if (equiv_cpu == equiv_table.table[i].equiv_cpu) + return equiv_table.table[i].installed_cpu; i++; } return 0; @@ -731,21 +733,21 @@ static unsigned int install_equiv_cpu_table(const u8 *buf, size_t buf_size) hdr = (const u32 *)buf; equiv_tbl_len = hdr[2]; - equiv_cpu_table = vmalloc(equiv_tbl_len); - if (!equiv_cpu_table) { + equiv_table.table = vmalloc(equiv_tbl_len); + if (!equiv_table.table) { pr_err("failed to allocate equivalent CPU table\n"); return 0; } - memcpy(equiv_cpu_table, buf + CONTAINER_HDR_SZ, equiv_tbl_len); + memcpy(equiv_table.table, buf + CONTAINER_HDR_SZ, equiv_tbl_len); return equiv_tbl_len; } static void free_equiv_cpu_table(void) { - vfree(equiv_cpu_table); - equiv_cpu_table = NULL; + vfree(equiv_table.table); + equiv_table.table = NULL; } static void cleanup(void)