diff mbox series

[for-4.20] hvmloader: Use fastcall everywhere

Message ID 20240717111817.3517937-1-andrew.cooper3@citrix.com (mailing list archive)
State New
Headers show
Series [for-4.20] hvmloader: Use fastcall everywhere | expand

Commit Message

Andrew Cooper July 17, 2024, 11:18 a.m. UTC
HVMLoader is a single freestanding 32bit program with no external
dependencies.  Use the fastcall calling convetion (up to 3 parameters in
registers rather than on the stack) globally, which is more efficient because
of reducing the number of stack operations.

Some bloat-o-meter highligs are:

  add/remove: 0/0 grow/shrink: 3/118 up/down: 8/-3004 (-2996)
  Function                                     old     new   delta
  ...
  hvmloader_acpi_build_tables                 1125     961    -164
  acpi_build_tables                           1277    1081    -196
  pci_setup                                   4756    4516    -240
  construct_secondary_tables                  1689    1447    -242

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Roger Pau Monné <roger.pau@citrix.com>

I was surprised to find that nowhere in the handover to other blobs do we pass
parameters on the stack, but then again the entry point of the new blobs
typically happen with no stack anyway so I suppose I shouldn't be surprised.
---
 tools/firmware/hvmloader/Makefile | 2 +-
 tools/firmware/hvmloader/smp.c    | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)


base-commit: 57338346f29cea7b183403561bdc5f407163b846
prerequisite-patch-id: 212002cd69805ec19f556756d487638c7d348878

Comments

Jan Beulich July 17, 2024, 12:09 p.m. UTC | #1
On 17.07.2024 13:18, Andrew Cooper wrote:
> HVMLoader is a single freestanding 32bit program with no external
> dependencies.  Use the fastcall calling convetion (up to 3 parameters in
> registers rather than on the stack) globally, which is more efficient because
> of reducing the number of stack operations.
> 
> Some bloat-o-meter highligs are:
> 
>   add/remove: 0/0 grow/shrink: 3/118 up/down: 8/-3004 (-2996)
>   Function                                     old     new   delta
>   ...
>   hvmloader_acpi_build_tables                 1125     961    -164
>   acpi_build_tables                           1277    1081    -196
>   pci_setup                                   4756    4516    -240
>   construct_secondary_tables                  1689    1447    -242
> 
> No functional change.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>

Reviewed-by: Jan Beulich <jbeulich@suse.com>
diff mbox series

Patch

diff --git a/tools/firmware/hvmloader/Makefile b/tools/firmware/hvmloader/Makefile
index 0e1dce26b342..05572f17f609 100644
--- a/tools/firmware/hvmloader/Makefile
+++ b/tools/firmware/hvmloader/Makefile
@@ -25,7 +25,7 @@  ld-option = $(shell if $(LD) -v $(1) >/dev/null 2>&1; then echo y; else echo n;
 # SMBIOS spec requires format mm/dd/yyyy
 SMBIOS_REL_DATE ?= $(shell date +%m/%d/%Y)
 
-CFLAGS += $(CFLAGS_xeninclude) -fno-pic
+CFLAGS += $(CFLAGS_xeninclude) -fno-pic -mregparm=3
 
 # We mustn't use tools-only public interfaces.
 CFLAGS += -D__XEN_INTERFACE_VERSION__=__XEN_LATEST_INTERFACE_VERSION__
diff --git a/tools/firmware/hvmloader/smp.c b/tools/firmware/hvmloader/smp.c
index 5d46eee1c5f4..1b940cefd071 100644
--- a/tools/firmware/hvmloader/smp.c
+++ b/tools/firmware/hvmloader/smp.c
@@ -31,7 +31,7 @@ 
 
 static int ap_callin;
 
-static void __attribute__((regparm(1))) cpu_setup(unsigned int cpu)
+static void cpu_setup(unsigned int cpu)
 {
     printf(" - CPU%d ... ", cpu);
     cacheattr_init();