From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1kcUuZ-0004dV-2K for mharc-grub-devel@gnu.org; Tue, 10 Nov 2020 09:46:19 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:39622) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kcUuX-0004cr-Ug for grub-devel@gnu.org; Tue, 10 Nov 2020 09:46:18 -0500 Received: from 5.mo7.mail-out.ovh.net ([178.32.120.239]:51957) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kcUuV-0002n3-Ob for grub-devel@gnu.org; Tue, 10 Nov 2020 09:46:17 -0500 Received: from player770.ha.ovh.net (unknown [10.108.54.87]) by mo7.mail-out.ovh.net (Postfix) with ESMTP id 121E9182EE5 for ; Tue, 10 Nov 2020 15:46:12 +0100 (CET) Received: from 3mdeb.com (231.85-237-190.tkchopin.pl [85.237.190.231]) (Authenticated sender: krystian.hebel@3mdeb.com) by player770.ha.ovh.net (Postfix) with ESMTPSA id 2D93B181EA673; Tue, 10 Nov 2020 14:46:10 +0000 (UTC) Authentication-Results: garm.ovh; auth=pass (GARM-97G002781552fa-5666-4dc6-8697-dc0ab8079087, 5ACF1FF395264E632C6C78FAA4B0D4185B0C945F) smtp.auth=krystian.hebel@3mdeb.com From: Krystian Hebel To: grub-devel@gnu.org Cc: Norbert Kaminski Subject: [GRUB PATCH RFC 01/22] i386/msr: Merge rdmsr.h and wrmsr.h into msr.h Date: Tue, 10 Nov 2020 15:44:39 +0100 Message-Id: <20201110144500.31606-2-krystian.hebel@3mdeb.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201110144500.31606-1-krystian.hebel@3mdeb.com> References: <20201110144500.31606-1-krystian.hebel@3mdeb.com> X-Ovh-Tracer-Id: 12084283703612726157 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedujedruddujedgieelucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkffojghfsedttdertdertddtnecuhfhrohhmpefmrhihshhtihgrnhcujfgvsggvlhcuoehkrhihshhtihgrnhdrhhgvsggvlhesfehmuggvsgdrtghomheqnecuggftrfgrthhtvghrnhepfeejgeefjeelfeduiedtjefhkeelgfelkefgjeffhedtudfhueehhfduudetleelnecuffhomhgrihhnpehgnhhurdhorhhgnecukfhppedtrddtrddtrddtpdekhedrvdefjedrudeltddrvdefudenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhhouggvpehsmhhtphdqohhuthdphhgvlhhopehplhgrhigvrhejjedtrdhhrgdrohhvhhdrnhgvthdpihhnvghtpedtrddtrddtrddtpdhmrghilhhfrhhomhepkhhrhihsthhirghnrdhhvggsvghlseefmhguvggsrdgtohhmpdhrtghpthhtohepghhruhgsqdguvghvvghlsehgnhhurdhorhhg Received-SPF: pass client-ip=178.32.120.239; envelope-from=krystian.hebel@3mdeb.com; helo=5.mo7.mail-out.ovh.net X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/10 09:46:13 X-ACL-Warn: Detected OS = Linux 3.11 and newer X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Nov 2020 14:46:18 -0000 From: Norbert Kaminski It does not make sense to have separate headers for separate static functions. Additionally, we have to add some constants with MSR addresses in subsequent patches. So, make one common place to store them. Signed-off-by: Daniel Kiper Signed-off-by: Norbert Kaminski --- grub-core/commands/i386/rdmsr.c | 2 +- grub-core/commands/i386/wrmsr.c | 2 +- include/grub/i386/{wrmsr.h => msr.h} | 16 +++++++++--- include/grub/i386/rdmsr.h | 37 ---------------------------- 4 files changed, 15 insertions(+), 42 deletions(-) rename include/grub/i386/{wrmsr.h => msr.h} (78%) delete mode 100644 include/grub/i386/rdmsr.h diff --git a/grub-core/commands/i386/rdmsr.c b/grub-core/commands/i386/rdmsr.c index 46c4346da1b6..fa4622f9e8a1 100644 --- a/grub-core/commands/i386/rdmsr.c +++ b/grub-core/commands/i386/rdmsr.c @@ -26,7 +26,7 @@ #include #include #include -#include +#include GRUB_MOD_LICENSE("GPLv3+"); diff --git a/grub-core/commands/i386/wrmsr.c b/grub-core/commands/i386/wrmsr.c index fa76f5aed117..9b7abba7cf27 100644 --- a/grub-core/commands/i386/wrmsr.c +++ b/grub-core/commands/i386/wrmsr.c @@ -26,7 +26,7 @@ #include #include #include -#include +#include GRUB_MOD_LICENSE("GPLv3+"); diff --git a/include/grub/i386/wrmsr.h b/include/grub/i386/msr.h similarity index 78% rename from include/grub/i386/wrmsr.h rename to include/grub/i386/msr.h index dea60aed1fc0..7b52b5d61229 100644 --- a/include/grub/i386/wrmsr.h +++ b/include/grub/i386/msr.h @@ -16,14 +16,24 @@ * along with GRUB. If not, see . */ -#ifndef GRUB_WRMSR_H -#define GRUB_WRMSR_H 1 +#ifndef GRUB_I386_MSR_H +#define GRUB_I386_MSR_H 1 /* * TODO: Add a general protection exception handler. * Accessing a reserved or unimplemented MSR address results in a GP#. */ +static inline grub_uint64_t +grub_msr_read (grub_uint32_t msr_id) +{ + grub_uint32_t low, high; + + asm volatile ("rdmsr" : "=a" (low), "=d" (high) : "c" (msr_id)); + + return ((grub_uint64_t) high << 32) | low; +} + static inline void grub_msr_write(grub_uint32_t msr_id, grub_uint64_t msr_value) { @@ -32,4 +42,4 @@ grub_msr_write(grub_uint32_t msr_id, grub_uint64_t msr_value) asm volatile ("wrmsr" : : "c" (msr_id), "a" (low), "d" (high)); } -#endif /* GRUB_WRMSR_H */ +#endif /* GRUB_I386_MSR_H */ diff --git a/include/grub/i386/rdmsr.h b/include/grub/i386/rdmsr.h deleted file mode 100644 index c0a0c717a0e9..000000000000 --- a/include/grub/i386/rdmsr.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * GRUB -- GRand Unified Bootloader - * Copyright (C) 2019 Free Software Foundation, Inc. - * - * GRUB is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * GRUB is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GRUB. If not, see . - */ - -#ifndef GRUB_RDMSR_H -#define GRUB_RDMSR_H 1 - -/* - * TODO: Add a general protection exception handler. - * Accessing a reserved or unimplemented MSR address results in a GP#. - */ - -static inline grub_uint64_t -grub_msr_read (grub_uint32_t msr_id) -{ - grub_uint32_t low, high; - - asm volatile ("rdmsr" : "=a" (low), "=d" (high) : "c" (msr_id)); - - return ((grub_uint64_t)high << 32) | low; -} - -#endif /* GRUB_RDMSR_H */ -- 2.17.1