Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp739355ybb; Wed, 25 Mar 2020 08:41:45 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvwdDvFCGM6DV321X8Qa4ZRLd5OTycV/+T7OBMkzCVHfVCeez5m2T/c8oFmoVbqxOnSdrXc X-Received: by 2002:aca:3386:: with SMTP id z128mr2964253oiz.40.1585150905827; Wed, 25 Mar 2020 08:41:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585150905; cv=none; d=google.com; s=arc-20160816; b=YN9mO7UtbO60Jb8N4Y078D9SfBzggLy041zc8cTUwSPj4DQk1vG4rvKRDFWpuO7N0D H2uHylITQnfxqXG0YNIOVdDgcgw//Z7OXWNpo1rRzFW2JnPpbDVl479eti4+TMJqxdj8 IENjVVVmp6enliDCaRH8174ooeD6mkrGYzvQoZBFtSEAWbephCSGn0fXknfh0AhL1tZm ajR6olqjd/eb8Uvz7Q/t5rLX6ZaukWi8CEzl2Q8FUUgJIjqq01UaIbDu+DEaaugng1Pm Mi9F4U0SmW7md01e2MzA8aX1bHHi9IvtHnRp+xE3YHPbWdh8zX356wWnZ3S0Nhjl+vHb uFAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=YLgTI2CpRGQHZGrpCofrJEh8+eMyo8By5x3TJ6MG1PY=; b=QmSXVHM/4y4Xgv+WXJ3gOX9jsMiA/ETu2klaTmnAk/6eG9fNi53GXSIhG4B1kEHMT7 e9moEp6NtzJrzPNr9iwYOY5RXEZTCn3tuyQPi5bd5W5erwSFEjHlRhFIGMVfxjMZw6M8 6jkmzVL5d0oraW4QHVjI6DeTAR71WXuL9t6vYNDB/zYn8eFZ8j5wZR4Fs8dA++aTURiy pH1WidUISdV9o19G3bNyxV13gqVJe63jIV8G0c/HS0d6fecacXOGP+epsgQvesl15RWP kwMhK97g6U6yzQdcBg5D4ZsMMVtdD4GszZmdvWhzoK7q1KxVFFSWiZHxB4stT+zFay4h YvCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=YKro6Bqi; 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=alien8.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d1si3713266otq.225.2020.03.25.08.41.32; Wed, 25 Mar 2020 08:41:45 -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=@alien8.de header.s=dkim header.b=YKro6Bqi; 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=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728043AbgCYPjy (ORCPT + 99 others); Wed, 25 Mar 2020 11:39:54 -0400 Received: from mail.skyhub.de ([5.9.137.197]:52226 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728016AbgCYPjx (ORCPT ); Wed, 25 Mar 2020 11:39:53 -0400 Received: from zn.tnic (p200300EC2F0B0600F597EAD9BBACC1F1.dip0.t-ipconnect.de [IPv6:2003:ec:2f0b:600:f597:ead9:bbac:c1f1]) (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 8D21B1EC0CED; Wed, 25 Mar 2020 16:39:51 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1585150791; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=YLgTI2CpRGQHZGrpCofrJEh8+eMyo8By5x3TJ6MG1PY=; b=YKro6Bqi33g4OHFZ5pL3ZedugLCCMsqNc56KydrYYPmTZwI5yzA29xDRUlbxZ71yRHbxhJ O8WCiyRUuE7ZmsnnidZSJYCLqpT1bK659/zS0D4NGl8ZKvcUgKbNbKczkekYXN5birVDUi /hoEo8RwhFmXVb2/Y8AGlyzFItQ9C1M= Date: Wed, 25 Mar 2020 16:39:45 +0100 From: Borislav Petkov To: Joerg Roedel Cc: 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: <20200325153945.GD27261@zn.tnic> References: <20200319091407.1481-1-joro@8bytes.org> <20200319091407.1481-6-joro@8bytes.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200319091407.1481-6-joro@8bytes.org> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org + 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. > > 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" > + > + 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)" > + 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" > } > > diff --git a/tools/arch/x86/tools/gen-insn-attr-x86.awk b/tools/arch/x86/tools/gen-insn-attr-x86.awk > index a42015b305f4..af38469afd14 100644 > --- a/tools/arch/x86/tools/gen-insn-attr-x86.awk > +++ b/tools/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" > + > + 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)" > + 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" > } > > -- > 2.17.1 > -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette