Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2030178ybb; Thu, 26 Mar 2020 20:03:52 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvjgT62k0Ehk+lp89cWxT1jgKml1lGitFWzGOoeK/YEOjMbzgokpKJPhRP2y1D69HldGH18 X-Received: by 2002:a4a:674f:: with SMTP id j15mr1940559oof.41.1585278232742; Thu, 26 Mar 2020 20:03:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585278232; cv=none; d=google.com; s=arc-20160816; b=k/IZGrwgd5LD5BjGkmopGmGm96ir+PmAexyL92pxUk8cPz3NloqI7HJu7qMYTG2A6Y Ye4WDQ35jdrtT+/yb3BMUeZVyWAWOXtKoN/2mO6qiaSvYPYWQNe2siRLTyC4EV+yBfcc k8owES7jIgZCA53gbqY52WBs8313nOO5nDAVulorieeEWDoKHrlzFUiLw7LLk5G3LCos 3FROVwk7VfKfCPaI25Sn4VyJKjhZYs3H/ZfoR5ktGyhNIZGvuSewfTHJIrmikkpUdp9k MhclHVRlwDJxU62AAt7DoV/2nQxElIUC/Zf5slzgPlzGOYZctXhsE4pXIoKSUeZ5unt/ reGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=E9wMl6cC30ZbsVMMAIgrg6iknlddFZcs6nbVFdK4dnU=; b=wRfNRcMw5WydDnnobF2L8T01i+F1TKIb27o0Je7uGkz2K1I8iJYkzCUAQC1+aTwic+ Xshqm08Yu6sUpieGoWphZ+euXSQJWmkL5miteoT1uNZgevzvIPLh8HTBRHZDQmrPJKS+ E5pPZ+scpRZbxBFlSjs4hEc406SbDjxkmm0Sm+fOpWWp7AGSbIDFQ845XmweOezzNj0p /SbXLyzAhyDCGH2WIW6AxHiQM4i0P1PgLxUSMmDp9MhM4iIhoreFiTPU2pbUi356+CUl vwqt5NpvFFyHUEY0v0ez1qM0nWESOTX1kor/q4sKYTexzj+hud3WeUvOzkbXHFupiEwn vo2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rniJm74H; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z78si1909214oia.200.2020.03.26.20.03.40; Thu, 26 Mar 2020 20:03: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; dkim=pass header.i=@kernel.org header.s=default header.b=rniJm74H; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727821AbgC0DDC (ORCPT + 99 others); Thu, 26 Mar 2020 23:03:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:42064 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726496AbgC0DDC (ORCPT ); Thu, 26 Mar 2020 23:03:02 -0400 Received: from devnote2 (NE2965lan1.rev.em-net.ne.jp [210.141.244.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4CA9C20787; Fri, 27 Mar 2020 03:02:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585278181; bh=b2ccDeO/pD0R+Y+srohROcyVA9Q145YuMgSh8oAXLmM=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=rniJm74HvN/lsrQkGt9EY0ampwZGukQI1mGNUHZ+Y1qgVosyqSmxQh7Y/aB0kiHUd skjYGOhr0dmRm2/Rkd2IbLKBHC5ii1/ZdoWPnM2LYGCid8jJUA+iigEapBxQLUIJVy je1LuCvKfE6zYULbGOvvJ9u/UCVNUeI2v0ouqBgk= Date: Fri, 27 Mar 2020 12:02:32 +0900 From: Masami Hiramatsu To: Borislav Petkov , Joerg Roedel Cc: Joerg Roedel , x86@kernel.org, hpa@zytor.com, Andy Lutomirski , Dave Hansen , Peter Zijlstra , Thomas Hellstrom , Jiri Slaby , Dan Williams , Tom Lendacky , Juergen Gross , Kees Cook , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, Joerg Roedel , Masami Hiramatsu Subject: Re: [PATCH 05/70] x86/insn: Make inat-tables.c suitable for pre-decompression code Message-Id: <20200327120232.c8e455ca100dc0d96e4ddc43@kernel.org> In-Reply-To: <20200325153945.GD27261@zn.tnic> References: <20200319091407.1481-1-joro@8bytes.org> <20200319091407.1481-6-joro@8bytes.org> <20200325153945.GD27261@zn.tnic> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.32; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Wed, 25 Mar 2020 16:39:45 +0100 Borislav Petkov wrote: > + Masami. > > On Thu, Mar 19, 2020 at 10:13:02AM +0100, Joerg Roedel wrote: > > From: Joerg Roedel > > > > The inat-tables.c file has some arrays in it that contain pointers to > > other arrays. These pointers need to be relocated when the kernel > > image is moved to a different location. > > > > The pre-decompression boot-code has no support for applying ELF > > relocations, so initialize these arrays at runtime in the > > pre-decompression code to make sure all pointers are correctly > > initialized. I need to check the whole series, but as far as I can understand from this patch, this seems not allowing to store the address value in static pointers. It may break more things, for example _kprobe_blacklist records the NOKPROBE_SYMBOL() symbol addresses at the build time. I have some comments here. > > Signed-off-by: Joerg Roedel > > --- > > arch/x86/tools/gen-insn-attr-x86.awk | 50 +++++++++++++++++++++- > > tools/arch/x86/tools/gen-insn-attr-x86.awk | 50 +++++++++++++++++++++- > > 2 files changed, 98 insertions(+), 2 deletions(-) > > > > diff --git a/arch/x86/tools/gen-insn-attr-x86.awk b/arch/x86/tools/gen-insn-attr-x86.awk > > index a42015b305f4..af38469afd14 100644 > > --- a/arch/x86/tools/gen-insn-attr-x86.awk > > +++ b/arch/x86/tools/gen-insn-attr-x86.awk > > @@ -362,6 +362,9 @@ function convert_operands(count,opnd, i,j,imm,mod) > > END { > > if (awkchecked != "") > > exit 1 > > + > > + print "#ifndef __BOOT_COMPRESSED\n" > > + > > # print escape opcode map's array > > print "/* Escape opcode map array */" > > print "const insn_attr_t * const inat_escape_tables[INAT_ESC_MAX + 1]" \ > > @@ -388,6 +391,51 @@ END { > > for (j = 0; j < max_lprefix; j++) > > if (atable[i,j]) > > print " ["i"]["j"] = "atable[i,j]"," > > - print "};" > > + print "};\n" > > + > > + print "#else /* !__BOOT_COMPRESSED */\n" I think the definitions of inat_*_tables can be shared in both case. If __BOOT_COMPRESSED is set, we can define inat_init_tables() as a initialize function, and if not, it will be just a dummy "do {} while (0)". BTW, where is the __BOOT_COMPRESSED defined? > > + > > + print "/* Escape opcode map array */" > > + print "static const insn_attr_t *inat_escape_tables[INAT_ESC_MAX + 1]" \ > > + "[INAT_LSTPFX_MAX + 1];" > > + print "" > > + > > + print "/* Group opcode map array */" > > + print "static const insn_attr_t *inat_group_tables[INAT_GRP_MAX + 1]"\ > > + "[INAT_LSTPFX_MAX + 1];" > > + print "" > > + > > + print "/* AVX opcode map array */" > > + print "static const insn_attr_t *inat_avx_tables[X86_VEX_M_MAX + 1]"\ > > + "[INAT_LSTPFX_MAX + 1];" > > + print "" > > + > > + print "static void inat_init_tables(void)" This functions should be "inline". And I can not see the call-site of inat_init_tables() in this patch. If possible, please include call-site with definition (especially new init function) so that I can check the init call timing too. > > + print "{" > > + > > + # print escape opcode map's array > > + print "\t/* Print Escape opcode map array */" > > + for (i = 0; i < geid; i++) > > + for (j = 0; j < max_lprefix; j++) > > + if (etable[i,j]) > > + print "\tinat_escape_tables["i"]["j"] = "etable[i,j]";" > > + print "" > > + > > + # print group opcode map's array > > + print "\t/* Print Group opcode map array */" > > + for (i = 0; i < ggid; i++) > > + for (j = 0; j < max_lprefix; j++) > > + if (gtable[i,j]) > > + print "\tinat_group_tables["i"]["j"] = "gtable[i,j]";" > > + print "" > > + # print AVX opcode map's array > > + print "\t/* Print AVX opcode map array */" > > + for (i = 0; i < gaid; i++) > > + for (j = 0; j < max_lprefix; j++) > > + if (atable[i,j]) > > + print "\tinat_avx_tables["i"]["j"] = "atable[i,j]";" > > + > > + print "}" > > + print "#endif" > > } The code itself looks good to me. Thank you, -- Masami Hiramatsu