summaryrefslogtreecommitdiff
path: root/gui-wm/sommelier/files/sommelier-0.12-enforce-16k-alignment.patch
blob: 7795fa574fd78428413668324bde56c1ea2860ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
Upstream: no

From 10056fbb3f09d448a00748fea48dc6c630948d90 Mon Sep 17 00:00:00 2001
From: Johannes Nixdorf <johannes@nixdorf.dev>
Date: Wed, 29 May 2024 21:20:53 +0200
Subject: [PATCH] Import the 16k alignment patch hidden in the copr sources

---
 sommelier-seat.cc                 | 4 +++-
 virtualization/virtgpu_channel.cc | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/sommelier-seat.cc b/sommelier-seat.cc
index 3a056ca00ea8..c8dc85fcacb1 100644
--- a/sommelier-seat.cc
+++ b/sommelier-seat.cc
@@ -286,6 +286,8 @@ static void sl_host_keyboard_release(struct wl_client* client,
 static const struct wl_keyboard_interface sl_keyboard_implementation = {
     sl_host_keyboard_release};
 
+#define ALIGN_POT(x, pot_align) (((x) + (pot_align) - 1) & ~((pot_align) - 1))
+
 static void sl_keyboard_keymap(void* data,
                                struct wl_keyboard* keyboard,
                                uint32_t format,
@@ -297,7 +299,7 @@ static void sl_keyboard_keymap(void* data,
   wl_keyboard_send_keymap(host->resource, format, fd, size);
 
   if (format == WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1) {
-    void* data = mmap(nullptr, size, PROT_READ, MAP_SHARED, fd, 0);
+    void* data = mmap(nullptr, ALIGN_POT(size, 16384), PROT_READ, MAP_SHARED, fd, 0);
 
     assert(data != MAP_FAILED);
 
diff --git a/virtualization/virtgpu_channel.cc b/virtualization/virtgpu_channel.cc
index ff4c07cffbf4..fcfbb8c7707c 100644
--- a/virtualization/virtgpu_channel.cc
+++ b/virtualization/virtgpu_channel.cc
@@ -617,13 +617,15 @@ int32_t VirtGpuChannel::channel_poll() {
   return 0;
 }
 
+#define ALIGN_POT(x, pot_align) (((x) + (pot_align) - 1) & ~((pot_align) - 1))
+
 int32_t VirtGpuChannel::create_host_blob(uint64_t blob_id,
                                          uint64_t size,
                                          int& out_fd) {
   int32_t ret;
   struct drm_virtgpu_resource_create_blob drm_rc_blob = {};
 
-  drm_rc_blob.size = size;
+  drm_rc_blob.size = ALIGN_POT(size, 16384);
   drm_rc_blob.blob_mem = VIRTGPU_BLOB_MEM_HOST3D;
   drm_rc_blob.blob_flags =
       VIRTGPU_BLOB_FLAG_USE_MAPPABLE | VIRTGPU_BLOB_FLAG_USE_SHAREABLE;
-- 
2.45.1