Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions .github/workflows/build-aarch64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,12 @@ jobs:
if: github.event_name == 'pull_request'
name: Build aarch64 kernel
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- stable
target:
- aarch64-unknown-linux-gnu
steps:
- name: Code checkout
uses: actions/checkout@v2

- name: Install dependencies
run: sudo apt-get install -y make gcc bc bison flex elfutils python3-pyelftools curl patch libelf-dev
run: sudo apt-get install -y make gcc bc bison flex elfutils python3-pyelftools curl patch libelf-dev gcc-aarch64-linux-gnu

- name: Build aarch64 kernel
run: make
run: make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
32 changes: 22 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
KERNEL_VERSION = linux-6.6.44
KERNEL_VERSION = linux-6.6.52
KERNEL_REMOTE = https://cdn.kernel.org/pub/linux/kernel/v6.x/$(KERNEL_VERSION).tar.xz
KERNEL_TARBALL = tarballs/$(KERNEL_VERSION).tar.xz
KERNEL_SOURCES = $(KERNEL_VERSION)
KERNEL_PATCHES = $(shell find patches/ -name "0*.patch" | sort)
KERNEL_C_BUNDLE = kernel.c

ABI_VERSION = 4
FULL_VERSION = 4.3.1
TIMESTAMP = "Sat Sep 7 00:58:59 CEST 2024"
FULL_VERSION = 4.4.0
TIMESTAMP = "Wed Sep 25 18:24:59 CEST 2024"

KERNEL_FLAGS = KBUILD_BUILD_TIMESTAMP=$(TIMESTAMP)
KERNEL_FLAGS += KBUILD_BUILD_USER=root
Expand All @@ -18,8 +18,20 @@ ifeq ($(SEV),1)
KERNEL_PATCHES += $(shell find patches-sev/ -name "0*.patch" | sort)
endif

ARCH = $(shell uname -m)
HOSTARCH = $(shell uname -m)
OS = $(shell uname -s)
ifeq ($(ARCH),)
GUESTARCH := $(HOSTARCH)
STRIP := strip
else ifeq ($(ARCH),arm64)
GUESTARCH := aarch64
CC := $(CROSS_COMPILE)gcc
STRIP := $(CROSS_COMPILE)strip
else
GUESTARCH := $(ARCH)
CC := $(CROSS_COMPILE)gcc
STRIP := $(CROSS_COMPILE)strip
endif

KBUNDLE_TYPE_x86_64 = vmlinux
KBUNDLE_TYPE_aarch64 = Image
Expand Down Expand Up @@ -62,20 +74,20 @@ $(KERNEL_TARBALL):
$(KERNEL_SOURCES): $(KERNEL_TARBALL)
tar xf $(KERNEL_TARBALL)
for patch in $(KERNEL_PATCHES); do patch -p1 -d $(KERNEL_SOURCES) < "$$patch"; done
cp config-libkrunfw$(VARIANT)_$(ARCH) $(KERNEL_SOURCES)/.config
cp config-libkrunfw$(VARIANT)_$(GUESTARCH) $(KERNEL_SOURCES)/.config
cd $(KERNEL_SOURCES) ; $(MAKE) olddefconfig

$(KERNEL_BINARY_$(ARCH)): $(KERNEL_SOURCES)
$(KERNEL_BINARY_$(GUESTARCH)): $(KERNEL_SOURCES)
cd $(KERNEL_SOURCES) ; rm -f .version ; $(MAKE) $(MAKEFLAGS) $(KERNEL_FLAGS)

ifeq ($(OS),Darwin)
$(KERNEL_C_BUNDLE):
@echo "Building on macOS, using ./build_on_krunvm.sh"
./build_on_krunvm.sh
else
$(KERNEL_C_BUNDLE): $(KERNEL_BINARY_$(ARCH))
@echo "Generating $(KERNEL_C_BUNDLE) from $(KERNEL_BINARY_$(ARCH))..."
@python3 bin2cbundle.py -t $(KBUNDLE_TYPE_$(ARCH)) $(KERNEL_BINARY_$(ARCH)) kernel.c
$(KERNEL_C_BUNDLE): $(KERNEL_BINARY_$(GUESTARCH))
@echo "Generating $(KERNEL_C_BUNDLE) from $(KERNEL_BINARY_$(GUESTARCH))..."
@python3 bin2cbundle.py -t $(KBUNDLE_TYPE_$(GUESTARCH)) $(KERNEL_BINARY_$(GUESTARCH)) kernel.c
endif

ifeq ($(SEV),1)
Expand All @@ -91,7 +103,7 @@ endif
$(KRUNFW_BINARY_$(OS)): $(KERNEL_C_BUNDLE) $(QBOOT_C_BUNDLE) $(INITRD_C_BUNDLE)
$(CC) -fPIC -DABI_VERSION=$(ABI_VERSION) -shared $(SONAME_$(OS)) -o $@ $(KERNEL_C_BUNDLE) $(QBOOT_C_BUNDLE) $(INITRD_C_BUNDLE)
ifeq ($(OS),Linux)
strip $(KRUNFW_BINARY_$(OS))
$(STRIP) $(KRUNFW_BINARY_$(OS))
endif

install:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From aa2644a251efee27236a017487fc30f82227cb1e Mon Sep 17 00:00:00 2001
From 6616593252269d81b003d7aa1e7e4dd156d1a629 Mon Sep 17 00:00:00 2001
From: Sergio Lopez <slp@sinrega.org>
Date: Fri, 10 Sep 2021 13:05:01 +0200
Subject: [PATCH 12/15] virtio: enable DMA API if memory is restricted
Subject: [PATCH 1/4] virtio: enable DMA API if memory is restricted

When running on a system with restricted memory access, the driver
can't have direct access to the memory. In this scenario,
Expand Down Expand Up @@ -32,7 +32,7 @@ index 71dee622b771..f92475dbca43 100644

if (!virtio_has_feature(dev, VIRTIO_F_VERSION_1))
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index 6f7e5010a673..d40dbac45284 100644
index 80669e05bf0e..438b4f6c5cdb 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -6,6 +6,7 @@
Expand All @@ -54,5 +54,5 @@ index 6f7e5010a673..d40dbac45284 100644
/*
* In theory, it's possible to have a buggy QEMU-supposed
--
2.45.2
2.46.0

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From ba40cb466eac33c12dc2d285f7af8f45e0cfbfd7 Mon Sep 17 00:00:00 2001
From ecbb6d5db802293ef27575a672336e17e8c2abfd Mon Sep 17 00:00:00 2001
From: Sergio Lopez <slp@redhat.com>
Date: Thu, 20 Oct 2022 10:23:16 +0200
Subject: [PATCH 13/15] x86/sev: write AP reset vector
Subject: [PATCH 2/4] x86/sev: write AP reset vector

If a jump table can't be found, write the SEV-ES trampoline location
into the AP reset vector used by libkrun's qboot.
Expand Down Expand Up @@ -55,5 +55,5 @@ index 9905dc0e0b09..38df85fd1324 100644
/* Check if AP Jump Table is page-aligned */
if (jump_table_addr & ~PAGE_MASK)
--
2.45.2
2.46.0

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 49e3dd72da01fff91a85f4d4bc0e705dbde9ae67 Mon Sep 17 00:00:00 2001
From 0738c09d916b06afa162facb0edc84ffe121c35a Mon Sep 17 00:00:00 2001
From: Sergio Lopez <slp@redhat.com>
Date: Wed, 3 Aug 2022 12:35:12 +0200
Subject: [PATCH 14/15] Implement driver to retrieve secrets from cmdline
Subject: [PATCH 3/4] Implement driver to retrieve secrets from cmdline

When CMDLINE_OVERRIDE is enabled, the contents originally present in
the location passed on the cmdline pointer of the zero page are
Expand Down Expand Up @@ -292,5 +292,5 @@ index c787e94cc898..2fb8a8af9af6 100644

/*
--
2.45.2
2.46.0

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 3fcf7bfe438218d884d8aa36159bcf6ec37e23eb Mon Sep 17 00:00:00 2001
From 95ae01ac9240b47dcdeda540e59a24ba0bdaf963 Mon Sep 17 00:00:00 2001
From: Sergio Lopez <slp@redhat.com>
Date: Wed, 5 Jun 2024 16:20:08 +0200
Subject: [PATCH 15/15] x86/sev: Avoid using native_cpuid
Subject: [PATCH 4/4] x86/sev: Avoid using native_cpuid

In the state we get into the kernel from qboot-krunfw we can't return
from #VC properly, so avoid calling native_cpuid in the early stages
Expand Down Expand Up @@ -61,5 +61,5 @@ index cc47a818a640..a2b5b08eee23 100644
/* Check the SEV MSR whether SEV or SME is enabled */
RIP_REL_REF(sev_status) = msr = __rdmsr(MSR_AMD64_SEV);
--
2.45.2
2.46.0

6 changes: 3 additions & 3 deletions patches/0001-krunfw-Don-t-panic-when-init-dies.patch
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 2b01861f2623f4434d90e484448e8c9e45c1242c Mon Sep 17 00:00:00 2001
From 7f18f75689b7b0f34ca711daa4e29e2d4ae5f910 Mon Sep 17 00:00:00 2001
From: Sergio Lopez <slp@redhat.com>
Date: Thu, 2 Mar 2023 07:34:49 +0100
Subject: [PATCH 01/15] krunfw: Don't panic when init dies
Subject: [PATCH 01/17] krunfw: Don't panic when init dies

In libkrun, the isolated process runs as PID 1. When it exits,
trigger an orderly reboot instead of panic'ing.
Expand Down Expand Up @@ -58,5 +58,5 @@ index 6ebef11c8876..4323caa5b871 100644
machine_restart(cmd);
}
--
2.45.2
2.46.0

6 changes: 3 additions & 3 deletions patches/0002-krunfw-Ignore-run_cmd-on-orderly-reboot.patch
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 887e1f887d0c04fe8ccf511a9521c38e2a817a2d Mon Sep 17 00:00:00 2001
From 5ed6edb3e75df34958f788bca363748cea75eea1 Mon Sep 17 00:00:00 2001
From: Sergio Lopez <slp@redhat.com>
Date: Mon, 16 May 2022 16:04:27 +0200
Subject: [PATCH 02/15] krunfw: Ignore run_cmd on orderly reboot
Subject: [PATCH 02/17] krunfw: Ignore run_cmd on orderly reboot

We don't really support restarting the conventional way, so ignore
"run_cmd" so we can fall back to an emergency sync and reboot.
Expand All @@ -28,5 +28,5 @@ index 4323caa5b871..d9d6f0dd2ebc 100644
if (ret) {
pr_warn("Failed to start orderly reboot: forcing the issue\n");
--
2.45.2
2.46.0

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 0334eb653db47ada29d2e523b2e7651dee2fb4e2 Mon Sep 17 00:00:00 2001
From 06a9c813b4f59d92edf78a6011a719629323081c Mon Sep 17 00:00:00 2001
From: Bobby Eshleman <bobby.eshleman () bytedance ! com>
Date: Sat, 10 Jun 2023 00:58:28 +0000
Subject: [PATCH 03/15] vsock/dgram: generalize recvmsg and drop
Subject: [PATCH 03/17] vsock/dgram: generalize recvmsg and drop
transport->dgram_dequeue

This commit drops the transport->dgram_dequeue callback and makes
Expand All @@ -14,13 +14,13 @@ Signed-off-by: Bobby Eshleman <bobby.eshleman@bytedance.com>
drivers/vhost/vsock.c | 4 +-
include/linux/virtio_vsock.h | 3 ++
include/net/af_vsock.h | 13 ++++-
net/vmw_vsock/af_vsock.c | 51 ++++++++++++++++++-
net/vmw_vsock/af_vsock.c | 58 +++++++++++++++++++--
net/vmw_vsock/hyperv_transport.c | 17 +++++--
net/vmw_vsock/virtio_transport.c | 4 +-
net/vmw_vsock/virtio_transport_common.c | 18 +++++++
net/vmw_vsock/vmci_transport.c | 68 ++++++++++---------------
net/vmw_vsock/vsock_loopback.c | 4 +-
9 files changed, 132 insertions(+), 50 deletions(-)
9 files changed, 137 insertions(+), 52 deletions(-)

diff --git a/drivers/vhost/vsock.c b/drivers/vhost/vsock.c
index d94a06008ff6..549158375086 100644
Expand Down Expand Up @@ -54,7 +54,7 @@ index fbf30721bac9..1098a4c0d738 100644
int virtio_transport_connect(struct vsock_sock *vsk);

diff --git a/include/net/af_vsock.h b/include/net/af_vsock.h
index dc3cb16835b6..3fee8b8bb3e0 100644
index f8b09a82f62e..7a342d406c34 100644
--- a/include/net/af_vsock.h
+++ b/include/net/af_vsock.h
@@ -120,11 +120,20 @@ struct vsock_transport {
Expand All @@ -81,28 +81,24 @@ index dc3cb16835b6..3fee8b8bb3e0 100644
/* STREAM. */
/* TODO: stream_bind() */
diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
index 4afb6a541cf3..c66d3def5e6e 100644
index f5eb737a677d..c3fdb22cfd39 100644
--- a/net/vmw_vsock/af_vsock.c
+++ b/net/vmw_vsock/af_vsock.c
@@ -1273,11 +1273,15 @@ static int vsock_dgram_connect(struct socket *sock,
int vsock_dgram_recvmsg(struct socket *sock, struct msghdr *msg,
size_t len, int flags)
@@ -1273,10 +1273,62 @@ static int vsock_dgram_connect(struct socket *sock,
int __vsock_dgram_recvmsg(struct socket *sock, struct msghdr *msg,
size_t len, int flags)
{
- struct sock *sk = sock->sk;
- struct vsock_sock *vsk = vsock_sk(sk);
+ const struct vsock_transport *transport;
#ifdef CONFIG_BPF_SYSCALL
const struct proto *prot;
#endif
struct vsock_sock *vsk;
+ struct vsock_sock *vsk;
+ struct sk_buff *skb;
+ size_t payload_len;
struct sock *sk;
+ struct sock *sk;
+ int err;

sk = sock->sk;
vsk = vsock_sk(sk);
@@ -1288,7 +1292,52 @@ int vsock_dgram_recvmsg(struct socket *sock, struct msghdr *msg,
return prot->recvmsg(sk, msg, len, flags, NULL);
#endif
+
+ sk = sock->sk;
+ vsk = vsock_sk(sk);

- return vsk->transport->dgram_dequeue(vsk, msg, len, flags);
+ if (flags & MSG_OOB || flags & MSG_ERRQUEUE)
Expand Down Expand Up @@ -152,8 +148,8 @@ index 4afb6a541cf3..c66d3def5e6e 100644
+ skb_free_datagram(&vsk->sk, skb);
+ return err;
}
EXPORT_SYMBOL_GPL(vsock_dgram_recvmsg);

int vsock_dgram_recvmsg(struct socket *sock, struct msghdr *msg,
diff --git a/net/vmw_vsock/hyperv_transport.c b/net/vmw_vsock/hyperv_transport.c
index e2157e387217..a83b30d366af 100644
--- a/net/vmw_vsock/hyperv_transport.c
Expand Down Expand Up @@ -352,5 +348,5 @@ index 0ce65d0a4a44..6b19e308a140 100644
.stream_dequeue = virtio_transport_stream_dequeue,
.stream_enqueue = virtio_transport_stream_enqueue,
--
2.45.2
2.46.0

8 changes: 4 additions & 4 deletions patches/0004-vsock-refactor-transport-lookup-code.patch
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 5981f2c4b9ec44a6195d2ba892100e1cdbe80d24 Mon Sep 17 00:00:00 2001
From 5a2b5b9c1a9f473836c361153b15c10eab012e9a Mon Sep 17 00:00:00 2001
From: Bobby Eshleman <bobby.eshleman () bytedance ! com>
Date: Sat, 10 Jun 2023 00:58:29 +0000
Subject: [PATCH 04/15] vsock: refactor transport lookup code
Subject: [PATCH 04/17] vsock: refactor transport lookup code

Introduce new reusable function vsock_connectible_lookup_transport()
that performs the transport lookup logic.
Expand All @@ -14,7 +14,7 @@ Signed-off-by: Bobby Eshleman <bobby.eshleman@bytedance.com>
1 file changed, 18 insertions(+), 7 deletions(-)

diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
index c66d3def5e6e..813588bee10f 100644
index c3fdb22cfd39..5a517638deed 100644
--- a/net/vmw_vsock/af_vsock.c
+++ b/net/vmw_vsock/af_vsock.c
@@ -424,6 +424,22 @@ static void vsock_deassign_transport(struct vsock_sock *vsk)
Expand Down Expand Up @@ -57,5 +57,5 @@ index c66d3def5e6e..813588bee10f 100644
default:
return -ESOCKTNOSUPPORT;
--
2.45.2
2.46.0

8 changes: 4 additions & 4 deletions patches/0005-vsock-support-multi-transport-datagrams.patch
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 0eca7ac3da42ac518e6410fa91d754ee40371886 Mon Sep 17 00:00:00 2001
From 10b18bb2d94abcf35e199c76fcf9921de1dbb9ae Mon Sep 17 00:00:00 2001
From: Bobby Eshleman <bobby.eshleman () bytedance ! com>
Date: Sat, 10 Jun 2023 00:58:30 +0000
Subject: [PATCH 05/15] vsock: support multi-transport datagrams
Subject: [PATCH 05/17] vsock: support multi-transport datagrams

This patch adds support for multi-transport datagrams.

Expand Down Expand Up @@ -82,7 +82,7 @@ index 1098a4c0d738..26339021418d 100644
int virtio_transport_dgram_get_cid(struct sk_buff *skb, unsigned int *cid);
int virtio_transport_dgram_get_port(struct sk_buff *skb, unsigned int *port);
diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
index 813588bee10f..2567641a829f 100644
index 5a517638deed..afe28d3b0b74 100644
--- a/net/vmw_vsock/af_vsock.c
+++ b/net/vmw_vsock/af_vsock.c
@@ -440,6 +440,18 @@ vsock_connectible_lookup_transport(unsigned int cid, __u8 flags)
Expand Down Expand Up @@ -304,5 +304,5 @@ index 6b19e308a140..21a4debde550 100644
.dgram_allow = virtio_transport_dgram_allow,
.dgram_get_cid = virtio_transport_dgram_get_cid,
--
2.45.2
2.46.0

8 changes: 4 additions & 4 deletions patches/0006-vsock-make-vsock-bind-reusable.patch
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From a01abc12504a5819737fc8dcb6026eb2c52e67de Mon Sep 17 00:00:00 2001
From 9b076ce6da60de7904d340289a2187325efee512 Mon Sep 17 00:00:00 2001
From: Bobby Eshleman <bobby.eshleman () bytedance ! com>
Date: Sat, 10 Jun 2023 00:58:31 +0000
Subject: [PATCH 06/15] vsock: make vsock bind reusable
Subject: [PATCH 06/17] vsock: make vsock bind reusable

This commit makes the bind table management functions in vsock usable
for different bind tables. For use by datagrams in a future patch.
Expand All @@ -12,7 +12,7 @@ Signed-off-by: Bobby Eshleman <bobby.eshleman@bytedance.com>
1 file changed, 26 insertions(+), 7 deletions(-)

diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
index 2567641a829f..034c3db91fc3 100644
index afe28d3b0b74..6a94a623dd07 100644
--- a/net/vmw_vsock/af_vsock.c
+++ b/net/vmw_vsock/af_vsock.c
@@ -232,11 +232,12 @@ static void __vsock_remove_connected(struct vsock_sock *vsk)
Expand Down Expand Up @@ -102,5 +102,5 @@ index 2567641a829f..034c3db91fc3 100644
struct sockaddr_vm *addr)
{
--
2.45.2
2.46.0

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From db9dd067e0ef890d720617635023919a106ac70e Mon Sep 17 00:00:00 2001
From f9c572bf348f3eda2d0763ecf0e212cf6861d769 Mon Sep 17 00:00:00 2001
From: Bobby Eshleman <bobby.eshleman () bytedance ! com>
Date: Sat, 10 Jun 2023 00:58:32 +0000
Subject: [PATCH 07/15] virtio/vsock: add VIRTIO_VSOCK_F_DGRAM feature bit
Subject: [PATCH 07/17] virtio/vsock: add VIRTIO_VSOCK_F_DGRAM feature bit

This commit adds a feature bit for virtio vsock to support datagrams.

Expand All @@ -24,5 +24,5 @@ index 64738838bee5..9c25f267bbc0 100644
struct virtio_vsock_config {
__le64 guest_cid;
--
2.45.2
2.46.0

Loading