Skip to content

Commit

Permalink
{emulators,sysutils}/xen-{kernel,tools}: update to 4.17
Browse files Browse the repository at this point in the history
While there also update SeaBIOS to 1.16.1.

Sponsored by: Citrix Systems R&D
Approved by: bapt (implicit)
  • Loading branch information
Roger Pau Monné authored and Roger Pau Monné committed Mar 9, 2023
1 parent 48ad0a5 commit 3688ce5
Show file tree
Hide file tree
Showing 20 changed files with 675 additions and 485 deletions.
22 changes: 10 additions & 12 deletions emulators/xen-kernel/Makefile
@@ -1,5 +1,5 @@
PORTNAME= xen
PORTVERSION= 4.16.0
PORTVERSION= 4.17.0
PORTREVISION= 0
CATEGORIES= emulators
MASTER_SITES= http://downloads.xenproject.org/release/xen/${PORTVERSION}/
Expand All @@ -26,17 +26,15 @@ PLIST_FILES= /boot/xen \
lib/debug/boot/xen.debug \
lib/debug/boot/xen-debug.debug

# XSA-395
EXTRA_PATCHES+= ${PATCHDIR}/xsa395.patch:-p1

# XSA-398
EXTRA_PATCHES+= ${PATCHDIR}/0001-x86-spec-ctrl-Drop-use_spec_ctrl-boolean.patch:-p1 \
${PATCHDIR}/0002-x86-spec-ctrl-Introduce-new-has_spec_ctrl-boolean.patch:-p1 \
${PATCHDIR}/xsa398-4.16-6-x86-spec-ctrl-Cease-using-thunk-lfence-on-AMD.patch:-p1

# Add retpoline support for clang builds
EXTRA_PATCHES+= ${PATCHDIR}/0001-x86-retpoline-split-retpoline-compiler-support-into-.patch:-p1 \
${PATCHDIR}/0002-x86-clang-add-retpoline-support.patch:-p1
# XSAs
EXTRA_PATCHES+= ${PATCHDIR}/xsa425.patch:-p1 \
${PATCHDIR}/xsa426.patch:-p1 \
${PATCHDIR}/0001-xen-Work-around-Clang-IAS-macro-expansion-bug.patch:-p1
# Backports
# clang build fixes
EXTRA_PATCHES+= ${PATCHDIR}/0001-xen-x86-Remove-the-use-of-K-R-functions.patch:-p1
# Support for fetching video mode from PVH dom0
EXTRA_PATCHES+= ${PATCHDIR}/0001-x86-platform-introduce-hypercall-to-get-initial-vide.patch:-p1

.include <bsd.port.options.mk>

Expand Down
6 changes: 3 additions & 3 deletions emulators/xen-kernel/distinfo
@@ -1,3 +1,3 @@
TIMESTAMP = 1648563575
SHA256 (xen-4.16.0.tar.gz) = adc87a90e614d090a2014b9aebae8d815a7348bf329d169b3cb655256d0ee995
SIZE (xen-4.16.0.tar.gz) = 44982322
TIMESTAMP = 1678353105
SHA256 (xen-4.17.0.tar.gz) = 119fc44fa3f9b581f1929c2ed8e0f97fac59a1828bc5ec5c244df096e7343ef9
SIZE (xen-4.17.0.tar.gz) = 46484553
@@ -0,0 +1,84 @@
From 4dd160583c798d3a5a451ea74633836891d15354 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= <roger.pau@citrix.com>
Date: Tue, 6 Dec 2022 13:53:43 +0100
Subject: [PATCH] x86/platform: introduce hypercall to get initial video
console settings
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This is required so PVH dom0 can get the initial video console state
as handled by Xen. PV dom0 will get this as part of the start_info,
but it doesn't seem necessary to place such information in the
HVM start info.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
xen/arch/x86/platform_hypercall.c | 11 +++++++++++
xen/drivers/video/vga.c | 2 +-
xen/include/public/platform.h | 6 ++++++
3 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/platform_hypercall.c b/xen/arch/x86/platform_hypercall.c
index a7341dc3d7..3f0d0389af 100644
--- a/xen/arch/x86/platform_hypercall.c
+++ b/xen/arch/x86/platform_hypercall.c
@@ -839,6 +839,17 @@ ret_t do_platform_op(
}
break;

+ case XENPF_get_dom0_console:
+ if ( !fill_console_start_info(&op->u.dom0_console) )
+ {
+ ret = -ENODEV;
+ break;
+ }
+
+ if ( copy_field_to_guest(u_xenpf_op, op, u.dom0_console) )
+ ret = -EFAULT;
+ break;
+
default:
ret = -ENOSYS;
break;
diff --git a/xen/drivers/video/vga.c b/xen/drivers/video/vga.c
index 29a88e8241..0a03508bee 100644
--- a/xen/drivers/video/vga.c
+++ b/xen/drivers/video/vga.c
@@ -205,7 +205,7 @@ static void cf_check vga_text_puts(const char *s, size_t nr)
}
}

-int __init fill_console_start_info(struct dom0_vga_console_info *ci)
+int fill_console_start_info(struct dom0_vga_console_info *ci)
{
memcpy(ci, &vga_console_info, sizeof(*ci));
return 1;
diff --git a/xen/include/public/platform.h b/xen/include/public/platform.h
index 5e1494fe9a..14784dfa77 100644
--- a/xen/include/public/platform.h
+++ b/xen/include/public/platform.h
@@ -605,6 +605,11 @@ struct xenpf_symdata {
typedef struct xenpf_symdata xenpf_symdata_t;
DEFINE_XEN_GUEST_HANDLE(xenpf_symdata_t);

+/* Fetch the video console information and mode setup by Xen. */
+#define XENPF_get_dom0_console 64
+typedef struct dom0_vga_console_info xenpf_dom0_console_t;
+DEFINE_XEN_GUEST_HANDLE(xenpf_dom0_console_t);
+
/*
* ` enum neg_errnoval
* ` HYPERVISOR_platform_op(const struct xen_platform_op*);
@@ -635,6 +640,7 @@ struct xen_platform_op {
xenpf_core_parking_t core_parking;
xenpf_resource_op_t resource_op;
xenpf_symdata_t symdata;
+ xenpf_dom0_console_t dom0_console;
uint8_t pad[128];
} u;
};
--
2.39.0

This file was deleted.

This file was deleted.

@@ -0,0 +1,107 @@
From a2adacff0b91cc7b977abb209dc419a2ef15963f Mon Sep 17 00:00:00 2001
From: Andrew Cooper <andrew.cooper3@citrix.com>
Date: Fri, 17 Feb 2023 00:12:24 +0000
Subject: [PATCH] xen: Work around Clang-IAS macro \@ expansion bug

https://github.com/llvm/llvm-project/issues/60792

It turns out that Clang-IAS does not expand \@ uniquely in a translaition
unit, and the XSA-426 change tickles this bug:

<instantiation>:4:1: error: invalid symbol redefinition
.L1_fill_rsb_loop:
^
make[3]: *** [Rules.mk:247: arch/x86/acpi/cpu_idle.o] Error 1

Extend DO_OVERWRITE_RSB with an optional parameter so C callers can mix %= in
too, which Clang does seem to expand properly.

Fixes: 63305e5392ec ("x86/spec-ctrl: Mitigate Cross-Thread Return Address Predictions")
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
xen/arch/x86/include/asm/spec_ctrl.h | 4 ++--
xen/arch/x86/include/asm/spec_ctrl_asm.h | 19 ++++++++++++-------
2 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/xen/arch/x86/include/asm/spec_ctrl.h b/xen/arch/x86/include/asm/spec_ctrl.h
index 3cf8a7d304..f718f94088 100644
--- a/xen/arch/x86/include/asm/spec_ctrl.h
+++ b/xen/arch/x86/include/asm/spec_ctrl.h
@@ -83,7 +83,7 @@ static always_inline void spec_ctrl_new_guest_context(void)
wrmsrl(MSR_PRED_CMD, PRED_CMD_IBPB);

/* (ab)use alternative_input() to specify clobbers. */
- alternative_input("", "DO_OVERWRITE_RSB", X86_BUG_IBPB_NO_RET,
+ alternative_input("", "DO_OVERWRITE_RSB xu=%=", X86_BUG_IBPB_NO_RET,
: "rax", "rcx");
}

@@ -172,7 +172,7 @@ static always_inline void spec_ctrl_enter_idle(struct cpu_info *info)
*
* (ab)use alternative_input() to specify clobbers.
*/
- alternative_input("", "DO_OVERWRITE_RSB", X86_FEATURE_SC_RSB_IDLE,
+ alternative_input("", "DO_OVERWRITE_RSB xu=%=", X86_FEATURE_SC_RSB_IDLE,
: "rax", "rcx");
}

diff --git a/xen/arch/x86/include/asm/spec_ctrl_asm.h b/xen/arch/x86/include/asm/spec_ctrl_asm.h
index fab27ff553..f23bb105c5 100644
--- a/xen/arch/x86/include/asm/spec_ctrl_asm.h
+++ b/xen/arch/x86/include/asm/spec_ctrl_asm.h
@@ -117,11 +117,16 @@
.L\@_done:
.endm

-.macro DO_OVERWRITE_RSB tmp=rax
+.macro DO_OVERWRITE_RSB tmp=rax xu
/*
* Requires nothing
* Clobbers \tmp (%rax by default), %rcx
*
+ * xu is an optional parameter to add eXtra Uniqueness. It is intended for
+ * passing %= in from an asm() block, in order to work around
+ * https://github.com/llvm/llvm-project/issues/60792 where Clang-IAS doesn't
+ * expand \@ uniquely.
+ *
* Requires 256 bytes of {,shadow}stack space, but %rsp/SSP has no net
* change. Based on Google's performance numbers, the loop is unrolled to 16
* iterations and two calls per iteration.
@@ -136,27 +141,27 @@
mov $16, %ecx /* 16 iterations, two calls per loop */
mov %rsp, %\tmp /* Store the current %rsp */

-.L\@_fill_rsb_loop:
+.L\@_fill_rsb_loop\xu:

.irp n, 1, 2 /* Unrolled twice. */
- call .L\@_insert_rsb_entry_\n /* Create an RSB entry. */
+ call .L\@_insert_rsb_entry\xu\n /* Create an RSB entry. */
int3 /* Halt rogue speculation. */

-.L\@_insert_rsb_entry_\n:
+.L\@_insert_rsb_entry\xu\n:
.endr

sub $1, %ecx
- jnz .L\@_fill_rsb_loop
+ jnz .L\@_fill_rsb_loop\xu
mov %\tmp, %rsp /* Restore old %rsp */

#ifdef CONFIG_XEN_SHSTK
mov $1, %ecx
rdsspd %ecx
cmp $1, %ecx
- je .L\@_shstk_done
+ je .L\@_shstk_done\xu
mov $64, %ecx /* 64 * 4 bytes, given incsspd */
incsspd %ecx /* Restore old SSP */
-.L\@_shstk_done:
+.L\@_shstk_done\xu:
#endif
.endm

--
2.39.0

0 comments on commit 3688ce5

Please sign in to comment.