All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/3] firmware: coreboot: Support for System Management Interrupt (SMI) handling in coreboot payload (MM payload concept)
@ 2025-06-16 14:01 Michal Gorlas
  2025-06-16 14:01 ` [PATCH v2 1/3] firmware: coreboot: support for parsing SMM related informations from coreboot tables Michal Gorlas
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: Michal Gorlas @ 2025-06-16 14:01 UTC (permalink / raw)
  To: Tzung-Bi Shih, Brian Norris, Julius Werner
  Cc: linux-kernel, chrome-platform, Marcello Sylvester Bauer,
	Michal Gorlas

Hi,

This patchset adds support for MM payload when Linux is used as
coreboot's payload. The main idea is to delegate higher-level SMM
functions to the payload, limiting the coreboot's System Management
Mode (SMM) related responsibilities to the minimum of basic SMM setup [1]. This is
done by loading a blob with SMI handler to the shared buffer, from
which it is copied to SMRAM [2].

The MM payload is still in a Proof of Concept stage, and we are still
working on getting the patches needed for coreboot upstreamed, but I would
appreciate any feedback that you may have.

Thanks,
Michal

[1]: https://github.com/9elements/LinuxBootSMM/wiki/Proposed-design#current-design-approach---mm-payload
[2]: https://github.com/9elements/LinuxBootSMM/wiki/Proof-of-Concept-(PoC)

Changes in v2:
- merged mm_info into mm_loader
- removed mm_loader_exit in favour of allocating memory with devm_*()
- added forgotten "\n\t" in trigger_smi()
- added gitignore in mm_handler/
- added COREBOOT_PAYLOAD_MM dependency on x86
- error handling for mm_info struct
- error handling for shared_buffer
- removed whitespace changes in coreboot_table.h
- removed INFO level prints 

---
Michal Gorlas (3):
      firmware: coreboot: support for parsing SMM related  informations from coreboot tables
      firmware: coreboot: loader for Linux-owned SMI handler
      firmware: coreboot: Linux-owned SMI handler to be loaded by coreboot

 drivers/firmware/google/Kconfig                  |  12 +
 drivers/firmware/google/Makefile                 |  11 +
 drivers/firmware/google/coreboot_table.h         |  11 +
 drivers/firmware/google/mm_blob.S                |  20 +
 drivers/firmware/google/mm_handler/.gitignore    |   4 +
 drivers/firmware/google/mm_handler/Makefile      |  51 +++
 drivers/firmware/google/mm_handler/handler.lds.S |  46 ++
 drivers/firmware/google/mm_handler/mm_handler.S  | 510 +++++++++++++++++++++++
 drivers/firmware/google/mm_handler/mm_handler.h  |  21 +
 drivers/firmware/google/mm_handler/mm_header.S   |  19 +
 drivers/firmware/google/mm_loader.c              | 215 ++++++++++
 drivers/firmware/google/mm_payload.h             |  58 +++
 12 files changed, 978 insertions(+)
---
base-commit: 19272b37aa4f83ca52bdf9c16d5d81bdd1354494
change-id: 20250613-coreboot-payload-mm-6642bb42284a

Best regards,
-- 
Michal Gorlas <michal.gorlas@9elements.com>


^ permalink raw reply	[flat|nested] 13+ messages in thread
* Re: [PATCH v2 2/3] firmware: coreboot: loader for Linux-owned SMI handler
@ 2025-06-18  0:30 kernel test robot
  0 siblings, 0 replies; 13+ messages in thread
From: kernel test robot @ 2025-06-18  0:30 UTC (permalink / raw)
  Cc: oe-kbuild-all, llvm

In-Reply-To: <20250616-coreboot-payload-mm-v2-2-5d679b682e13@9elements.com>
References: <20250616-coreboot-payload-mm-v2-2-5d679b682e13@9elements.com>
TO: Michal Gorlas <michal.gorlas@9elements.com>
TO: "Tzung-Bi Shih" <tzungbi@kernel.org>
TO: Brian Norris <briannorris@chromium.org>
TO: Julius Werner <jwerner@chromium.org>
CC: linux-kernel@vger.kernel.org
CC: chrome-platform@lists.linux.dev
CC: Marcello Sylvester Bauer <marcello.bauer@9elements.com>
CC: Michal Gorlas <michal.gorlas@9elements.com>

Hi Michal,

kernel test robot noticed the following build errors:

[auto build test ERROR on 19272b37aa4f83ca52bdf9c16d5d81bdd1354494]

url:    https://github.com/intel-lab-lkp/linux/commits/Michal-Gorlas/firmware-coreboot-support-for-parsing-SMM-related-informations-from-coreboot-tables/20250616-220336
base:   19272b37aa4f83ca52bdf9c16d5d81bdd1354494
patch link:    https://lore.kernel.org/r/20250616-coreboot-payload-mm-v2-2-5d679b682e13%409elements.com
patch subject: [PATCH v2 2/3] firmware: coreboot: loader for Linux-owned SMI handler
config: i386-randconfig-012-20250618 (https://download.01.org/0day-ci/archive/20250618/202506180813.XldQ0K9E-lkp@intel.com/config)
compiler: clang version 20.1.2 (https://github.com/llvm/llvm-project 58df0ef89dd64126512e4ee27b4ac3fd8ddf6247)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250618/202506180813.XldQ0K9E-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202506180813.XldQ0K9E-lkp@intel.com/

All errors (new ones prefixed by >>):

>> drivers/firmware/google/mm_loader.c:38:15: error: inline assembly requires more registers than available
      38 |         asm volatile("movq      %[cmd], %%rax\n\t"
         |                      ^
>> drivers/firmware/google/mm_loader.c:38:15: error: register %rax is only available in 64-bit mode
   <inline asm>:1:13: note: instantiated into assembly here
       1 |         movq    %eax, %rax
         |                       ^~~~
   drivers/firmware/google/mm_loader.c:38:36: error: register %rax is only available in 64-bit mode
      38 |         asm volatile("movq      %[cmd], %%rax\n\t"
         |                                                ^
   <inline asm>:2:7: note: instantiated into assembly here
       2 |         movq    %rax, %rcx
         |                 ^~~~~
>> drivers/firmware/google/mm_loader.c:39:28: error: register %rbx is only available in 64-bit mode
      39 |                      "movq      %%rax, %%rcx\n\t"
         |                                               ^
   <inline asm>:3:13: note: instantiated into assembly here
       3 |         movq    %eax, %rbx
         |                       ^~~~
>> drivers/firmware/google/mm_loader.c:40:29: error: register %r8 is only available in 64-bit mode
      40 |                      "movq      %[arg], %%rbx\n\t"
         |                                                ^
   <inline asm>:4:13: note: instantiated into assembly here
       4 |         movq    %ecx, %r8
         |                       ^~~
>> drivers/firmware/google/mm_loader.c:44:26: error: register %rcx is only available in 64-bit mode
      44 |                      "outb      %%al, %%dx\n\t"
         |                                             ^
   <inline asm>:8:7: note: instantiated into assembly here
       8 |         cmpq    %rcx, %rax
         |                 ^~~~~
   drivers/firmware/google/mm_loader.c:46:30: error: register %rcx is only available in 64-bit mode
      46 |                      "jne       .return_changed\n\t"
         |                                                  ^
   <inline asm>:10:8: note: instantiated into assembly here
      10 |         pushq   %rcx
         |                 ^~~~
   drivers/firmware/google/mm_loader.c:47:22: error: register %rcx is only available in 64-bit mode
      47 |                      "pushq     %%rcx\n\t"
         |                                        ^
   <inline asm>:11:15: note: instantiated into assembly here
      11 |         movq    $10000, %rcx
         |                         ^~~~
   drivers/firmware/google/mm_loader.c:49:18: error: register %rcx is only available in 64-bit mode
      49 |                      "rep       nop\n\t"
         |                                      ^
   <inline asm>:13:7: note: instantiated into assembly here
      13 |         popq    %rcx
         |                 ^~~~
   drivers/firmware/google/mm_loader.c:50:21: error: register %r8 is only available in 64-bit mode
      50 |                      "popq      %%rcx\n\t"
         |                                        ^
   <inline asm>:14:11: note: instantiated into assembly here
      14 |         cmpq    $0, %r8
         |                     ^~~
   drivers/firmware/google/mm_loader.c:52:33: error: register %r8 is only available in 64-bit mode
      52 |                      "je        .return_not_changed\n\t"
         |                                                      ^
   <inline asm>:16:7: note: instantiated into assembly here
      16 |         decq    %r8
         |                 ^~~
   drivers/firmware/google/mm_loader.c:55:27: error: register %rax is only available in 64-bit mode
      55 |                      ".return_changed:\n\t"
         |                                         ^
   <inline asm>:19:7: note: instantiated into assembly here
      19 |         movq    %rax, %eax
         |                 ^~~~~
   drivers/firmware/google/mm_loader.c:58:31: error: register %rcx is only available in 64-bit mode
      58 |                      ".return_not_changed:\n\t"
         |                                             ^
   <inline asm>:22:7: note: instantiated into assembly here
      22 |         movq    %rcx, %eax
         |                 ^~~~~
   13 errors generated.


vim +38 drivers/firmware/google/mm_loader.c

    27	
    28	/*
    29	 * This is x86_64 specific, assuming that we want this to also work on i386,
    30	 * we either need to have "trigger_smi32" bounded by preprocessor guards(?)
    31	 * or mm_loader32 and then mm_loader$(BITS) in Makefile(?).
    32	 */
    33	static int trigger_smi(u64 cmd, u64 arg, u64 retry)
    34	{
    35		u64 status;
    36		u16 apmc_port = 0xb2;
    37	
  > 38		asm volatile("movq	%[cmd], %%rax\n\t"
  > 39			     "movq	%%rax, %%rcx\n\t"
  > 40			     "movq	%[arg], %%rbx\n\t"
    41			     "movq	%[retry], %%r8\n\t"
    42			     ".trigger:\n\t"
    43			     "mov	%[apmc_port], %%dx\n\t"
  > 44			     "outb	%%al, %%dx\n\t"
    45			     "cmpq	%%rcx, %%rax\n\t"
    46			     "jne	.return_changed\n\t"
    47			     "pushq	%%rcx\n\t"
    48			     "movq	$10000, %%rcx\n\t"
    49			     "rep	nop\n\t"
    50			     "popq	%%rcx\n\t"
    51			     "cmpq	$0, %%r8\n\t"
    52			     "je	.return_not_changed\n\t"
    53			     "decq	%%r8\n\t"
    54			     "jmp	.trigger\n\t"
    55			     ".return_changed:\n\t"
    56			     "movq	%%rax, %[status]\n\t"
    57			     "jmp	.end\n\t"
    58			     ".return_not_changed:\n\t"
    59			     "movq	%%rcx, %[status]\n\t"
    60			     ".end:\n\t"
    61			     : [status] "=r"(status)
    62			     : [cmd] "r"(cmd), [arg] "r"(arg), [retry] "r"(retry),
    63			       [apmc_port] "r"(apmc_port)
    64			     : "%rax", "%rbx", "%rdx", "%rcx", "%r8");
    65	
    66		if (status == cmd || status == PAYLOAD_MM_RET_FAILURE)
    67			status = PAYLOAD_MM_RET_FAILURE;
    68		else
    69			status = PAYLOAD_MM_RET_SUCCESS;
    70	
    71		return status;
    72	}
    73	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

end of thread, other threads:[~2025-06-27 11:41 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-16 14:01 [PATCH v2 0/3] firmware: coreboot: Support for System Management Interrupt (SMI) handling in coreboot payload (MM payload concept) Michal Gorlas
2025-06-16 14:01 ` [PATCH v2 1/3] firmware: coreboot: support for parsing SMM related informations from coreboot tables Michal Gorlas
2025-06-25  5:58   ` Tzung-Bi Shih
2025-06-16 14:01 ` [PATCH v2 2/3] firmware: coreboot: loader for Linux-owned SMI handler Michal Gorlas
2025-06-25  5:58   ` Tzung-Bi Shih
2025-06-25 12:26     ` Michal Gorlas
2025-06-26 11:41       ` Michal Gorlas
2025-06-27  2:49         ` Tzung-Bi Shih
2025-06-27 11:40           ` Michal Gorlas
2025-06-27  2:33       ` Tzung-Bi Shih
2025-06-16 14:01 ` [PATCH v2 3/3] firmware: coreboot: Linux-owned SMI handler to be loaded by coreboot Michal Gorlas
2025-06-25  5:58 ` [PATCH v2 0/3] firmware: coreboot: Support for System Management Interrupt (SMI) handling in coreboot payload (MM payload concept) Tzung-Bi Shih
  -- strict thread matches above, loose matches on Subject: below --
2025-06-18  0:30 [PATCH v2 2/3] firmware: coreboot: loader for Linux-owned SMI handler kernel test robot

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.