All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/2] Replace __asm__ __volatile__ with asm volatile.
@ 2019-03-01 17:17 Jesús Diéguez Fernández
  2019-03-01 17:17 ` [PATCH v2 2/2] Add new MSR modules (rdmsr/wrmsr) Jesús Diéguez Fernández
  2019-03-05 10:45 ` [PATCH v2 1/2] Replace __asm__ __volatile__ with asm volatile Daniel Kiper
  0 siblings, 2 replies; 10+ messages in thread
From: Jesús Diéguez Fernández @ 2019-03-01 17:17 UTC (permalink / raw)
  To: grub-devel; +Cc: Jesús Diéguez Fernández

In order to maintain the coding style consistency, it was requested to
replace the methods that use __asm__ __volatile__ with asm volatile.

Signed-off-by: Jesús Diéguez Fernández <jesusdf@gmail.com>
---
 grub-core/efiemu/runtime/efiemu.c | 10 +++++-----
 grub-core/lib/i386/halt.c         |  2 +-
 include/grub/arm/time.h           |  2 +-
 include/grub/arm64/time.h         |  2 +-
 include/grub/i386/io.h            | 12 ++++++------
 include/grub/i386/time.h          |  2 +-
 include/grub/i386/tsc.h           |  2 +-
 include/grub/x86_64/time.h        |  2 +-
 8 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/grub-core/efiemu/runtime/efiemu.c b/grub-core/efiemu/runtime/efiemu.c
index d923e409f..5db1f347b 100644
--- a/grub-core/efiemu/runtime/efiemu.c
+++ b/grub-core/efiemu/runtime/efiemu.c
@@ -174,17 +174,17 @@ efiemu_memset (grub_uint8_t *a, grub_uint8_t b, grub_size_t n)
 static inline void
 write_cmos (grub_uint8_t addr, grub_uint8_t val)
 {
-  __asm__ __volatile__ ("outb %%al,$0x70\n"
-			"mov %%cl, %%al\n"
-			"outb %%al,$0x71": :"a" (addr), "c" (val));
+  asm volatile ("outb %%al,$0x70\n"
+		"mov %%cl, %%al\n"
+		"outb %%al,$0x71": :"a" (addr), "c" (val));
 }
 
 static inline grub_uint8_t
 read_cmos (grub_uint8_t addr)
 {
   grub_uint8_t ret;
-  __asm__ __volatile__ ("outb %%al, $0x70\n"
-			"inb $0x71, %%al": "=a"(ret) :"a" (addr));
+  asm volatile ("outb %%al, $0x70\n"
+		"inb $0x71, %%al": "=a"(ret) :"a" (addr));
   return ret;
 }
 
diff --git a/grub-core/lib/i386/halt.c b/grub-core/lib/i386/halt.c
index 9f8405494..2364fe4d7 100644
--- a/grub-core/lib/i386/halt.c
+++ b/grub-core/lib/i386/halt.c
@@ -66,7 +66,7 @@ grub_halt (void)
 #endif
 
   /* Disable interrupts.  */
-  __asm__ __volatile__ ("cli");
+  asm volatile ("cli");
 
   /* Bochs, QEMU, etc. Removed in newer QEMU releases.  */
   for (i = 0; i < sizeof (bochs_shutdown) - 1; i++)
diff --git a/include/grub/arm/time.h b/include/grub/arm/time.h
index 4128506cb..c5a685225 100644
--- a/include/grub/arm/time.h
+++ b/include/grub/arm/time.h
@@ -23,7 +23,7 @@ static __inline void
 grub_cpu_idle (void)
 {
   /* FIXME: this can't work until we handle interrupts.  */
-/*  __asm__ __volatile__ ("wfi"); */
+/*  asm volatile ("wfi"); */
 }
 
 #endif /* ! KERNEL_CPU_TIME_HEADER */
diff --git a/include/grub/arm64/time.h b/include/grub/arm64/time.h
index 4128506cb..c5a685225 100644
--- a/include/grub/arm64/time.h
+++ b/include/grub/arm64/time.h
@@ -23,7 +23,7 @@ static __inline void
 grub_cpu_idle (void)
 {
   /* FIXME: this can't work until we handle interrupts.  */
-/*  __asm__ __volatile__ ("wfi"); */
+/*  asm volatile ("wfi"); */
 }
 
 #endif /* ! KERNEL_CPU_TIME_HEADER */
diff --git a/include/grub/i386/io.h b/include/grub/i386/io.h
index ae12a3e3d..e9cd80957 100644
--- a/include/grub/i386/io.h
+++ b/include/grub/i386/io.h
@@ -28,7 +28,7 @@ grub_inb (unsigned short int port)
 {
   unsigned char _v;
 
-  __asm__ __volatile__ ("inb %w1,%0":"=a" (_v):"Nd" (port));
+  asm volatile ("inb %w1,%0":"=a" (_v):"Nd" (port));
   return _v;
 }
 
@@ -37,7 +37,7 @@ grub_inw (unsigned short int port)
 {
   unsigned short _v;
 
-  __asm__ __volatile__ ("inw %w1,%0":"=a" (_v):"Nd" (port));
+  asm volatile ("inw %w1,%0":"=a" (_v):"Nd" (port));
   return _v;
 }
 
@@ -46,27 +46,27 @@ grub_inl (unsigned short int port)
 {
   unsigned int _v;
 
-  __asm__ __volatile__ ("inl %w1,%0":"=a" (_v):"Nd" (port));
+  asm volatile ("inl %w1,%0":"=a" (_v):"Nd" (port));
   return _v;
 }
 
 static __inline void
 grub_outb (unsigned char value, unsigned short int port)
 {
-  __asm__ __volatile__ ("outb %b0,%w1": :"a" (value), "Nd" (port));
+  asm volatile ("outb %b0,%w1": :"a" (value), "Nd" (port));
 }
 
 static __inline void
 grub_outw (unsigned short int value, unsigned short int port)
 {
-  __asm__ __volatile__ ("outw %w0,%w1": :"a" (value), "Nd" (port));
+  asm volatile ("outw %w0,%w1": :"a" (value), "Nd" (port));
 
 }
 
 static __inline void
 grub_outl (unsigned int value, unsigned short int port)
 {
-  __asm__ __volatile__ ("outl %0,%w1": :"a" (value), "Nd" (port));
+  asm volatile ("outl %0,%w1": :"a" (value), "Nd" (port));
 }
 
 #endif /* _SYS_IO_H */
diff --git a/include/grub/i386/time.h b/include/grub/i386/time.h
index 842882cf2..4da5ae93c 100644
--- a/include/grub/i386/time.h
+++ b/include/grub/i386/time.h
@@ -23,7 +23,7 @@ static __inline void
 grub_cpu_idle (void)
 {
   /* FIXME: this can't work until we handle interrupts.  */
-/*  __asm__ __volatile__ ("hlt"); */
+/*  asm volatile ("hlt"); */
 }
 
 #endif /* ! KERNEL_CPU_TIME_HEADER */
diff --git a/include/grub/i386/tsc.h b/include/grub/i386/tsc.h
index 324174ded..947e62fa1 100644
--- a/include/grub/i386/tsc.h
+++ b/include/grub/i386/tsc.h
@@ -46,7 +46,7 @@ grub_get_tsc (void)
   grub_cpuid (0,a,b,c,d);
   /* Read TSC value.  We cannot use "=A", since this would use
      %rax on x86_64. */
-  __asm__ __volatile__ ("rdtsc":"=a" (lo), "=d" (hi));
+  asm volatile ("rdtsc":"=a" (lo), "=d" (hi));
 
   return (((grub_uint64_t) hi) << 32) | lo;
 }
diff --git a/include/grub/x86_64/time.h b/include/grub/x86_64/time.h
index 842882cf2..4da5ae93c 100644
--- a/include/grub/x86_64/time.h
+++ b/include/grub/x86_64/time.h
@@ -23,7 +23,7 @@ static __inline void
 grub_cpu_idle (void)
 {
   /* FIXME: this can't work until we handle interrupts.  */
-/*  __asm__ __volatile__ ("hlt"); */
+/*  asm volatile ("hlt"); */
 }
 
 #endif /* ! KERNEL_CPU_TIME_HEADER */
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v2 2/2] Add new MSR modules (rdmsr/wrmsr)
  2019-03-01 17:17 [PATCH v2 1/2] Replace __asm__ __volatile__ with asm volatile Jesús Diéguez Fernández
@ 2019-03-01 17:17 ` Jesús Diéguez Fernández
  2019-03-05 11:09   ` Daniel Kiper
  2019-03-05 10:45 ` [PATCH v2 1/2] Replace __asm__ __volatile__ with asm volatile Daniel Kiper
  1 sibling, 1 reply; 10+ messages in thread
From: Jesús Diéguez Fernández @ 2019-03-01 17:17 UTC (permalink / raw)
  To: grub-devel; +Cc: Jesús Diéguez Fernández

In order to be able to read and write from/to model-specific registers,
two new modules are added. They are i386 specific, as the cpuid module.

rdmsr module registers the command rdmsr that allows reading from a MSR.
wrmsr module registers the command wrmsr that allows writing to a MSR.

wrmsr module is disabled if UEFI secure boot is enabled.

Please note that on SMP systems, interacting with a MSR that has a
scope per hardware thread, implies that the value only applies to
the particular cpu/core/thread that ran the command.

Changelog v1 -> v2:

    - Patch all source code files with s/__asm__ __volatile__/asm volatile/g.
    - Split the module in two (rdmsr/wrmsr).
    - Include the wrmsr module in the forbidden modules efi list.
    - Code indentation and cleanup.
    - Copyright year update.
    - Implicit casting mask removed.
    - Use the same assembly code for x86 and x86_64.
    - Add missing documentation.
    - Patch submited with Signed-off-by.

Signed-off-by: Jesús Diéguez Fernández <jesusdf@gmail.com>
---
 docs/grub.texi                     | 45 ++++++++++++++--
 grub-core/Makefile.core.def        | 16 ++++++
 grub-core/commands/efi/shim_lock.c |  2 +-
 grub-core/commands/i386/rdmsr.c    | 84 ++++++++++++++++++++++++++++++
 grub-core/commands/i386/wrmsr.c    | 75 ++++++++++++++++++++++++++
 include/grub/i386/rdmsr.h          | 32 ++++++++++++
 include/grub/i386/wrmsr.h          | 29 +++++++++++
 7 files changed, 277 insertions(+), 6 deletions(-)
 create mode 100644 grub-core/commands/i386/rdmsr.c
 create mode 100644 grub-core/commands/i386/wrmsr.c
 create mode 100644 include/grub/i386/rdmsr.h
 create mode 100644 include/grub/i386/wrmsr.h

diff --git a/docs/grub.texi b/docs/grub.texi
index ecaba9d5c..1d792b636 100644
--- a/docs/grub.texi
+++ b/docs/grub.texi
@@ -3931,6 +3931,7 @@ you forget a command, you can run the command @command{help}
 * play::                        Play a tune
 * probe::                       Retrieve device info
 * pxe_unload::                  Unload the PXE environment
+* rdmsr::                       Read values from model-specific registers
 * read::                        Read user input
 * reboot::                      Reboot your computer
 * regexp::                      Test if regular expression matches string
@@ -3953,6 +3954,7 @@ you forget a command, you can run the command @command{help}
 * verify_detached::             Verify detached digital signature
 * videoinfo::                   List available video modes
 @comment * xen_*::              Xen boot commands for AArch64
+* wrmsr::                       Write values to model-specific registers
 * xen_hypervisor::              Load xen hypervisor binary (only on AArch64)
 * xen_module::                  Load xen modules for xen hypervisor (only on AArch64)
 @end menu
@@ -4785,6 +4787,20 @@ This command is only available on PC BIOS systems.
 @end deffn
 
 
+@node rdmsr
+@subsection rdmsr
+
+@deffn Command: rdmsr 0xADDR [-v VARNAME]
+Read a model-specific register at address 0xADDR. If the parameter
+@option{-v} is used and an environment variable @var{VARNAME} is 
+given, set that environment variable to the value that was read.
+
+Please note that on SMP systems, reading from a MSR that has a
+scope per hardware thread, implies that the value that is returned
+only applies to the particular cpu/core/thread that runs the command.
+@end deffn
+
+
 @node read
 @subsection read
 
@@ -5223,6 +5239,17 @@ successfully.  If validation fails, it is set to a non-zero value.
 List available video modes. If resolution is given, show only matching modes.
 @end deffn
 
+@node wrmsr
+@subsection wrmsr
+
+@deffn Command: wrmsr 0xADDR 0xVALUE
+Write a 0xVALUE to a model-specific register at address 0xADDR.
+
+Please note that on SMP systems, writing to a MSR that has a scope 
+per hardware thread, implies that the value that is written
+only applies to the particular cpu/core/thread that runs the command.
+@end deffn
+
 @node xen_hypervisor
 @subsection xen_hypervisor
 
@@ -5716,11 +5743,11 @@ boot and the shim. This functionality is provided by the shim_lock module. It
 is recommend to build in this and other required modules into the @file{core.img}.
 All modules not stored in the @file{core.img} and the ACPI tables for the
 @command{acpi} command have to be signed, e.g. using PGP. Additionally, the
-@command{iorw} and the @command{memrw} commands are prohibited if the UEFI
-secure boot is enabled. This is done due to security reasons. All above
-mentioned requirements are enforced by the shim_lock module. And itself it
-is a persistent module which means that it cannot be unloaded if it was
-loaded into the memory.
+@command{iorw}, the @command{memrw} and the @command{wrmsr} commands are 
+prohibited if the UEFI secure boot is enabled.  This is done due to 
+security reasons.  All above mentioned requirements are enforced by the 
+shim_lock module. And itself it is a persistent module which means that 
+it cannot be unloaded if it was loaded into the memory.
 
 @node Measured Boot
 @section Measuring boot components
@@ -5831,6 +5858,8 @@ to install to is specified, UUID is used instead as well.
 @item USB                @tab yes     @tab yes      @tab yes          @tab yes
 @item chainloader        @tab local   @tab yes      @tab yes          @tab no
 @item cpuid              @tab partial @tab partial  @tab partial      @tab partial
+@item rdmsr              @tab partial @tab partial  @tab partial      @tab partial
+@item wrmsr              @tab partial @tab partial  @tab partial      @tab partial
 @item hints              @tab guess   @tab guess    @tab guess        @tab guess
 @item PCI                @tab yes     @tab yes      @tab yes          @tab yes
 @item badram             @tab yes     @tab yes      @tab yes          @tab yes
@@ -5850,6 +5879,8 @@ to install to is specified, UUID is used instead as well.
 @item USB                @tab yes         @tab yes       @tab yes           @tab no
 @item chainloader        @tab local       @tab local     @tab no            @tab local
 @item cpuid              @tab partial     @tab partial   @tab partial       @tab no
+@item rdmsr              @tab partial     @tab partial   @tab partial       @tab no
+@item wrmsr              @tab partial     @tab partial   @tab partial       @tab no
 @item hints              @tab guess       @tab guess     @tab good          @tab guess
 @item PCI                @tab yes         @tab yes       @tab yes           @tab no
 @item badram             @tab yes         @tab yes       @tab no            @tab yes
@@ -5869,6 +5900,8 @@ to install to is specified, UUID is used instead as well.
 @item USB                @tab yes         @tab no      @tab no      @tab no
 @item chainloader        @tab yes         @tab no      @tab no      @tab no
 @item cpuid              @tab no          @tab no      @tab no      @tab no
+@item rdmsr              @tab no          @tab no      @tab no      @tab no
+@item wrmsr              @tab no          @tab no      @tab no      @tab no
 @item hints              @tab good        @tab good    @tab good    @tab no
 @item PCI                @tab yes         @tab no      @tab no      @tab no
 @item badram             @tab yes (*)     @tab no      @tab no      @tab no
@@ -5888,6 +5921,8 @@ to install to is specified, UUID is used instead as well.
 @item USB                @tab N/A       @tab yes         @tab no
 @item chainloader        @tab yes       @tab no          @tab yes
 @item cpuid              @tab no        @tab no          @tab yes
+@item rdmsr              @tab no        @tab no          @tab yes
+@item wrmsr              @tab no        @tab no          @tab yes
 @item hints              @tab guess     @tab no          @tab no
 @item PCI                @tab no        @tab no          @tab no
 @item badram             @tab yes (*)   @tab no          @tab no
diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
index 2346bd291..a966a8f28 100644
--- a/grub-core/Makefile.core.def
+++ b/grub-core/Makefile.core.def
@@ -2484,3 +2484,19 @@ module = {
   common = loader/i386/xen_file64.c;
   extra_dist = loader/i386/xen_fileXX.c;
 };
+module = {
+  name = rdmsr;
+  common = commands/i386/rdmsr.c;
+  enable = x86;
+  enable = i386_xen_pvh;
+  enable = i386_xen;
+  enable = x86_64_xen;
+};
+module = {
+  name = wrmsr;
+  common = commands/i386/wrmsr.c;
+  enable = x86;
+  enable = i386_xen_pvh;
+  enable = i386_xen;
+  enable = x86_64_xen;
+};
diff --git a/grub-core/commands/efi/shim_lock.c b/grub-core/commands/efi/shim_lock.c
index 83568cb2b..764098cfc 100644
--- a/grub-core/commands/efi/shim_lock.c
+++ b/grub-core/commands/efi/shim_lock.c
@@ -43,7 +43,7 @@ static grub_efi_guid_t shim_lock_guid = GRUB_EFI_SHIM_LOCK_GUID;
 static grub_efi_shim_lock_protocol_t *sl;
 
 /* List of modules which cannot be loaded if UEFI secure boot mode is enabled. */
-static const char * const disabled_mods[] = {"iorw", "memrw", NULL};
+static const char * const disabled_mods[] = {"iorw", "memrw", "wrmsr", NULL};
 
 static grub_err_t
 shim_lock_init (grub_file_t io, enum grub_file_type type,
diff --git a/grub-core/commands/i386/rdmsr.c b/grub-core/commands/i386/rdmsr.c
new file mode 100644
index 000000000..08e5aee0b
--- /dev/null
+++ b/grub-core/commands/i386/rdmsr.c
@@ -0,0 +1,84 @@
+/* rdmsr.c - Read CPU model-specific registers */
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2019  Free Software Foundation, Inc.
+ *  Based on gcc/gcc/config/i386/driver-i386.c
+ *
+ *  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 <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/env.h>
+#include <grub/command.h>
+#include <grub/extcmd.h>
+#include <grub/i386/rdmsr.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE("GPLv3+");
+
+static grub_extcmd_t cmd_read;
+
+static const struct grub_arg_option options[] =
+{
+    {0, 'v', 0, N_("Save read value into variable VARNAME."),
+    N_("VARNAME"), ARG_TYPE_STRING},
+    {0, 0, 0, 0, 0, 0}
+};
+
+static grub_err_t
+grub_cmd_msr_read (grub_extcmd_context_t ctxt, int argc, char **argv)
+{
+    grub_uint64_t addr, value;
+    char *ptr;
+    char buf[sizeof("XXXXXXXX")];
+
+    if (argc != 1)
+        return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
+
+    grub_errno = GRUB_ERR_NONE;
+    ptr = argv[0];
+    addr = grub_strtoul (ptr, &ptr, 0);
+
+    if (grub_errno != GRUB_ERR_NONE)
+        return grub_errno;
+    if (*ptr != '\0')
+        return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("invalid argument"));
+
+    value = grub_msr_read (addr);
+
+    if (ctxt->state[0].set)
+    {
+        grub_snprintf (buf, sizeof(buf), "%llx", value);
+        grub_env_set (ctxt->state[0].arg, buf);
+    }
+    else
+        grub_printf ("0x%llx\n", value);
+
+    return GRUB_ERR_NONE;
+}
+
+GRUB_MOD_INIT(rdmsr)
+{
+    cmd_read = grub_register_extcmd ("rdmsr", grub_cmd_msr_read, 0,
+                                    N_("ADDR"),
+                                    N_("Read a CPU model specific register."),
+                                    options);
+}
+
+GRUB_MOD_FINI(rdmsr)
+{
+    grub_unregister_extcmd (cmd_read);
+}
diff --git a/grub-core/commands/i386/wrmsr.c b/grub-core/commands/i386/wrmsr.c
new file mode 100644
index 000000000..351b93f93
--- /dev/null
+++ b/grub-core/commands/i386/wrmsr.c
@@ -0,0 +1,75 @@
+/* wrmsr.c - Write CPU model-specific registers */
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2019  Free Software Foundation, Inc.
+ *  Based on gcc/gcc/config/i386/driver-i386.c
+ *
+ *  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 <http://www.gnu.org/licenses/>.
+ */
+
+#include <grub/dl.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/env.h>
+#include <grub/command.h>
+#include <grub/extcmd.h>
+#include <grub/i386/wrmsr.h>
+#include <grub/i18n.h>
+
+GRUB_MOD_LICENSE("GPLv3+");
+
+static grub_command_t cmd_write;
+
+static grub_err_t
+grub_cmd_msr_write (grub_command_t cmd, int argc, char **argv)
+{
+    grub_uint64_t addr, value;
+    char *ptr;
+
+    if (argc != 2)
+        return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("two arguments expected"));
+
+    grub_errno = GRUB_ERR_NONE;
+    ptr = argv[0];
+    addr = grub_strtoul (ptr, &ptr, 0);
+
+    if (grub_errno != GRUB_ERR_NONE)
+        return grub_errno;
+    if (*ptr != '\0')
+        return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("invalid argument"));
+
+    ptr = argv[1];
+    value = grub_strtoul (ptr, &ptr, 0);
+
+    if (grub_errno != GRUB_ERR_NONE)
+        return grub_errno;
+    if (*ptr != '\0')
+        return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("invalid argument"));
+
+    grub_msr_write (addr, value);
+
+    return GRUB_ERR_NONE;
+}
+
+GRUB_MOD_INIT(wrmsr)
+{
+    cmd_write = grub_register_command ("wrmsr", grub_cmd_msr_write,
+                                      N_("ADDR VALUE"),
+                                      N_("Write a value to a CPU model specific register."));
+}
+
+GRUB_MOD_FINI(wrmsr)
+{
+    grub_unregister_command (cmd_write);
+}
diff --git a/include/grub/i386/rdmsr.h b/include/grub/i386/rdmsr.h
new file mode 100644
index 000000000..e907f1052
--- /dev/null
+++ b/include/grub/i386/rdmsr.h
@@ -0,0 +1,32 @@
+/*
+ *  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 <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GRUB_CPU_MSR_READ_HEADER
+#define GRUB_CPU_MSR_READ_HEADER 1
+#endif
+
+extern __inline grub_uint64_t grub_msr_read (grub_uint64_t msr_id)
+{
+    grub_uint32_t low_id = msr_id, low, high;
+
+    asm volatile ( "rdmsr"  : "=a"(low), "=d"(high) : "c"(low_id) );
+
+    return ((grub_uint64_t)high << 32) | low;
+}
+
+
diff --git a/include/grub/i386/wrmsr.h b/include/grub/i386/wrmsr.h
new file mode 100644
index 000000000..2e535b8fe
--- /dev/null
+++ b/include/grub/i386/wrmsr.h
@@ -0,0 +1,29 @@
+/*
+ *  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 <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GRUB_CPU_MSR_WRITE_HEADER
+#define GRUB_CPU_MSR_WRITE_HEADER 1
+#endif
+
+extern __inline void grub_msr_write(grub_uint64_t msr_id, grub_uint64_t msr_value)
+{
+    grub_uint32_t low_id = msr_id, low = msr_value, high = msr_value >> 32;
+
+    asm volatile ( "wrmsr" : : "c"(low_id), "a"(low), "d"(high) );
+}
+
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 1/2] Replace __asm__ __volatile__ with asm volatile.
  2019-03-01 17:17 [PATCH v2 1/2] Replace __asm__ __volatile__ with asm volatile Jesús Diéguez Fernández
  2019-03-01 17:17 ` [PATCH v2 2/2] Add new MSR modules (rdmsr/wrmsr) Jesús Diéguez Fernández
@ 2019-03-05 10:45 ` Daniel Kiper
  1 sibling, 0 replies; 10+ messages in thread
From: Daniel Kiper @ 2019-03-05 10:45 UTC (permalink / raw)
  To: Jesús Diéguez Fernández; +Cc: grub-devel

On Fri, Mar 01, 2019 at 06:17:41PM +0100, Jesús Diéguez Fernández wrote:
> In order to maintain the coding style consistency, it was requested to
> replace the methods that use __asm__ __volatile__ with asm volatile.
>
> Signed-off-by: Jesús Diéguez Fernández <jesusdf@gmail.com>

Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>

Daniel


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 2/2] Add new MSR modules (rdmsr/wrmsr)
  2019-03-01 17:17 ` [PATCH v2 2/2] Add new MSR modules (rdmsr/wrmsr) Jesús Diéguez Fernández
@ 2019-03-05 11:09   ` Daniel Kiper
  2019-03-05 22:17     ` Jesús Diéguez Fernández
  0 siblings, 1 reply; 10+ messages in thread
From: Daniel Kiper @ 2019-03-05 11:09 UTC (permalink / raw)
  To: Jesús Diéguez Fernández; +Cc: grub-devel

On Fri, Mar 01, 2019 at 06:17:42PM +0100, Jesús Diéguez Fernández wrote:
> In order to be able to read and write from/to model-specific registers,
> two new modules are added. They are i386 specific, as the cpuid module.
>
> rdmsr module registers the command rdmsr that allows reading from a MSR.
> wrmsr module registers the command wrmsr that allows writing to a MSR.
>
> wrmsr module is disabled if UEFI secure boot is enabled.
>
> Please note that on SMP systems, interacting with a MSR that has a
> scope per hardware thread, implies that the value only applies to
> the particular cpu/core/thread that ran the command.
>
> Changelog v1 -> v2:
>
>     - Patch all source code files with s/__asm__ __volatile__/asm volatile/g.
>     - Split the module in two (rdmsr/wrmsr).
>     - Include the wrmsr module in the forbidden modules efi list.
>     - Code indentation and cleanup.
>     - Copyright year update.
>     - Implicit casting mask removed.
>     - Use the same assembly code for x86 and x86_64.
>     - Add missing documentation.
>     - Patch submited with Signed-off-by.
>
> Signed-off-by: Jesús Diéguez Fernández <jesusdf@gmail.com>

In general it looks much better but I still have some concerns...

First of all, two patches and more should have mail introducing them.
Good example you can find here
  http://lists.gnu.org/archive/html/grub-devel/2018-10/msg00201.html
or here
  http://lists.gnu.org/archive/html/grub-devel/2018-11/msg00282.html

git send-email --compose ... is your friend...

[...]

> diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
> index 2346bd291..a966a8f28 100644
> --- a/grub-core/Makefile.core.def
> +++ b/grub-core/Makefile.core.def
> @@ -2484,3 +2484,19 @@ module = {
>    common = loader/i386/xen_file64.c;
>    extra_dist = loader/i386/xen_fileXX.c;
>  };
> +module = {
> +  name = rdmsr;
> +  common = commands/i386/rdmsr.c;
> +  enable = x86;
> +  enable = i386_xen_pvh;
> +  enable = i386_xen;
> +  enable = x86_64_xen;

I think that x86 should suffice? Does not it?

> +};
> +module = {
> +  name = wrmsr;
> +  common = commands/i386/wrmsr.c;
> +  enable = x86;
> +  enable = i386_xen_pvh;
> +  enable = i386_xen;
> +  enable = x86_64_xen;

Ditto.

> +};
> diff --git a/grub-core/commands/efi/shim_lock.c b/grub-core/commands/efi/shim_lock.c
> index 83568cb2b..764098cfc 100644
> --- a/grub-core/commands/efi/shim_lock.c
> +++ b/grub-core/commands/efi/shim_lock.c
> @@ -43,7 +43,7 @@ static grub_efi_guid_t shim_lock_guid = GRUB_EFI_SHIM_LOCK_GUID;
>  static grub_efi_shim_lock_protocol_t *sl;
>
>  /* List of modules which cannot be loaded if UEFI secure boot mode is enabled. */
> -static const char * const disabled_mods[] = {"iorw", "memrw", NULL};
> +static const char * const disabled_mods[] = {"iorw", "memrw", "wrmsr", NULL};
>
>  static grub_err_t
>  shim_lock_init (grub_file_t io, enum grub_file_type type,
> diff --git a/grub-core/commands/i386/rdmsr.c b/grub-core/commands/i386/rdmsr.c
> new file mode 100644
> index 000000000..08e5aee0b
> --- /dev/null
> +++ b/grub-core/commands/i386/rdmsr.c
> @@ -0,0 +1,84 @@
> +/* rdmsr.c - Read CPU model-specific registers */
> +/*
> + *  GRUB  --  GRand Unified Bootloader
> + *  Copyright (C) 2019  Free Software Foundation, Inc.
> + *  Based on gcc/gcc/config/i386/driver-i386.c
> + *
> + *  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 <http://www.gnu.org/licenses/>.
> + */
> +
> +#include <grub/dl.h>
> +#include <grub/misc.h>
> +#include <grub/mm.h>
> +#include <grub/env.h>
> +#include <grub/command.h>
> +#include <grub/extcmd.h>
> +#include <grub/i386/rdmsr.h>
> +#include <grub/i18n.h>
> +
> +GRUB_MOD_LICENSE("GPLv3+");
> +
> +static grub_extcmd_t cmd_read;
> +
> +static const struct grub_arg_option options[] =
> +{
> +    {0, 'v', 0, N_("Save read value into variable VARNAME."),
> +    N_("VARNAME"), ARG_TYPE_STRING},
> +    {0, 0, 0, 0, 0, 0}
> +};
> +
> +static grub_err_t
> +grub_cmd_msr_read (grub_extcmd_context_t ctxt, int argc, char **argv)
> +{
> +    grub_uint64_t addr, value;
> +    char *ptr;
> +    char buf[sizeof("XXXXXXXX")];
> +
> +    if (argc != 1)
> +        return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
> +
> +    grub_errno = GRUB_ERR_NONE;
> +    ptr = argv[0];
> +    addr = grub_strtoul (ptr, &ptr, 0);
> +
> +    if (grub_errno != GRUB_ERR_NONE)
> +        return grub_errno;

Should not you display a blurb to the user what happened here?
Like you do below...

> +    if (*ptr != '\0')
> +        return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("invalid argument"));
> +
> +    value = grub_msr_read (addr);
> +
> +    if (ctxt->state[0].set)
> +    {
> +        grub_snprintf (buf, sizeof(buf), "%llx", value);
> +        grub_env_set (ctxt->state[0].arg, buf);
> +    }
> +    else
> +        grub_printf ("0x%llx\n", value);
> +
> +    return GRUB_ERR_NONE;
> +}
> +
> +GRUB_MOD_INIT(rdmsr)
> +{
> +    cmd_read = grub_register_extcmd ("rdmsr", grub_cmd_msr_read, 0,
> +                                    N_("ADDR"),
> +                                    N_("Read a CPU model specific register."),
> +                                    options);
> +}
> +
> +GRUB_MOD_FINI(rdmsr)
> +{
> +    grub_unregister_extcmd (cmd_read);
> +}
> diff --git a/grub-core/commands/i386/wrmsr.c b/grub-core/commands/i386/wrmsr.c
> new file mode 100644
> index 000000000..351b93f93
> --- /dev/null
> +++ b/grub-core/commands/i386/wrmsr.c
> @@ -0,0 +1,75 @@
> +/* wrmsr.c - Write CPU model-specific registers */
> +/*
> + *  GRUB  --  GRand Unified Bootloader
> + *  Copyright (C) 2019  Free Software Foundation, Inc.
> + *  Based on gcc/gcc/config/i386/driver-i386.c
> + *
> + *  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 <http://www.gnu.org/licenses/>.
> + */
> +
> +#include <grub/dl.h>
> +#include <grub/misc.h>
> +#include <grub/mm.h>
> +#include <grub/env.h>
> +#include <grub/command.h>
> +#include <grub/extcmd.h>
> +#include <grub/i386/wrmsr.h>
> +#include <grub/i18n.h>
> +
> +GRUB_MOD_LICENSE("GPLv3+");
> +
> +static grub_command_t cmd_write;
> +
> +static grub_err_t
> +grub_cmd_msr_write (grub_command_t cmd, int argc, char **argv)
> +{
> +    grub_uint64_t addr, value;
> +    char *ptr;
> +
> +    if (argc != 2)
> +        return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("two arguments expected"));
> +
> +    grub_errno = GRUB_ERR_NONE;
> +    ptr = argv[0];
> +    addr = grub_strtoul (ptr, &ptr, 0);
> +
> +    if (grub_errno != GRUB_ERR_NONE)
> +        return grub_errno;

Ditto.

> +    if (*ptr != '\0')
> +        return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("invalid argument"));
> +
> +    ptr = argv[1];
> +    value = grub_strtoul (ptr, &ptr, 0);
> +
> +    if (grub_errno != GRUB_ERR_NONE)
> +        return grub_errno;

Ditto.

> +    if (*ptr != '\0')
> +        return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("invalid argument"));
> +
> +    grub_msr_write (addr, value);
> +
> +    return GRUB_ERR_NONE;
> +}
> +
> +GRUB_MOD_INIT(wrmsr)
> +{
> +    cmd_write = grub_register_command ("wrmsr", grub_cmd_msr_write,
> +                                      N_("ADDR VALUE"),
> +                                      N_("Write a value to a CPU model specific register."));
> +}
> +
> +GRUB_MOD_FINI(wrmsr)
> +{
> +    grub_unregister_command (cmd_write);
> +}
> diff --git a/include/grub/i386/rdmsr.h b/include/grub/i386/rdmsr.h
> new file mode 100644
> index 000000000..e907f1052
> --- /dev/null
> +++ b/include/grub/i386/rdmsr.h
> @@ -0,0 +1,32 @@
> +/*
> + *  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 <http://www.gnu.org/licenses/>.
> + */
> +
> +#ifndef GRUB_CPU_MSR_READ_HEADER
> +#define GRUB_CPU_MSR_READ_HEADER 1

s/GRUB_CPU_MSR_READ_HEADER/GRUB_RDMSR_H/

> +#endif

This #endif should go...

> +
> +extern __inline grub_uint64_t grub_msr_read (grub_uint64_t msr_id)
> +{
> +    grub_uint32_t low_id = msr_id, low, high;
> +
> +    asm volatile ( "rdmsr"  : "=a"(low), "=d"(high) : "c"(low_id) );
> +
> +    return ((grub_uint64_t)high << 32) | low;
> +}
> +

...here. Like this

#endif /* GRUB_RDMSR_H */

> +

Please drop this empty line.

> diff --git a/include/grub/i386/wrmsr.h b/include/grub/i386/wrmsr.h
> new file mode 100644
> index 000000000..2e535b8fe
> --- /dev/null
> +++ b/include/grub/i386/wrmsr.h
> @@ -0,0 +1,29 @@
> +/*
> + *  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 <http://www.gnu.org/licenses/>.
> + */
> +
> +#ifndef GRUB_CPU_MSR_WRITE_HEADER
> +#define GRUB_CPU_MSR_WRITE_HEADER 1

s/GRUB_CPU_MSR_READ_HEADER/GRUB_WRMSR_H/

> +#endif

And this #endif should go below too. Like in rdmsr.h.

> +extern __inline void grub_msr_write(grub_uint64_t msr_id, grub_uint64_t msr_value)
> +{
> +    grub_uint32_t low_id = msr_id, low = msr_value, high = msr_value >> 32;
> +
> +    asm volatile ( "wrmsr" : : "c"(low_id), "a"(low), "d"(high) );
> +}

Anyway, thank you for doing the work. Looking forward for next version
of patches. Please post them quickly because freeze date is nearing.

Daniel


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 2/2] Add new MSR modules (rdmsr/wrmsr)
  2019-03-05 11:09   ` Daniel Kiper
@ 2019-03-05 22:17     ` Jesús Diéguez Fernández
  2019-03-06 10:32       ` Daniel Kiper
  0 siblings, 1 reply; 10+ messages in thread
From: Jesús Diéguez Fernández @ 2019-03-05 22:17 UTC (permalink / raw)
  To: Daniel Kiper; +Cc: grub-devel

Hi,
   I have some doubts that I comment below.

El 5/3/19 a las 12:09, Daniel Kiper escribió:
> On Fri, Mar 01, 2019 at 06:17:42PM +0100, Jesús Diéguez Fernández wrote:
>> In order to be able to read and write from/to model-specific registers,
>> two new modules are added. They are i386 specific, as the cpuid module.
>>
>> rdmsr module registers the command rdmsr that allows reading from a MSR.
>> wrmsr module registers the command wrmsr that allows writing to a MSR.
>>
>> wrmsr module is disabled if UEFI secure boot is enabled.
>>
>> Please note that on SMP systems, interacting with a MSR that has a
>> scope per hardware thread, implies that the value only applies to
>> the particular cpu/core/thread that ran the command.
>>
>> Changelog v1 -> v2:
>>
>>     - Patch all source code files with s/__asm__ __volatile__/asm volatile/g.
>>     - Split the module in two (rdmsr/wrmsr).
>>     - Include the wrmsr module in the forbidden modules efi list.
>>     - Code indentation and cleanup.
>>     - Copyright year update.
>>     - Implicit casting mask removed.
>>     - Use the same assembly code for x86 and x86_64.
>>     - Add missing documentation.
>>     - Patch submited with Signed-off-by.
>>
>> Signed-off-by: Jesús Diéguez Fernández <jesusdf@gmail.com>
> 
> In general it looks much better but I still have some concerns...
> 
> First of all, two patches and more should have mail introducing them.
> Good example you can find here
>   http://lists.gnu.org/archive/html/grub-devel/2018-10/msg00201.html
> or here
>   http://lists.gnu.org/archive/html/grub-devel/2018-11/msg00282.html
> 
> git send-email --compose ... is your friend...
> 
> [...]

I thought about it before sending the e-mail, but I chose the wrong
option. :-\

For the v3, now that the patch [1/2] has already been reviewed, should I
send it again, or should I skip it?

> 
>> diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
>> index 2346bd291..a966a8f28 100644
>> --- a/grub-core/Makefile.core.def
>> +++ b/grub-core/Makefile.core.def
>> @@ -2484,3 +2484,19 @@ module = {
>>    common = loader/i386/xen_file64.c;
>>    extra_dist = loader/i386/xen_fileXX.c;
>>  };
>> +module = {
>> +  name = rdmsr;
>> +  common = commands/i386/rdmsr.c;
>> +  enable = x86;
>> +  enable = i386_xen_pvh;
>> +  enable = i386_xen;
>> +  enable = x86_64_xen;
> 
> I think that x86 should suffice? Does not it?

I used the cpuid module as an example since it has many similarities.
Even so, I thought that accessing MSR from a Xen guest could be interesting:

http://www.brendangregg.com/blog/2014-09-15/the-msrs-of-ec2.html

For my use case, leaving alone x86 is enough. I'll modify it as you tell
me to.

> 
>> +};
>> +module = {
>> +  name = wrmsr;
>> +  common = commands/i386/wrmsr.c;
>> +  enable = x86;
>> +  enable = i386_xen_pvh;
>> +  enable = i386_xen;
>> +  enable = x86_64_xen;
> 
> Ditto.
> 

[...]

>> +static grub_err_t
>> +grub_cmd_msr_read (grub_extcmd_context_t ctxt, int argc, char **argv)
>> +{
>> +    grub_uint64_t addr, value;
>> +    char *ptr;
>> +    char buf[sizeof("XXXXXXXX")];
>> +
>> +    if (argc != 1)
>> +        return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
>> +
>> +    grub_errno = GRUB_ERR_NONE;
>> +    ptr = argv[0];
>> +    addr = grub_strtoul (ptr, &ptr, 0);
>> +
>> +    if (grub_errno != GRUB_ERR_NONE)
>> +        return grub_errno;
> 
> Should not you display a blurb to the user what happened here?
> Like you do below...

I used the same method that is used in grub-core/term/terminfo.c

static grub_err_t
grub_cmd_terminfo (grub_extcmd_context_t ctxt, int argc, char **args)
{
...

      char *ptr = state[OPTION_GEOMETRY].arg;
      w = grub_strtoul (ptr, &ptr, 0);
      if (grub_errno)
        return grub_errno;
      if (*ptr != 'x')
        return grub_error (GRUB_ERR_BAD_ARGUMENT,
                           N_("incorrect terminal dimensions
specification"));

I tested this with:

rdmsr z => shows "unrecognized number"
rdmsr 0x1122334455667788991100 => shows "overflow detected"

I can change it to:

if (grub_errno != GRUB_ERR_NONE)
        return grub_error (grub_errno, N_("invalid argument"));

If that is any better.

> 
>> +    if (*ptr != '\0')
>> +        return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("invalid argument"));
>> +
>> +    value = grub_msr_read (addr);
>> +
>> +    if (ctxt->state[0].set)
>> +    {
>> +        grub_snprintf (buf, sizeof(buf), "%llx", value);
>> +        grub_env_set (ctxt->state[0].arg, buf);
>> +    }
>> +    else
>> +        grub_printf ("0x%llx\n", value);
>> +
>> +    return GRUB_ERR_NONE;
>> +}

[...]

>> +
>> +GRUB_MOD_LICENSE("GPLv3+");
>> +
>> +static grub_command_t cmd_write;
>> +
>> +static grub_err_t
>> +grub_cmd_msr_write (grub_command_t cmd, int argc, char **argv)
>> +{
>> +    grub_uint64_t addr, value;
>> +    char *ptr;
>> +
>> +    if (argc != 2)
>> +        return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("two arguments expected"));
>> +
>> +    grub_errno = GRUB_ERR_NONE;
>> +    ptr = argv[0];
>> +    addr = grub_strtoul (ptr, &ptr, 0);
>> +
>> +    if (grub_errno != GRUB_ERR_NONE)
>> +        return grub_errno;
> 
> Ditto.
> 
>> +    if (*ptr != '\0')
>> +        return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("invalid argument"));
>> +
>> +    ptr = argv[1];
>> +    value = grub_strtoul (ptr, &ptr, 0);
>> +
>> +    if (grub_errno != GRUB_ERR_NONE)
>> +        return grub_errno;
> 
> Ditto.
> 
>> +    if (*ptr != '\0')
>> +        return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("invalid argument"));
>> +

I found a bug in this function, it is possible to write 64 bit values to
the MSR, so I should have used grub_strtoull when reading the value.
It will be fixed in the v3.

>> +    grub_msr_write (addr, value);
>> +
>> +    return GRUB_ERR_NONE;
>> +}
>> +
>> +GRUB_MOD_INIT(wrmsr)
>> +{
>> +    cmd_write = grub_register_command ("wrmsr", grub_cmd_msr_write,
>> +                                      N_("ADDR VALUE"),
>> +                                      N_("Write a value to a CPU model specific register."));
>> +}
>> +
>> +GRUB_MOD_FINI(wrmsr)
>> +{
>> +    grub_unregister_command (cmd_write);
>> +}

[...]

> 
> And this #endif should go below too. Like in rdmsr.h.
> 
>> +extern __inline void grub_msr_write(grub_uint64_t msr_id, grub_uint64_t msr_value)
>> +{
>> +    grub_uint32_t low_id = msr_id, low = msr_value, high = msr_value >> 32;
>> +
>> +    asm volatile ( "wrmsr" : : "c"(low_id), "a"(low), "d"(high) );
>> +}
> 
> Anyway, thank you for doing the work. Looking forward for next version
> of patches. Please post them quickly because freeze date is nearing.
> 
> Daniel
> 

I'm also interested in getting this patch into the next version. I'll
send you the v3 as soon as this doubts are cleared.

Jesus


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 2/2] Add new MSR modules (rdmsr/wrmsr)
  2019-03-05 22:17     ` Jesús Diéguez Fernández
@ 2019-03-06 10:32       ` Daniel Kiper
       [not found]         ` <CAPo7o_5d2rsb13+iVopwtcZJGYWK1uHzJn21_ece747Jw56Qzw@mail.gmail.com>
  0 siblings, 1 reply; 10+ messages in thread
From: Daniel Kiper @ 2019-03-06 10:32 UTC (permalink / raw)
  To: Jesús Diéguez Fernández; +Cc: grub-devel

On Tue, Mar 05, 2019 at 11:17:01PM +0100, Jesús Diéguez Fernández wrote:
> Hi,
>    I have some doubts that I comment below.
>
> El 5/3/19 a las 12:09, Daniel Kiper escribió:
> > On Fri, Mar 01, 2019 at 06:17:42PM +0100, Jesús Diéguez Fernández wrote:
> >> In order to be able to read and write from/to model-specific registers,
> >> two new modules are added. They are i386 specific, as the cpuid module.
> >>
> >> rdmsr module registers the command rdmsr that allows reading from a MSR.
> >> wrmsr module registers the command wrmsr that allows writing to a MSR.
> >>
> >> wrmsr module is disabled if UEFI secure boot is enabled.
> >>
> >> Please note that on SMP systems, interacting with a MSR that has a
> >> scope per hardware thread, implies that the value only applies to
> >> the particular cpu/core/thread that ran the command.
> >>
> >> Changelog v1 -> v2:
> >>
> >>     - Patch all source code files with s/__asm__ __volatile__/asm volatile/g.
> >>     - Split the module in two (rdmsr/wrmsr).
> >>     - Include the wrmsr module in the forbidden modules efi list.
> >>     - Code indentation and cleanup.
> >>     - Copyright year update.
> >>     - Implicit casting mask removed.
> >>     - Use the same assembly code for x86 and x86_64.
> >>     - Add missing documentation.
> >>     - Patch submited with Signed-off-by.
> >>
> >> Signed-off-by: Jesús Diéguez Fernández <jesusdf@gmail.com>
> >
> > In general it looks much better but I still have some concerns...
> >
> > First of all, two patches and more should have mail introducing them.
> > Good example you can find here
> >   http://lists.gnu.org/archive/html/grub-devel/2018-10/msg00201.html
> > or here
> >   http://lists.gnu.org/archive/html/grub-devel/2018-11/msg00282.html
> >
> > git send-email --compose ... is your friend...
> >
> > [...]
>
> I thought about it before sending the e-mail, but I chose the wrong
> option. :-\

Not big deal...

> For the v3, now that the patch [1/2] has already been reviewed, should I
> send it again, or should I skip it?

Please add my Reviewed-by under your Signed-off-by (SOB) and resend it.

> >> diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
> >> index 2346bd291..a966a8f28 100644
> >> --- a/grub-core/Makefile.core.def
> >> +++ b/grub-core/Makefile.core.def
> >> @@ -2484,3 +2484,19 @@ module = {
> >>    common = loader/i386/xen_file64.c;
> >>    extra_dist = loader/i386/xen_fileXX.c;
> >>  };
> >> +module = {
> >> +  name = rdmsr;
> >> +  common = commands/i386/rdmsr.c;
> >> +  enable = x86;
> >> +  enable = i386_xen_pvh;
> >> +  enable = i386_xen;
> >> +  enable = x86_64_xen;
> >
> > I think that x86 should suffice? Does not it?
>
> I used the cpuid module as an example since it has many similarities.
> Even so, I thought that accessing MSR from a Xen guest could be interesting:
>
> http://www.brendangregg.com/blog/2014-09-15/the-msrs-of-ec2.html
>
> For my use case, leaving alone x86 is enough. I'll modify it as you tell
> me to.

I am not saying that MSR access is not interesting on Xen. I am saying
that I have a feeling that all "enable ..." except "enable = x86;" are
redundant. So, I think that "enable = x86;" will cover Xen too. Please
double check it. If it does not cover leave xen stuff as is.

> >> +};
> >> +module = {
> >> +  name = wrmsr;
> >> +  common = commands/i386/wrmsr.c;
> >> +  enable = x86;
> >> +  enable = i386_xen_pvh;
> >> +  enable = i386_xen;
> >> +  enable = x86_64_xen;
> >
> > Ditto.
> >
>
> [...]
>
> >> +static grub_err_t
> >> +grub_cmd_msr_read (grub_extcmd_context_t ctxt, int argc, char **argv)
> >> +{
> >> +    grub_uint64_t addr, value;
> >> +    char *ptr;
> >> +    char buf[sizeof("XXXXXXXX")];
> >> +
> >> +    if (argc != 1)
> >> +        return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected"));
> >> +
> >> +    grub_errno = GRUB_ERR_NONE;
> >> +    ptr = argv[0];
> >> +    addr = grub_strtoul (ptr, &ptr, 0);
> >> +
> >> +    if (grub_errno != GRUB_ERR_NONE)
> >> +        return grub_errno;
> >
> > Should not you display a blurb to the user what happened here?
> > Like you do below...
>
> I used the same method that is used in grub-core/term/terminfo.c
>
> static grub_err_t
> grub_cmd_terminfo (grub_extcmd_context_t ctxt, int argc, char **args)
> {
> ...
>
>       char *ptr = state[OPTION_GEOMETRY].arg;
>       w = grub_strtoul (ptr, &ptr, 0);
>       if (grub_errno)
>         return grub_errno;
>       if (*ptr != 'x')
>         return grub_error (GRUB_ERR_BAD_ARGUMENT,
>                            N_("incorrect terminal dimensions
> specification"));
>
> I tested this with:
>
> rdmsr z => shows "unrecognized number"
> rdmsr 0x1122334455667788991100 => shows "overflow detected"
>
> I can change it to:
>
> if (grub_errno != GRUB_ERR_NONE)
>         return grub_error (grub_errno, N_("invalid argument"));
>
> If that is any better.

If your/terminfo version works correctly then I am fine with it.
You do not need to change it.

> >> +    if (*ptr != '\0')
> >> +        return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("invalid argument"));
> >> +
> >> +    value = grub_msr_read (addr);
> >> +
> >> +    if (ctxt->state[0].set)
> >> +    {
> >> +        grub_snprintf (buf, sizeof(buf), "%llx", value);
> >> +        grub_env_set (ctxt->state[0].arg, buf);
> >> +    }
> >> +    else
> >> +        grub_printf ("0x%llx\n", value);
> >> +
> >> +    return GRUB_ERR_NONE;
> >> +}
>
> [...]
>
> >> +
> >> +GRUB_MOD_LICENSE("GPLv3+");
> >> +
> >> +static grub_command_t cmd_write;
> >> +
> >> +static grub_err_t
> >> +grub_cmd_msr_write (grub_command_t cmd, int argc, char **argv)
> >> +{
> >> +    grub_uint64_t addr, value;
> >> +    char *ptr;
> >> +
> >> +    if (argc != 2)
> >> +        return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("two arguments expected"));
> >> +
> >> +    grub_errno = GRUB_ERR_NONE;
> >> +    ptr = argv[0];
> >> +    addr = grub_strtoul (ptr, &ptr, 0);
> >> +
> >> +    if (grub_errno != GRUB_ERR_NONE)
> >> +        return grub_errno;
> >
> > Ditto.
> >
> >> +    if (*ptr != '\0')
> >> +        return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("invalid argument"));
> >> +
> >> +    ptr = argv[1];
> >> +    value = grub_strtoul (ptr, &ptr, 0);
> >> +
> >> +    if (grub_errno != GRUB_ERR_NONE)
> >> +        return grub_errno;
> >
> > Ditto.
> >
> >> +    if (*ptr != '\0')
> >> +        return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("invalid argument"));
> >> +
>
> I found a bug in this function, it is possible to write 64 bit values to
> the MSR, so I should have used grub_strtoull when reading the value.
> It will be fixed in the v3.
>
> >> +    grub_msr_write (addr, value);

There are other issues. IMO addr should be 32-bit type instead of 64-bit.

And Intel spec says:
  The CPUID instruction should be used to determine whether MSRs are
  supported (CPUID.01H:EDX[5] = 1) before using this instruction.

  Specifying a reserved or unimplemented MSR address in ECX will also
  cause a general protection exception.

What will happen if somebody specifies invalid MSR? Does GRUB crashes?

Daniel


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 2/2] Add new MSR modules (rdmsr/wrmsr)
       [not found]           ` <20190306143057.gkthocy5t6ojbzks@tomti.i.net-space.pl>
@ 2019-03-07 18:05             ` Jesús Diéguez Fernández
  2019-03-07 19:58               ` Daniel Kiper
  0 siblings, 1 reply; 10+ messages in thread
From: Jesús Diéguez Fernández @ 2019-03-07 18:05 UTC (permalink / raw)
  To: Daniel Kiper, grub-devel

El 6/3/19 a las 15:30, Daniel Kiper escribió:
> On Wed, Mar 06, 2019 at 01:01:07PM +0100, Jesús DF wrote:
>> El mié., 6 mar. 2019 a las 11:32, Daniel Kiper (<dkiper@net-space.pl>) escribió:
>>> On Tue, Mar 05, 2019 at 11:17:01PM +0100, Jesús Diéguez Fernández wrote:
>>>> Hi,
>>>>    I have some doubts that I comment below.
>>>>
>>>> El 5/3/19 a las 12:09, Daniel Kiper escribió:
>>>>> On Fri, Mar 01, 2019 at 06:17:42PM +0100, Jesús Diéguez Fernández wrote:
>>>>>> In order to be able to read and write from/to model-specific registers,
>>>>>> two new modules are added. They are i386 specific, as the cpuid module.
>>>>>>
>>>>>> rdmsr module registers the command rdmsr that allows reading from a MSR.
>>>>>> wrmsr module registers the command wrmsr that allows writing to a MSR.
>>>>>>
>>>>>> wrmsr module is disabled if UEFI secure boot is enabled.
>>>>>>
>>>>>> Please note that on SMP systems, interacting with a MSR that has a
>>>>>> scope per hardware thread, implies that the value only applies to
>>>>>> the particular cpu/core/thread that ran the command.
>>>>>>
>>>>>> Changelog v1 -> v2:
>>>>>>
>>>>>>     - Patch all source code files with s/__asm__ __volatile__/asm volatile/g.
>>>>>>     - Split the module in two (rdmsr/wrmsr).
>>>>>>     - Include the wrmsr module in the forbidden modules efi list.
>>>>>>     - Code indentation and cleanup.
>>>>>>     - Copyright year update.
>>>>>>     - Implicit casting mask removed.
>>>>>>     - Use the same assembly code for x86 and x86_64.
>>>>>>     - Add missing documentation.
>>>>>>     - Patch submited with Signed-off-by.
>>>>>>
>>>>>> Signed-off-by: Jesús Diéguez Fernández <jesusdf@gmail.com>
>>>>>
>>>>> In general it looks much better but I still have some concerns...
>>>>>
>>>>> First of all, two patches and more should have mail introducing them.
>>>>> Good example you can find here
>>>>>   http://lists.gnu.org/archive/html/grub-devel/2018-10/msg00201.html
>>>>> or here
>>>>>   http://lists.gnu.org/archive/html/grub-devel/2018-11/msg00282.html
>>>>>
>>>>> git send-email --compose ... is your friend...
>>>>>
>>>>> [...]
>>>>
>>>> I thought about it before sending the e-mail, but I chose the wrong
>>>> option. :-\
>>>
>>> Not big deal...
>>>
>>>> For the v3, now that the patch [1/2] has already been reviewed, should I
>>>> send it again, or should I skip it?
>>>
>>> Please add my Reviewed-by under your Signed-off-by (SOB) and resend it.
>>>
>>
>> Ok.
> 
> [...]
> 
>>>>>> +static grub_err_t
>>>>>> +grub_cmd_msr_write (grub_command_t cmd, int argc, char **argv)
>>>>>> +{
>>>>>> +    grub_uint64_t addr, value;
>>>>>> +    char *ptr;
>>>>>> +
>>>>>> +    if (argc != 2)
>>>>>> +        return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("two arguments expected"));
>>>>>> +
>>>>>> +    grub_errno = GRUB_ERR_NONE;
>>>>>> +    ptr = argv[0];
>>>>>> +    addr = grub_strtoul (ptr, &ptr, 0);
>>>>>> +
>>>>>> +    if (grub_errno != GRUB_ERR_NONE)
>>>>>> +        return grub_errno;
>>>>>
>>>>> Ditto.
>>>>>
>>>>>> +    if (*ptr != '\0')
>>>>>> +        return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("invalid argument"));
>>>>>> +
>>>>>> +    ptr = argv[1];
>>>>>> +    value = grub_strtoul (ptr, &ptr, 0);
>>>>>> +
>>>>>> +    if (grub_errno != GRUB_ERR_NONE)
>>>>>> +        return grub_errno;
>>>>>
>>>>> Ditto.
>>>>>
>>>>>> +    if (*ptr != '\0')
>>>>>> +        return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("invalid argument"));
>>>>>> +
>>>>
>>>> I found a bug in this function, it is possible to write 64 bit values to
>>>> the MSR, so I should have used grub_strtoull when reading the value.
>>>> It will be fixed in the v3.
>>>>
>>>>>> +    grub_msr_write (addr, value);
>>>
>>> There are other issues. IMO addr should be 32-bit type instead of 64-bit.
>>>
>>> And Intel spec says:
>>>   The CPUID instruction should be used to determine whether MSRs are
>>>   supported (CPUID.01H:EDX[5] = 1) before using this instruction.
>>>
>>>   Specifying a reserved or unimplemented MSR address in ECX will also
>>>   cause a general protection exception.
>>>
>>> What will happen if somebody specifies invalid MSR? Does GRUB crashes?
>>>
>>> Daniel
>>
>> Yes, I already did change addr to be 32-bit type in my local branch.
> 
> Great!
> 
>> All Intel CPUs since the first Pentium support that instructions, but
>> to be safe I should check it using CPUID.
>> I'll add that functionality to the cpuid module and use it to verify
>> if its availiable before calling the instruction.
> 
> I am not sure that it pays to pull in cpuid module here. Maybe it will
> be easier to just use asm with cpuid before grub_msr_read()/grub_msr_write()
> calls. Anyway, whichever is simpler.
> 
>> Currently, when you try to read or write from an invalid MSR, the
>> system is rebooted.
>> I'm not familiar with the way to handle a general protection
>> exceptions, do you know where should I look at?
> 
> Intel SDM, Linux kernel or Xen.
> 
> Daniel
> 

I've sorted out the MSR support check, but I'm struggling a bit with
handling the exception.

I've read the Intel SDM and other docs, and I think I understand the
reason why the system reboots: when the rdmsr or wrmsr access a
restricted area, a general protection exception is raised; and because
there's no interrupt 13 (GP#) handler installed, it double faults and
then triple faults, resulting in a cpu halt and motherboard reboot.

The linux kernel uses the following function to read and write to the msr:

https://elixir.bootlin.com/linux/latest/source/arch/x86/include/asm/msr.h#L137

If I understood it correctly, it uses some gcc syntax to setup the
handler of an exception in a different section, but I think that it
relies on the IDT that the linux kernel has already installed, so I
can't use that code.

https://github.com/torvalds/linux/blob/master/Documentation/x86/exception-tables.txt

Apart from setting up the IDT, I've found the opcodes CLI and STI, but
I'm quite sure that trying to use them to ignore the interrupt is a dead
end.

I've looked around in the grub code and there are only a few files that
reference CLI, STI, LIDT or IRET, mainly the code that makes a stage
change.
I also found that the file grub-core/commands/i386/pc/drivemap.c sets up
a int13h trap to handle the disk mappings.

Since I'm not very familiar with this area (and maybe I'm
overcomplicating it), it seems that the approach of handling the
exception could take a lot more effort than the whole module itself.

Now, the questions I have are about what direction I should take:

- Do I really need to make a custom handler (something like drivemap.c
does), or is there any simpler way?

- I assume that I'm not the first one to need to handle a general
protection exception in grub, but I couldn't find any example in other
modules/commands. Any reference would be appreciated.

- And from a practical point of view, in case that I need to setup a
custom handler for this, is it mandatory to ship the patch with it or
could it be added later (maybe adding a TODO now)?

Jesus


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 2/2] Add new MSR modules (rdmsr/wrmsr)
  2019-03-07 18:05             ` Jesús Diéguez Fernández
@ 2019-03-07 19:58               ` Daniel Kiper
  2019-03-07 21:28                 ` Jesús Diéguez Fernández
  0 siblings, 1 reply; 10+ messages in thread
From: Daniel Kiper @ 2019-03-07 19:58 UTC (permalink / raw)
  To: Jesús Diéguez Fernández; +Cc: grub-devel

On Thu, Mar 07, 2019 at 07:05:20PM +0100, Jesús Diéguez Fernández wrote:

[...]

> I've sorted out the MSR support check, but I'm struggling a bit with

Great!

> handling the exception.

Yeah, this can be difficult.

> I've read the Intel SDM and other docs, and I think I understand the
> reason why the system reboots: when the rdmsr or wrmsr access a
> restricted area, a general protection exception is raised; and because
> there's no interrupt 13 (GP#) handler installed, it double faults and
> then triple faults, resulting in a cpu halt and motherboard reboot.
>
> The linux kernel uses the following function to read and write to the msr:
>
> https://elixir.bootlin.com/linux/latest/source/arch/x86/include/asm/msr.h#L137
>
> If I understood it correctly, it uses some gcc syntax to setup the
> handler of an exception in a different section, but I think that it
> relies on the IDT that the linux kernel has already installed, so I
> can't use that code.
>
> https://github.com/torvalds/linux/blob/master/Documentation/x86/exception-tables.txt
>
> Apart from setting up the IDT, I've found the opcodes CLI and STI, but
> I'm quite sure that trying to use them to ignore the interrupt is a dead
> end.
>
> I've looked around in the grub code and there are only a few files that
> reference CLI, STI, LIDT or IRET, mainly the code that makes a stage
> change.
> I also found that the file grub-core/commands/i386/pc/drivemap.c sets up
> a int13h trap to handle the disk mappings.
>
> Since I'm not very familiar with this area (and maybe I'm
> overcomplicating it), it seems that the approach of handling the
> exception could take a lot more effort than the whole module itself.
>
> Now, the questions I have are about what direction I should take:
>
> - Do I really need to make a custom handler (something like drivemap.c
> does), or is there any simpler way?
>
> - I assume that I'm not the first one to need to handle a general
> protection exception in grub, but I couldn't find any example in other
> modules/commands. Any reference would be appreciated.

I think that we should have generic #GP handler which catches general
protection faults.

> - And from a practical point of view, in case that I need to setup a
> custom handler for this, is it mandatory to ship the patch with it or
> could it be added later (maybe adding a TODO now)?

I can accept this patch series without #GP handler if:
  - you add warning to the GRUB doc that #GP for rdmsr/wrmsr are not
    handled and system reboots; so, potential users have to be careful
    using these modules,
  - you add TODO notice to the code saying that generic #GP handling
    should be added to the GRUB code,
  - you promise me that at some point, let's say after GRUB release,
    you will try to implement generic #GP handler.

Is this acceptable for you?

Daniel


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 2/2] Add new MSR modules (rdmsr/wrmsr)
  2019-03-07 19:58               ` Daniel Kiper
@ 2019-03-07 21:28                 ` Jesús Diéguez Fernández
  2019-03-08 10:50                   ` Daniel Kiper
  0 siblings, 1 reply; 10+ messages in thread
From: Jesús Diéguez Fernández @ 2019-03-07 21:28 UTC (permalink / raw)
  To: Daniel Kiper; +Cc: grub-devel

El 7/3/19 a las 20:58, Daniel Kiper escribió:
> On Thu, Mar 07, 2019 at 07:05:20PM +0100, Jesús Diéguez Fernández wrote:
> 
> [...]
> 

[...]

>> - And from a practical point of view, in case that I need to setup a
>> custom handler for this, is it mandatory to ship the patch with it or
>> could it be added later (maybe adding a TODO now)?
> 
> I can accept this patch series without #GP handler if:
>   - you add warning to the GRUB doc that #GP for rdmsr/wrmsr are not
>     handled and system reboots; so, potential users have to be careful
>     using these modules,
>   - you add TODO notice to the code saying that generic #GP handling
>     should be added to the GRUB code,

That's what I had in mind.

>   - you promise me that at some point, let's say after GRUB release,
>     you will try to implement generic #GP handler.
> > Is this acceptable for you?
> 
> Daniel
> 

I think that having a generic #GP handler is a nice improvement.
As I said before, I don't know exactly the size of the rabbit hole I'm
entering, so I can't guarantee a delivery date, but I do guarantee that
I'll do my best.

GRUB is becoming very interesting to me, if you don't mind having a
newbie around here, maybe making one question or two sometimes, then we
have a deal. :)

Jesus


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 2/2] Add new MSR modules (rdmsr/wrmsr)
  2019-03-07 21:28                 ` Jesús Diéguez Fernández
@ 2019-03-08 10:50                   ` Daniel Kiper
  0 siblings, 0 replies; 10+ messages in thread
From: Daniel Kiper @ 2019-03-08 10:50 UTC (permalink / raw)
  To: Jesús Diéguez Fernández; +Cc: grub-devel

On Thu, Mar 07, 2019 at 10:28:06PM +0100, Jesús Diéguez Fernández wrote:
> El 7/3/19 a las 20:58, Daniel Kiper escribió:
> > On Thu, Mar 07, 2019 at 07:05:20PM +0100, Jesús Diéguez Fernández wrote:
> >
> > [...]
> >
>
> [...]
>
> >> - And from a practical point of view, in case that I need to setup a
> >> custom handler for this, is it mandatory to ship the patch with it or
> >> could it be added later (maybe adding a TODO now)?
> >
> > I can accept this patch series without #GP handler if:
> >   - you add warning to the GRUB doc that #GP for rdmsr/wrmsr are not
> >     handled and system reboots; so, potential users have to be careful
> >     using these modules,
> >   - you add TODO notice to the code saying that generic #GP handling
> >     should be added to the GRUB code,
>
> That's what I had in mind.

Perfect!

> >   - you promise me that at some point, let's say after GRUB release,
> >     you will try to implement generic #GP handler.
> > > Is this acceptable for you?
> >
> > Daniel
> >
>
> I think that having a generic #GP handler is a nice improvement.
> As I said before, I don't know exactly the size of the rabbit hole I'm
> entering, so I can't guarantee a delivery date, but I do guarantee that
> I'll do my best.

I do not expect delivery date from you. I am asking you to work on this
issue. If you encounter any problems send us questions. We will try to
help. However, please do not drop the project in the middle without
informing us why. This is the worst think which can be done.

> GRUB is becoming very interesting to me, if you don't mind having a

Nice to hear that!

> newbie around here, maybe making one question or two sometimes, then we

Sure thing!

> have a deal. :)

We have the deal!

Daniel


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2019-03-08 10:57 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-01 17:17 [PATCH v2 1/2] Replace __asm__ __volatile__ with asm volatile Jesús Diéguez Fernández
2019-03-01 17:17 ` [PATCH v2 2/2] Add new MSR modules (rdmsr/wrmsr) Jesús Diéguez Fernández
2019-03-05 11:09   ` Daniel Kiper
2019-03-05 22:17     ` Jesús Diéguez Fernández
2019-03-06 10:32       ` Daniel Kiper
     [not found]         ` <CAPo7o_5d2rsb13+iVopwtcZJGYWK1uHzJn21_ece747Jw56Qzw@mail.gmail.com>
     [not found]           ` <20190306143057.gkthocy5t6ojbzks@tomti.i.net-space.pl>
2019-03-07 18:05             ` Jesús Diéguez Fernández
2019-03-07 19:58               ` Daniel Kiper
2019-03-07 21:28                 ` Jesús Diéguez Fernández
2019-03-08 10:50                   ` Daniel Kiper
2019-03-05 10:45 ` [PATCH v2 1/2] Replace __asm__ __volatile__ with asm volatile Daniel Kiper

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.