[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v3] x86emul: build with -Os


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 5 Apr 2023 15:00:24 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=qAfNC/zjVcbX3wOy+qauUhTJ8tcVsFPgjltxjEMksao=; b=gJFipnJVgve6cXeZRxscll5tkVoMgsxmfSW4MKJKyUdzEO0gpwx9NXUQHvAWXf8EAYq2JBq85h2UDhYii4i6gnrYTzA33mUzDpbp6ppv3sP9LffHMk98k3gQDrMZ/pE8JP7/3dXONJ3joJTvoAec8cHWoVNWAy/N7d3O3n348MzZ3cWt/B7MvE/R1E9aFdrW9w4bkaccufi4thkzNWo62TEINUXxYylSpQVkq5WyURedb5TyxhfBQDhcHMwZ25oY0HTtIZN7+J4z5ON+q20UNHFjEJ9bKQfPcph4PnPX/M5iLVkCORnLq2bf3L5iHOTx/H0gWiAzglvytxZFa8eVlw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bu1LozaZwSHW0gQ8nnl1ClKXoo70m7hMUZeWF+Rn/E8nfQVmzKSa0TREPaf1/O1cpGT5aS0rAgZyYkVw1H1yrD33T9byTv0uGykw5m/Qa5JBRdcHafJwX8C64RjgVlB+99z64J4TZr4gpBSOQ5lKLY3a47ounbO7KX5KoZQmYc2cOvajwbQaxy1ip/vo3VHOuVlPtsxNvr0VyAtx1kLoIsBfkBsnAFUqeeODi5KIxmCiikJr9/wSztmmeQAI3QHkNHF3ldhyYWzTFfx+RxjjqJjkl4W/Kgd5giICbwsHVLOfoBQiJ7R1e+zYVPG1uM8yj+IioyJKcD3yAVIWhBJwBQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Wed, 05 Apr 2023 13:00:39 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Emulator code is large and involving it in guest operations cannot be
expected to be fast anyway. Help binary size as well as, for release
builds at least, compile time by building all involved code with size
optimization, independent of the build being a debug or a release one.

The size savings observed in a release build (with AMX and KeyLocker
code in place on top of what's upstream) are above 48k of .text, with
gcc 11.

To keep what is being tested similar to what's in the hypervisor, apply
the override to test and fuzzing harnesses as well (but affecting only
the core emulator files, not any auxiliary ones).

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
---
Of course if we were to gain a Kconfig control for selecting the
optimization level, the override done here may want to be controllable
that way as well then.
---
v3: Also apply to test and fuzzing harnesses.
v2: New.

--- a/tools/fuzz/x86_instruction_emulator/Makefile
+++ b/tools/fuzz/x86_instruction_emulator/Makefile
@@ -39,6 +39,10 @@ x86-emulate.h: x86_emulate/x86_emulate.h
 x86-emulate.o x86-emulate-cov.o: x86-emulate.h x86_emulate/x86_emulate.c 
x86_emulate/private.h
 fuzz-emul.o fuzz-emul-cov.o wrappers.o: x86-emulate.h
 
+x86-emulate.o x86-emulate-cov.o: CFLAGS += -Os
+$(filter x86_emulate/%.o,$(OBJS)): CFLAGS += -Os
+$(patsubst %.o,%-cov.o,$(filter x86_emulate/%.o,$(OBJS))): CFLAGS += -Os
+
 $(filter x86_emulate/%.o,$(OBJS)): x86_emulate/%.o: x86_emulate/%.c 
x86_emulate/private.h $(x86_emulate.h)
        $(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_$*.o) -c -o $@ $< $(APPEND_CFLAGS)
 
--- a/tools/tests/x86_emulator/Makefile
+++ b/tools/tests/x86_emulator/Makefile
@@ -298,7 +298,7 @@ $(OBJS): %.o: %.c $(x86_emulate.h)
        $(HOSTCC) $(HOSTCFLAGS) -c -g -o $@ $<
 
 x86-emulate.o: x86_emulate/x86_emulate.c
-x86-emulate.o x86_emulate/%.o: HOSTCFLAGS += -D__XEN_TOOLS__
+x86-emulate.o x86_emulate/%.o: HOSTCFLAGS += -D__XEN_TOOLS__ -Os
 
 # In order for our custom .type assembler directives to reliably land after
 # gcc's, we need to keep it from re-ordering top-level constructs.
--- a/xen/arch/x86/Makefile
+++ b/xen/arch/x86/Makefile
@@ -89,6 +89,7 @@ hostprogs-y += efi/mkreloc
 # Allows usercopy.c to include itself
 $(obj)/usercopy.o: CFLAGS-y += -iquote .
 
+$(obj)/x86_emulate.o: CFLAGS-y += -Os
 ifneq ($(CONFIG_HVM),y)
 $(obj)/x86_emulate.o: CFLAGS-y += -Wno-unused-label
 endif
--- a/xen/arch/x86/x86_emulate/Makefile
+++ b/xen/arch/x86/x86_emulate/Makefile
@@ -1,3 +1,5 @@
+CFLAGS-y += -Os
+
 obj-y += 0f01.o
 obj-y += 0fae.o
 obj-y += 0fc7.o



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.