From patchwork Mon Sep 2 13:32:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 13787303 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5F53DCD342D for ; Mon, 2 Sep 2024 13:33:10 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.787949.1197403 (Exim 4.92) (envelope-from ) id 1sl7Au-0000vU-Pl; Mon, 02 Sep 2024 13:32:56 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 787949.1197403; Mon, 02 Sep 2024 13:32:56 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sl7Au-0000vL-Mb; Mon, 02 Sep 2024 13:32:56 +0000 Received: by outflank-mailman (input) for mailman id 787949; Mon, 02 Sep 2024 13:32:54 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sl7As-0000uL-OJ for xen-devel@lists.xenproject.org; Mon, 02 Sep 2024 13:32:54 +0000 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [2a00:1450:4864:20::52d]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id daa11806-692f-11ef-99a1-01e77a169b0f; Mon, 02 Sep 2024 15:32:52 +0200 (CEST) Received: by mail-ed1-x52d.google.com with SMTP id 4fb4d7f45d1cf-5c0a9f2b967so4016000a12.2 for ; Mon, 02 Sep 2024 06:32:52 -0700 (PDT) Received: from andrewcoop.eng.citrite.net ([185.25.67.249]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8989196975sm562333666b.135.2024.09.02.06.32.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Sep 2024 06:32:50 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: daa11806-692f-11ef-99a1-01e77a169b0f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1725283971; x=1725888771; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JkjCsz/TTC6SLbAh60aBVRxv3OTDCBQ4EzpkKj3S5ug=; b=Gd1NTWoSjj79AVK9xEMB4IHLESKHqVM9boIALpsRoxvc/aiCNeO4gU2ZN5SgWTqIh7 6anaJ1qvYUdW7aZHhB3ZTQ2bUGizlmhF5Tr543cJdCuC/KvBkxqChd30v6rDQNXrgBHk 0vc3b87MdSCJ4oayUJ42aELX0WCnQh39W+2q4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725283971; x=1725888771; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JkjCsz/TTC6SLbAh60aBVRxv3OTDCBQ4EzpkKj3S5ug=; b=E/b4+5ACzQ5bx6SGVBuOoytW1dFOeW1ILhm36dk5VNSmmX0FgBUPt+TxFmZyCeiXNx 2WhtbmG+XNfFRy+tw43BnYOX87KBJRyuIUoRSI8V0YspEzU/lKmkYWsqE4VePj/YnLZ8 sGeMZF62q/JE+QhAmabA0EJfX1hDpTAXu7SYoNSV9O/BCPCuO4bYBZffdeJ+ZbLoPf3/ Ze0wibmx4pN9OmMehEB0sJ+EY2mlAXz/6EwcoW6Ugk3DJ127MgtNlEzbGhZXv78reOrR 3hMF5w+ms/5uy2/riFFX7mao6psw4OVKCeTFdVRr9I1JfUKcbaPJobCoTqVBISbRehsi KPGg== X-Gm-Message-State: AOJu0Yz/qqobozablDF7cPBG+U5MM5tmcOGeT5qVtz8Z24dLnb5e9Lcw Ho2BGPezA+eVYSeXGYm5F+SWd2EWMeXAOhQoY1MuIYAQQ1l0CTL89CDvD9xJCdXxBWb37/vLXFr G X-Google-Smtp-Source: AGHT+IGLiZWsjP904HzU5d+Lqwsu331ymEnmmqjv5MvEuswF7Gkc+QrUPOrkKmjl1yJdP48f1/EmGw== X-Received: by 2002:a17:907:1c9f:b0:a8a:18f9:269f with SMTP id a640c23a62f3a-a8a18f92a81mr42918266b.60.1725283970945; Mon, 02 Sep 2024 06:32:50 -0700 (PDT) From: Andrew Cooper To: Xen-devel Cc: Andrew Cooper , Jan Beulich , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Frediano Ziglio Subject: [PATCH 1/4] x86/boot: Use Date: Mon, 2 Sep 2024 14:32:29 +0100 Message-Id: <20240902133232.3302839-2-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240902133232.3302839-1-andrew.cooper3@citrix.com> References: <20240902133232.3302839-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 ... rather than opencoding locally. This also covers NULL and *_MAX. No functional change. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: Jan Beulich CC: Roger Pau Monné CC: Frediano Ziglio --- xen/arch/x86/boot/cmdline.c | 2 ++ xen/arch/x86/boot/defs.h | 17 ----------------- xen/arch/x86/boot/reloc.c | 2 ++ 3 files changed, 4 insertions(+), 17 deletions(-) diff --git a/xen/arch/x86/boot/cmdline.c b/xen/arch/x86/boot/cmdline.c index b8ad7f3a144a..28a47da7ab02 100644 --- a/xen/arch/x86/boot/cmdline.c +++ b/xen/arch/x86/boot/cmdline.c @@ -31,6 +31,8 @@ asm ( ); #include +#include + #include "defs.h" #include "video.h" diff --git a/xen/arch/x86/boot/defs.h b/xen/arch/x86/boot/defs.h index ee1a4da6af03..cf9a80d116f3 100644 --- a/xen/arch/x86/boot/defs.h +++ b/xen/arch/x86/boot/defs.h @@ -20,14 +20,10 @@ #ifndef __BOOT_DEFS_H__ #define __BOOT_DEFS_H__ -#include - #define __maybe_unused __attribute__((__unused__)) #define __packed __attribute__((__packed__)) #define __stdcall __attribute__((__stdcall__)) -#define NULL ((void *)0) - #define ALIGN_UP(arg, align) \ (((arg) + (align) - 1) & ~((typeof(arg))(align) - 1)) @@ -47,17 +43,4 @@ #define tolower(c) ((c) | 0x20) -typedef unsigned char u8; -typedef unsigned short u16; -typedef unsigned int u32; -typedef unsigned long long u64; -typedef unsigned int size_t; -typedef u8 uint8_t; -typedef u16 uint16_t; -typedef u32 uint32_t; -typedef u64 uint64_t; - -#define UINT16_MAX ((uint16_t)(~0U)) -#define UINT_MAX (~0U) - #endif /* __BOOT_DEFS_H__ */ diff --git a/xen/arch/x86/boot/reloc.c b/xen/arch/x86/boot/reloc.c index 589e026ff9fb..ac8b58b69581 100644 --- a/xen/arch/x86/boot/reloc.c +++ b/xen/arch/x86/boot/reloc.c @@ -26,6 +26,8 @@ asm ( " jmp reloc \n" ); +#include + #include "defs.h" #include From patchwork Mon Sep 2 13:32:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 13787300 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 511C0CD13CF for ; Mon, 2 Sep 2024 13:33:09 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.787950.1197408 (Exim 4.92) (envelope-from ) id 1sl7Av-0000z4-3m; Mon, 02 Sep 2024 13:32:57 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 787950.1197408; Mon, 02 Sep 2024 13:32:57 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sl7Au-0000y5-Th; Mon, 02 Sep 2024 13:32:56 +0000 Received: by outflank-mailman (input) for mailman id 787950; Mon, 02 Sep 2024 13:32:54 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sl7As-0000fj-RZ for xen-devel@lists.xenproject.org; Mon, 02 Sep 2024 13:32:54 +0000 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [2a00:1450:4864:20::62b]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id dba3bc97-692f-11ef-a0b2-8be0dac302b0; Mon, 02 Sep 2024 15:32:54 +0200 (CEST) Received: by mail-ej1-x62b.google.com with SMTP id a640c23a62f3a-a7a81bd549eso355546266b.3 for ; Mon, 02 Sep 2024 06:32:54 -0700 (PDT) Received: from andrewcoop.eng.citrite.net ([185.25.67.249]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8989196975sm562333666b.135.2024.09.02.06.32.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Sep 2024 06:32:51 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: dba3bc97-692f-11ef-a0b2-8be0dac302b0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1725283973; x=1725888773; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lp4Hjg94tKrZYICmOS2HvNx6IWTgN7ERFoJhbNxt2hw=; b=GvSIQAgS67EKP8o1MJr7Ue8tuFw4XaHaCQfRxDyFC5VLn+GCBQB0Cd6j/nbkFdtGax 32K4mZ7u1dG+dFgX3EOjaZwO/7zgW6btoe58URyUK9UD9/HXurhoeLLzeZFfhH4PkBNx r0NapU3/FLHq/zdBqv/jbjiyodpp6JuZx+F2o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725283973; x=1725888773; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lp4Hjg94tKrZYICmOS2HvNx6IWTgN7ERFoJhbNxt2hw=; b=ChCNEhuuTdtyJ90UmdLDapc6LQ38CoQytfQA/M9Yn29K2zb6kO837b8H5UjVd7sxiV iInruN4I01D5AvWVMNEnwRi+xx0xA5UxgQQd5vbZOlNFX1vBCPNavlkONaYGKHopAUrh NzNQIaO/Fb/bvEq1kiLVVIjHIFDvG4IeYHxNJX4Y3UozvcbE/CdL5l7oBBDu9xR1yiFD 2Mm/DQhYiGLoEjT5jjJZGEPl002qTTueU4y+rHURUDyS9/tcrGamXx/ugyBVXY5FY1kU k8i7cllmu+ARCYI+zOV+lM9ziHdgPDw06P9vIPu+FZ6RMMacKXhNVLGeNmTTDiYf7hSP c3Tw== X-Gm-Message-State: AOJu0YzZo6PEz32mpwpjYmcA/8a9CWDYuTlUkQyK4wY+A2QZhgr80Mjg r7BYxFe5ISN+LymiWiD4rxx8Ah17+IZXAXmGYW4i41CQPTlXXHx1tVO3Aw/AnleHiMOi+2x5Xgv 4 X-Google-Smtp-Source: AGHT+IF7L5H0cHoI7pyXW0UG3zW0dzJJJBgyMRjpGl+dI8EV9R2woi6ZucqStzp/m2yDzuNf64DR5A== X-Received: by 2002:a17:906:6a03:b0:a77:e48d:bc8 with SMTP id a640c23a62f3a-a8a1d2c8219mr13502066b.21.1725283972059; Mon, 02 Sep 2024 06:32:52 -0700 (PDT) From: Andrew Cooper To: Xen-devel Cc: Andrew Cooper , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Frediano Ziglio Subject: [PATCH 2/4] x86/boot: Use Date: Mon, 2 Sep 2024 14:32:30 +0100 Message-Id: <20240902133232.3302839-3-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240902133232.3302839-1-andrew.cooper3@citrix.com> References: <20240902133232.3302839-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 ... rather than opencoding locally. This involve collecting various macros scattered around Xen (min()/max() macros from kernel.h, and _p() from lib.h) and moving them into macros.h In reloc.c, replace ALIGN_UP() with ROUNDUP(). No functional change. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: Jan Beulich CC: Roger Pau Monné CC: Frediano Ziglio --- xen/arch/x86/boot/cmdline.c | 4 ++++ xen/arch/x86/boot/defs.h | 19 ---------------- xen/arch/x86/boot/reloc.c | 11 +++++----- xen/include/xen/kernel.h | 36 +----------------------------- xen/include/xen/lib.h | 2 -- xen/include/xen/macros.h | 44 +++++++++++++++++++++++++++++++++++++ 6 files changed, 55 insertions(+), 61 deletions(-) diff --git a/xen/arch/x86/boot/cmdline.c b/xen/arch/x86/boot/cmdline.c index 28a47da7ab02..b7375d106678 100644 --- a/xen/arch/x86/boot/cmdline.c +++ b/xen/arch/x86/boot/cmdline.c @@ -31,6 +31,7 @@ asm ( ); #include +#include #include #include "defs.h" @@ -50,6 +51,9 @@ typedef struct __packed { #endif } early_boot_opts_t; +/* Avoid pulling in all of ctypes.h for this. */ +#define tolower(c) ((c) | 0x20) + /* * Space and TAB are obvious delimiters. However, I am * adding "\n" and "\r" here too. Just in case when diff --git a/xen/arch/x86/boot/defs.h b/xen/arch/x86/boot/defs.h index cf9a80d116f3..4d519ac4f5ea 100644 --- a/xen/arch/x86/boot/defs.h +++ b/xen/arch/x86/boot/defs.h @@ -24,23 +24,4 @@ #define __packed __attribute__((__packed__)) #define __stdcall __attribute__((__stdcall__)) -#define ALIGN_UP(arg, align) \ - (((arg) + (align) - 1) & ~((typeof(arg))(align) - 1)) - -#define min(x,y) ({ \ - const typeof(x) _x = (x); \ - const typeof(y) _y = (y); \ - (void) (&_x == &_y); \ - _x < _y ? _x : _y; }) - -#define max(x,y) ({ \ - const typeof(x) _x = (x); \ - const typeof(y) _y = (y); \ - (void) (&_x == &_y); \ - _x > _y ? _x : _y; }) - -#define _p(val) ((void *)(unsigned long)(val)) - -#define tolower(c) ((c) | 0x20) - #endif /* __BOOT_DEFS_H__ */ diff --git a/xen/arch/x86/boot/reloc.c b/xen/arch/x86/boot/reloc.c index ac8b58b69581..eb9902d73fd9 100644 --- a/xen/arch/x86/boot/reloc.c +++ b/xen/arch/x86/boot/reloc.c @@ -26,6 +26,7 @@ asm ( " jmp reloc \n" ); +#include #include #include "defs.h" @@ -76,7 +77,7 @@ static uint32_t alloc; static uint32_t alloc_mem(uint32_t bytes) { - return alloc -= ALIGN_UP(bytes, 16); + return alloc -= ROUNDUP(bytes, 16); } static void zero_mem(uint32_t s, uint32_t bytes) @@ -202,11 +203,11 @@ static multiboot_info_t *mbi2_reloc(uint32_t mbi_in, uint32_t video_out) zero_mem(ptr, sizeof(*mbi_out)); /* Skip Multiboot2 information fixed part. */ - ptr = ALIGN_UP(mbi_in + sizeof(*mbi_fix), MULTIBOOT2_TAG_ALIGN); + ptr = ROUNDUP(mbi_in + sizeof(*mbi_fix), MULTIBOOT2_TAG_ALIGN); /* Get the number of modules. */ for ( tag = _p(ptr); (uint32_t)tag - mbi_in < mbi_fix->total_size; - tag = _p(ALIGN_UP((uint32_t)tag + tag->size, MULTIBOOT2_TAG_ALIGN)) ) + tag = _p(ROUNDUP((uint32_t)tag + tag->size, MULTIBOOT2_TAG_ALIGN)) ) { if ( tag->type == MULTIBOOT2_TAG_TYPE_MODULE ) ++mbi_out->mods_count; @@ -227,11 +228,11 @@ static multiboot_info_t *mbi2_reloc(uint32_t mbi_in, uint32_t video_out) } /* Skip Multiboot2 information fixed part. */ - ptr = ALIGN_UP(mbi_in + sizeof(*mbi_fix), MULTIBOOT2_TAG_ALIGN); + ptr = ROUNDUP(mbi_in + sizeof(*mbi_fix), MULTIBOOT2_TAG_ALIGN); /* Put all needed data into mbi_out. */ for ( tag = _p(ptr); (uint32_t)tag - mbi_in < mbi_fix->total_size; - tag = _p(ALIGN_UP((uint32_t)tag + tag->size, MULTIBOOT2_TAG_ALIGN)) ) + tag = _p(ROUNDUP((uint32_t)tag + tag->size, MULTIBOOT2_TAG_ALIGN)) ) { switch ( tag->type ) { diff --git a/xen/include/xen/kernel.h b/xen/include/xen/kernel.h index bc2440b5f96e..c5b6cc977772 100644 --- a/xen/include/xen/kernel.h +++ b/xen/include/xen/kernel.h @@ -5,43 +5,9 @@ * 'kernel.h' contains some often-used function prototypes etc */ +#include #include -/* - * min()/max() macros that also do - * strict type-checking.. See the - * "unnecessary" pointer comparison. - */ -#define min(x,y) ({ \ - const typeof(x) _x = (x); \ - const typeof(y) _y = (y); \ - (void) (&_x == &_y); \ - _x < _y ? _x : _y; }) - -#define max(x,y) ({ \ - const typeof(x) _x = (x); \ - const typeof(y) _y = (y); \ - (void) (&_x == &_y); \ - _x > _y ? _x : _y; }) - -/* - * ..and if you can't take the strict - * types, you can specify one yourself. - * - * Or not use min/max at all, of course. - */ -#define min_t(type,x,y) \ - ({ type __x = (x); type __y = (y); __x < __y ? __x: __y; }) -#define max_t(type,x,y) \ - ({ type __x = (x); type __y = (y); __x > __y ? __x: __y; }) - -/* - * pre-processor, array size, and bit field width suitable variants; - * please don't use in "normal" expressions. - */ -#define MIN(x,y) ((x) < (y) ? (x) : (y)) -#define MAX(x,y) ((x) > (y) ? (x) : (y)) - /** * container_of - cast a member of a structure out to the containing structure * diff --git a/xen/include/xen/lib.h b/xen/include/xen/lib.h index 394319c81863..e884a02ee8ce 100644 --- a/xen/include/xen/lib.h +++ b/xen/include/xen/lib.h @@ -57,8 +57,6 @@ static inline void debugtrace_printk(const char *fmt, ...) {} #endif -/* Allows us to use '%p' as general-purpose machine-word format char. */ -#define _p(_x) ((void *)(unsigned long)(_x)) extern void printk(const char *fmt, ...) __attribute__ ((format (printf, 1, 2), cold)); diff --git a/xen/include/xen/macros.h b/xen/include/xen/macros.h index 44d723fd121a..19caaa8026ea 100644 --- a/xen/include/xen/macros.h +++ b/xen/include/xen/macros.h @@ -101,6 +101,50 @@ */ #define sizeof_field(type, member) sizeof(((type *)NULL)->member) +/* Cast an arbitrary integer to a pointer. */ +#define _p(x) ((void *)(unsigned long)(x)) + +/* + * min()/max() macros that also do strict type-checking.. + */ +#define min(x, y) \ + ({ \ + const typeof(x) _x = (x); \ + const typeof(y) _y = (y); \ + (void)(&_x == &_y); /* typecheck */ \ + _x < _y ? _x : _y; \ + }) +#define max(x, y) \ + ({ \ + const typeof(x) _x = (x); \ + const typeof(y) _y = (y); \ + (void)(&_x == &_y); /* typecheck */ \ + _x > _y ? _x : _y; \ + }) + +/* + * ..and if you can't take the strict types, you can specify one yourself. + */ +#define min_t(type, x, y) \ + ({ \ + type __x = (x); \ + type __y = (y); \ + __x < __y ? __x: __y; \ + }) +#define max_t(type, x, y) \ + ({ \ + type __x = (x); \ + type __y = (y); \ + __x > __y ? __x: __y; \ + }) + +/* + * pre-processor, array size, and bit field width suitable variants; + * please don't use in "normal" expressions. + */ +#define MIN(x, y) ((x) < (y) ? (x) : (y)) +#define MAX(x, y) ((x) > (y) ? (x) : (y)) + #endif /* __ASSEMBLY__ */ #endif /* __MACROS_H__ */ From patchwork Mon Sep 2 13:32:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 13787304 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D5120CD342A for ; Mon, 2 Sep 2024 13:33:09 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.787951.1197413 (Exim 4.92) (envelope-from ) id 1sl7Av-00012n-CQ; Mon, 02 Sep 2024 13:32:57 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 787951.1197413; Mon, 02 Sep 2024 13:32:57 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sl7Av-00010E-5K; Mon, 02 Sep 2024 13:32:57 +0000 Received: by outflank-mailman (input) for mailman id 787951; Mon, 02 Sep 2024 13:32:56 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sl7Au-0000uL-C1 for xen-devel@lists.xenproject.org; Mon, 02 Sep 2024 13:32:56 +0000 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [2a00:1450:4864:20::535]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id dbe618a8-692f-11ef-99a1-01e77a169b0f; Mon, 02 Sep 2024 15:32:54 +0200 (CEST) Received: by mail-ed1-x535.google.com with SMTP id 4fb4d7f45d1cf-5c241feb80dso3930531a12.0 for ; Mon, 02 Sep 2024 06:32:54 -0700 (PDT) Received: from andrewcoop.eng.citrite.net ([185.25.67.249]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8989196975sm562333666b.135.2024.09.02.06.32.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Sep 2024 06:32:52 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: dbe618a8-692f-11ef-99a1-01e77a169b0f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1725283973; x=1725888773; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=aFl3TVf1HFUGf5X7Hzvme/0k6OhCaTh4d95heeg1LWs=; b=r1zOi23shx0w1DjBKvQm/20YvsRD0/MqDpWthKptYDoovB1lMAEA4/s13ptFAs6Cd1 kO2MZBc+UQtekHY9bXmMGo+l0UJc4BbUmDaJZ2iySH4BVF+kP8u/nhqo9btoSgo4W350 ImZkYoS7o3dDGeWdKej8RWHy/taBtg1wJHJMQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725283973; x=1725888773; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aFl3TVf1HFUGf5X7Hzvme/0k6OhCaTh4d95heeg1LWs=; b=qXuqmFTOhMXJ51Y9xAVF46I51z4oC1dtSnwFSs+FpqCo0P0Quzv7bueOTBe8t8vqgL c0J/Jh5bMlEb1xbwEeHQjFhSCEEGdO6Od8po3QE9IXUKmaa1tRHErcvRTf+nB2G9FM8Z YXAGTqEoAt8TwH9X6+KwoSmP6ajbl3hUtg1WlY9OdY9ZAeAQxBw65FcJ3QgHMf0Gr2BL mZF/AwnYi95F6GfE0BVkDejVQiELh+kgReaoxOsZTG0K7vLkCQ5iL0h9wS/eJK58dXno 4J7vX1wQaQ56O5srftzcEXYL3m+7pSooJkJbybLBlSRPNpLHP8vf9XaNcoJmOotWA9Pj vx6A== X-Gm-Message-State: AOJu0Yxeb6uZRtj1NQt41J7D0TYVHe5GizXHYnDprzSnZ5jg1qD/xfig uAAF52DKrdUQ2bn7T/u/Aew3nxflG0vE8OuL3kQqs9xvZ1f9wyGjwoCkSLlfCaYCy25OyaagIXf p X-Google-Smtp-Source: AGHT+IHfpkYzaJzrhNVmY/WHkSEWAtrtKnBlyANpKf08/odYzlNkMz+SUEQ2t9VNTdzNSpgDDzZwbw== X-Received: by 2002:a17:907:2d88:b0:a86:9e85:2619 with SMTP id a640c23a62f3a-a89827a3c54mr1495834066b.25.1725283972949; Mon, 02 Sep 2024 06:32:52 -0700 (PDT) From: Andrew Cooper To: Xen-devel Cc: Andrew Cooper , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Frediano Ziglio Subject: [PATCH 3/4] x86/boot: Use Date: Mon, 2 Sep 2024 14:32:31 +0100 Message-Id: <20240902133232.3302839-4-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240902133232.3302839-1-andrew.cooper3@citrix.com> References: <20240902133232.3302839-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 ... rather than opencoding locally. __stdcall is x86-only and not something we want to introduce to Xen generically, so opencode it in the two positions where it matters. With this, defs.h is empty so delete it. No functional change. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: Jan Beulich CC: Roger Pau Monné CC: Frediano Ziglio I was hoping to do away with stdcall entirely and use fastcall instead, but I've clearly got something wrong and the result doesn't boot. --- xen/arch/x86/boot/cmdline.c | 5 +++-- xen/arch/x86/boot/defs.h | 27 --------------------------- xen/arch/x86/boot/reloc.c | 7 +++---- 3 files changed, 6 insertions(+), 33 deletions(-) delete mode 100644 xen/arch/x86/boot/defs.h diff --git a/xen/arch/x86/boot/cmdline.c b/xen/arch/x86/boot/cmdline.c index b7375d106678..bdd5b95c224b 100644 --- a/xen/arch/x86/boot/cmdline.c +++ b/xen/arch/x86/boot/cmdline.c @@ -30,11 +30,11 @@ asm ( " jmp cmdline_parse_early \n" ); +#include #include #include #include -#include "defs.h" #include "video.h" /* Keep in sync with trampoline.S:early_boot_opts label! */ @@ -347,7 +347,8 @@ static void vga_parse(const char *cmdline, early_boot_opts_t *ebo) #endif /* SAF-1-safe */ -void __stdcall cmdline_parse_early(const char *cmdline, early_boot_opts_t *ebo) +void __attribute__((__stdcall__)) +cmdline_parse_early(const char *cmdline, early_boot_opts_t *ebo) { if ( !cmdline ) return; diff --git a/xen/arch/x86/boot/defs.h b/xen/arch/x86/boot/defs.h deleted file mode 100644 index 4d519ac4f5ea..000000000000 --- a/xen/arch/x86/boot/defs.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved. - * - * This program 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 2 of the License, or - * (at your option) any later version. - * - * This program 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 this program. If not, see . - * - * max() was copied from xen/xen/include/xen/kernel.h. - */ - -#ifndef __BOOT_DEFS_H__ -#define __BOOT_DEFS_H__ - -#define __maybe_unused __attribute__((__unused__)) -#define __packed __attribute__((__packed__)) -#define __stdcall __attribute__((__stdcall__)) - -#endif /* __BOOT_DEFS_H__ */ diff --git a/xen/arch/x86/boot/reloc.c b/xen/arch/x86/boot/reloc.c index eb9902d73fd9..1e3a30fab0c6 100644 --- a/xen/arch/x86/boot/reloc.c +++ b/xen/arch/x86/boot/reloc.c @@ -26,11 +26,10 @@ asm ( " jmp reloc \n" ); +#include #include #include -#include "defs.h" - #include #include #include @@ -354,8 +353,8 @@ static multiboot_info_t *mbi2_reloc(uint32_t mbi_in, uint32_t video_out) } /* SAF-1-safe */ -void *__stdcall reloc(uint32_t magic, uint32_t in, uint32_t trampoline, - uint32_t video_info) +void *__attribute__((__stdcall__)) +reloc(uint32_t magic, uint32_t in, uint32_t trampoline, uint32_t video_info) { alloc = trampoline; From patchwork Mon Sep 2 13:32:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 13787301 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A3518CA0ED3 for ; Mon, 2 Sep 2024 13:33:09 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.787952.1197434 (Exim 4.92) (envelope-from ) id 1sl7Aw-0001ck-Mz; Mon, 02 Sep 2024 13:32:58 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 787952.1197434; Mon, 02 Sep 2024 13:32:58 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sl7Aw-0001ak-Fi; Mon, 02 Sep 2024 13:32:58 +0000 Received: by outflank-mailman (input) for mailman id 787952; Mon, 02 Sep 2024 13:32:56 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sl7Au-0000uL-RV for xen-devel@lists.xenproject.org; Mon, 02 Sep 2024 13:32:56 +0000 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [2a00:1450:4864:20::636]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id dc33a439-692f-11ef-99a1-01e77a169b0f; Mon, 02 Sep 2024 15:32:55 +0200 (CEST) Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-a868b8bb0feso514405766b.0 for ; Mon, 02 Sep 2024 06:32:55 -0700 (PDT) Received: from andrewcoop.eng.citrite.net ([185.25.67.249]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8989196975sm562333666b.135.2024.09.02.06.32.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Sep 2024 06:32:53 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: dc33a439-692f-11ef-99a1-01e77a169b0f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1725283974; x=1725888774; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HVSfpr2fa6TJfrTtjhxFl5r7Fd98sI0EkF9Wzth3+h0=; b=b5ilD2r6tCOeVJnHhw32XSZ1az1Zdk6Tn/TUcZcR6T2LWBjAt5B5QfEudvJgct2fVw PbD5NLfJNXE1fcNLfpYJzKBNoha3prTqLQibUhy2i0747QofegylK0OTNyCsHKYZUahE MuwkFD2Pe+9LDpOOCq/b+qIyBlnvChYVUkc/w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725283974; x=1725888774; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HVSfpr2fa6TJfrTtjhxFl5r7Fd98sI0EkF9Wzth3+h0=; b=wJcnew18aCYQVxAByncqpZOQb3ppm17CE66VIp/YN0wivHPOJY+E05DDlk200qqutp jqPPqKYDGqrhFaBVP2qOt6I39EmBxM2qJV70ZEISr/rRuGmFyHTCwZ/JJpyXEw4leEW2 NqMREIj09Ki6uzX1oCFAFIz8/bGMsL1Qt0Gxbg2b5ufStiqyYFEusNhR/Q5ai+Q+1Ull 8NpcTAE8tph7JKy0SRnHVz7V0/XTg8iRpbLo+vrZnNtVGJAyAeUA7jQjnfINDQW4co0C ZhbkAYVBlq81hccyo2W7U16yjtKRuskfiUmAJRxJhdgZCCJvvxJK2j6fFt1+J7TqABef zdHQ== X-Gm-Message-State: AOJu0YyOC7aJ6Kl8B2t+jbgQDHgjpQ9m8FsHR772PzluB0xbI2DYgKno wCWOIriPw8NOFW2jrydNIqKPb0ZvMMq2WuQt5wZO5HUZ2Mkm0p6IXRcBnOwzwS9hXBbmqZxWQN/ v X-Google-Smtp-Source: AGHT+IF8I+a5pKvl+y6zQSzuoQKoJt6tDqoETst5kvCX0Rcy+oWXb32xqp32QR6ulU2uwfWAgw8vTg== X-Received: by 2002:a17:907:980c:b0:a86:8f57:7de0 with SMTP id a640c23a62f3a-a89a37aa9famr721201366b.49.1725283973599; Mon, 02 Sep 2024 06:32:53 -0700 (PDT) From: Andrew Cooper To: Xen-devel Cc: Andrew Cooper , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Frediano Ziglio Subject: [PATCH 4/4] x86/boot: Use fastcall for 32bit code Date: Mon, 2 Sep 2024 14:32:32 +0100 Message-Id: <20240902133232.3302839-5-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240902133232.3302839-1-andrew.cooper3@citrix.com> References: <20240902133232.3302839-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Signed-off-by: Andrew Cooper --- CC: Jan Beulich CC: Roger Pau Monné CC: Frediano Ziglio RFC. This doesn't boot, but I haven't quite figured out where yet. --- xen/arch/x86/boot/Makefile | 2 +- xen/arch/x86/boot/cmdline.c | 7 +++---- xen/arch/x86/boot/head.S | 15 +++++++++------ xen/arch/x86/boot/reloc.c | 12 ++++++------ 4 files changed, 19 insertions(+), 17 deletions(-) diff --git a/xen/arch/x86/boot/Makefile b/xen/arch/x86/boot/Makefile index 03d8ce3a9e48..b327663fba94 100644 --- a/xen/arch/x86/boot/Makefile +++ b/xen/arch/x86/boot/Makefile @@ -13,7 +13,7 @@ $(obj)/head.o: $(head-bin-objs:.o=.bin) CFLAGS_x86_32 := $(subst -m64,-m32 -march=i686,$(XEN_TREEWIDE_CFLAGS)) $(call cc-options-add,CFLAGS_x86_32,CC,$(EMBEDDED_EXTRA_CFLAGS)) -CFLAGS_x86_32 += -Werror -fno-builtin -g0 -msoft-float +CFLAGS_x86_32 += -Werror -fno-builtin -g0 -msoft-float -mregparm=3 ifneq ($(abs_objtree),$(abs_srctree)) CFLAGS_x86_32 += -I$(objtree)/include endif diff --git a/xen/arch/x86/boot/cmdline.c b/xen/arch/x86/boot/cmdline.c index bdd5b95c224b..6eddbb37b5b9 100644 --- a/xen/arch/x86/boot/cmdline.c +++ b/xen/arch/x86/boot/cmdline.c @@ -20,8 +20,8 @@ /* * This entry point is entered from xen/arch/x86/boot/head.S with: - * - 0x4(%esp) = &cmdline, - * - 0x8(%esp) = &early_boot_opts. + * - %eax = &cmdline, + * - %ecx = &early_boot_opts. */ asm ( " .text \n" @@ -347,8 +347,7 @@ static void vga_parse(const char *cmdline, early_boot_opts_t *ebo) #endif /* SAF-1-safe */ -void __attribute__((__stdcall__)) -cmdline_parse_early(const char *cmdline, early_boot_opts_t *ebo) +void cmdline_parse_early(const char *cmdline, early_boot_opts_t *ebo) { if ( !cmdline ) return; diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S index d867b015d961..b745a7cd3a26 100644 --- a/xen/arch/x86/boot/head.S +++ b/xen/arch/x86/boot/head.S @@ -613,10 +613,13 @@ trampoline_setup: /* Save Multiboot / PVH info struct (after relocation) for later use. */ push %edx /* Boot video info to be filled from MB2. */ - push %ecx /* Bottom-most low-memory stack address. */ - push %ebx /* Multiboot / PVH information address. */ - push %eax /* Magic number. */ + mov %ecx, %edx /* Bottom-most low-memory stack address. */ + mov %ebx, %ecx /* Multiboot / PVH information address. */ + /* Magic number. */ + /* reloc(magic, info, trampoline, video) using fastcall(a, c, d, stk). */ call reloc + add $4, %esp + #ifdef CONFIG_PVH_GUEST cmpb $0, sym_esi(pvh_boot) je 1f @@ -848,9 +851,9 @@ trampoline_setup: testl $MBI_CMDLINE,MB_flags(%ebx) jz 1f - lea sym_esi(early_boot_opts),%eax - push %eax - pushl MB_cmdline(%ebx) + lea sym_esi(early_boot_opts), %ecx + lea MB_cmdline(%ebx), %eax + /* cmdline_parse_early(cmdline, opts) using fastcall(a, c). */ call cmdline_parse_early 1: diff --git a/xen/arch/x86/boot/reloc.c b/xen/arch/x86/boot/reloc.c index 1e3a30fab0c6..32acded81d78 100644 --- a/xen/arch/x86/boot/reloc.c +++ b/xen/arch/x86/boot/reloc.c @@ -14,10 +14,10 @@ /* * This entry point is entered from xen/arch/x86/boot/head.S with: - * - 0x04(%esp) = MAGIC, - * - 0x08(%esp) = INFORMATION_ADDRESS, - * - 0x0c(%esp) = TOPMOST_LOW_MEMORY_STACK_ADDRESS. - * - 0x10(%esp) = BOOT_VIDEO_INFO_ADDRESS. + * - %eax = MAGIC, + * - %ecx = INFORMATION_ADDRESS, + * - %edx = TOPMOST_LOW_MEMORY_STACK_ADDRESS. + * - 0x04(%esp) = BOOT_VIDEO_INFO_ADDRESS. */ asm ( " .text \n" @@ -353,8 +353,8 @@ static multiboot_info_t *mbi2_reloc(uint32_t mbi_in, uint32_t video_out) } /* SAF-1-safe */ -void *__attribute__((__stdcall__)) -reloc(uint32_t magic, uint32_t in, uint32_t trampoline, uint32_t video_info) +void *reloc(uint32_t magic, uint32_t in, uint32_t trampoline, + uint32_t video_info) { alloc = trampoline;