Gentoo Archives: gentoo-commits

From: Mike Pagano <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:4.18 commit in: /
Date: Wed, 14 Nov 2018 13:15:59
Message-Id: 1542201321.c25319c18a134fe3e6ff8b66a6e53342c0fd0ff3.mpagano@gentoo
1 commit: c25319c18a134fe3e6ff8b66a6e53342c0fd0ff3
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Sat Jun 23 22:21:38 2018 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Wed Nov 14 13:15:21 2018 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=c25319c1
7
8 Patch to support for namespace user.pax.* on tmpfs.
9 Enable link security restrictions by default.
10 Add UAS disable quirk. See bug #640082.
11 hid-apple patch to enable swapping of the FN and left Control keys and
12 some additional on some apple keyboards. See bug #622902
13 Bootsplash ported by Conrad Kostecki. (Bug #637434)
14 Enable control of the unaligned access control policy from sysctl
15 Patch that adds Gentoo Linux support config settings and defaults.
16 Kernel patch enables gcc >= v4.13 optimizations for additional CPUs.
17
18 Signed-off-by: Mike Pagano <mpagano <AT> gentoo.org>
19
20 0000_README | 28 +
21 1500_XATTR_USER_PREFIX.patch | 69 +
22 ...ble-link-security-restrictions-by-default.patch | 22 +
23 ...age-Disable-UAS-on-JMicron-SATA-enclosure.patch | 40 +
24 2600_enable-key-swapping-for-apple-mac.patch | 114 ++
25 4200_fbcondecor.patch | 2095 ++++++++++++++++++++
26 4400_alpha-sysctl-uac.patch | 142 ++
27 4567_distro-Gentoo-Kconfig.patch | 160 +-
28 ...able-additional-cpu-optimizations-for-gcc.patch | 545 +++++
29 9 files changed, 3061 insertions(+), 154 deletions(-)
30
31 diff --git a/0000_README b/0000_README
32 index 9018993..917d838 100644
33 --- a/0000_README
34 +++ b/0000_README
35 @@ -43,6 +43,34 @@ EXPERIMENTAL
36 Individual Patch Descriptions:
37 --------------------------------------------------------------------------
38
39 +Patch: 1500_XATTR_USER_PREFIX.patch
40 +From: https://bugs.gentoo.org/show_bug.cgi?id=470644
41 +Desc: Support for namespace user.pax.* on tmpfs.
42 +
43 +Patch: 1510_fs-enable-link-security-restrictions-by-default.patch
44 +From: http://sources.debian.net/src/linux/3.16.7-ckt4-3/debian/patches/debian/fs-enable-link-security-restrictions-by-default.patch/
45 +Desc: Enable link security restrictions by default.
46 +
47 +Patch: 2500_usb-storage-Disable-UAS-on-JMicron-SATA-enclosure.patch
48 +From: https://bugzilla.redhat.com/show_bug.cgi?id=1260207#c5
49 +Desc: Add UAS disable quirk. See bug #640082.
50 +
51 +Patch: 2600_enable-key-swapping-for-apple-mac.patch
52 +From: https://github.com/free5lot/hid-apple-patched
53 +Desc: This hid-apple patch enables swapping of the FN and left Control keys and some additional on some apple keyboards. See bug #622902
54 +
55 +Patch: 4200_fbcondecor.patch
56 +From: http://www.mepiscommunity.org/fbcondecor
57 +Desc: Bootsplash ported by Conrad Kostecki. (Bug #637434)
58 +
59 +Patch: 4400_alpha-sysctl-uac.patch
60 +From: Tobias Klausmann (klausman@g.o) and http://bugs.gentoo.org/show_bug.cgi?id=217323
61 +Desc: Enable control of the unaligned access control policy from sysctl
62 +
63 Patch: 4567_distro-Gentoo-Kconfig.patch
64 From: Tom Wijsman <TomWij@g.o>
65 Desc: Add Gentoo Linux support config settings and defaults.
66 +
67 +Patch: 5010_enable-additional-cpu-optimizations-for-gcc.patch
68 +From: https://github.com/graysky2/kernel_gcc_patch/
69 +Desc: Kernel patch enables gcc >= v4.13 optimizations for additional CPUs.
70
71 diff --git a/1500_XATTR_USER_PREFIX.patch b/1500_XATTR_USER_PREFIX.patch
72 new file mode 100644
73 index 0000000..bacd032
74 --- /dev/null
75 +++ b/1500_XATTR_USER_PREFIX.patch
76 @@ -0,0 +1,69 @@
77 +From: Anthony G. Basile <blueness@g.o>
78 +
79 +This patch adds support for a restricted user-controlled namespace on
80 +tmpfs filesystem used to house PaX flags. The namespace must be of the
81 +form user.pax.* and its value cannot exceed a size of 8 bytes.
82 +
83 +This is needed even on all Gentoo systems so that XATTR_PAX flags
84 +are preserved for users who might build packages using portage on
85 +a tmpfs system with a non-hardened kernel and then switch to a
86 +hardened kernel with XATTR_PAX enabled.
87 +
88 +The namespace is added to any user with Extended Attribute support
89 +enabled for tmpfs. Users who do not enable xattrs will not have
90 +the XATTR_PAX flags preserved.
91 +
92 +diff --git a/include/uapi/linux/xattr.h b/include/uapi/linux/xattr.h
93 +index 1590c49..5eab462 100644
94 +--- a/include/uapi/linux/xattr.h
95 ++++ b/include/uapi/linux/xattr.h
96 +@@ -73,5 +73,9 @@
97 + #define XATTR_POSIX_ACL_DEFAULT "posix_acl_default"
98 + #define XATTR_NAME_POSIX_ACL_DEFAULT XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_DEFAULT
99 +
100 ++/* User namespace */
101 ++#define XATTR_PAX_PREFIX XATTR_USER_PREFIX "pax."
102 ++#define XATTR_PAX_FLAGS_SUFFIX "flags"
103 ++#define XATTR_NAME_PAX_FLAGS XATTR_PAX_PREFIX XATTR_PAX_FLAGS_SUFFIX
104 +
105 + #endif /* _UAPI_LINUX_XATTR_H */
106 +diff --git a/mm/shmem.c b/mm/shmem.c
107 +index 440e2a7..c377172 100644
108 +--- a/mm/shmem.c
109 ++++ b/mm/shmem.c
110 +@@ -2667,6 +2667,14 @@ static int shmem_xattr_handler_set(const struct xattr_handler *handler,
111 + struct shmem_inode_info *info = SHMEM_I(d_inode(dentry));
112 +
113 + name = xattr_full_name(handler, name);
114 ++
115 ++ if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
116 ++ if (strcmp(name, XATTR_NAME_PAX_FLAGS))
117 ++ return -EOPNOTSUPP;
118 ++ if (size > 8)
119 ++ return -EINVAL;
120 ++ }
121 ++
122 + return simple_xattr_set(&info->xattrs, name, value, size, flags);
123 + }
124 +
125 +@@ -2682,6 +2690,12 @@ static const struct xattr_handler shmem_trusted_xattr_handler = {
126 + .set = shmem_xattr_handler_set,
127 + };
128 +
129 ++static const struct xattr_handler shmem_user_xattr_handler = {
130 ++ .prefix = XATTR_USER_PREFIX,
131 ++ .get = shmem_xattr_handler_get,
132 ++ .set = shmem_xattr_handler_set,
133 ++};
134 ++
135 + static const struct xattr_handler *shmem_xattr_handlers[] = {
136 + #ifdef CONFIG_TMPFS_POSIX_ACL
137 + &posix_acl_access_xattr_handler,
138 +@@ -2689,6 +2703,7 @@ static const struct xattr_handler *shmem_xattr_handlers[] = {
139 + #endif
140 + &shmem_security_xattr_handler,
141 + &shmem_trusted_xattr_handler,
142 ++ &shmem_user_xattr_handler,
143 + NULL
144 + };
145 +
146
147 diff --git a/1510_fs-enable-link-security-restrictions-by-default.patch b/1510_fs-enable-link-security-restrictions-by-default.patch
148 new file mode 100644
149 index 0000000..639fb3c
150 --- /dev/null
151 +++ b/1510_fs-enable-link-security-restrictions-by-default.patch
152 @@ -0,0 +1,22 @@
153 +From: Ben Hutchings <ben@××××××××××××.uk>
154 +Subject: fs: Enable link security restrictions by default
155 +Date: Fri, 02 Nov 2012 05:32:06 +0000
156 +Bug-Debian: https://bugs.debian.org/609455
157 +Forwarded: not-needed
158 +
159 +This reverts commit 561ec64ae67ef25cac8d72bb9c4bfc955edfd415
160 +('VFS: don't do protected {sym,hard}links by default').
161 +
162 +--- a/fs/namei.c
163 ++++ b/fs/namei.c
164 +@@ -651,8 +651,8 @@ static inline void put_link(struct namei
165 + path_put(link);
166 + }
167 +
168 +-int sysctl_protected_symlinks __read_mostly = 0;
169 +-int sysctl_protected_hardlinks __read_mostly = 0;
170 ++int sysctl_protected_symlinks __read_mostly = 1;
171 ++int sysctl_protected_hardlinks __read_mostly = 1;
172 +
173 + /**
174 + * may_follow_link - Check symlink following for unsafe situations
175
176 diff --git a/2500_usb-storage-Disable-UAS-on-JMicron-SATA-enclosure.patch b/2500_usb-storage-Disable-UAS-on-JMicron-SATA-enclosure.patch
177 new file mode 100644
178 index 0000000..0dd93ef
179 --- /dev/null
180 +++ b/2500_usb-storage-Disable-UAS-on-JMicron-SATA-enclosure.patch
181 @@ -0,0 +1,40 @@
182 +From d02a55182307c01136b599fd048b4679f259a84e Mon Sep 17 00:00:00 2001
183 +From: Laura Abbott <labbott@×××××××××××××.org>
184 +Date: Tue, 8 Sep 2015 09:53:38 -0700
185 +Subject: [PATCH] usb-storage: Disable UAS on JMicron SATA enclosure
186 +
187 +Steve Ellis reported incorrect block sizes and alignement
188 +offsets with a SATA enclosure. Adding a quirk to disable
189 +UAS fixes the problems.
190 +
191 +Reported-by: Steven Ellis <sellis@××××××.com>
192 +Signed-off-by: Laura Abbott <labbott@×××××××××××××.org>
193 +---
194 + drivers/usb/storage/unusual_uas.h | 7 +++++--
195 + 1 file changed, 5 insertions(+), 2 deletions(-)
196 +
197 +diff --git a/drivers/usb/storage/unusual_uas.h b/drivers/usb/storage/unusual_uas.h
198 +index c85ea53..216d93d 100644
199 +--- a/drivers/usb/storage/unusual_uas.h
200 ++++ b/drivers/usb/storage/unusual_uas.h
201 +@@ -141,12 +141,15 @@ UNUSUAL_DEV(0x2109, 0x0711, 0x0000, 0x9999,
202 + USB_SC_DEVICE, USB_PR_DEVICE, NULL,
203 + US_FL_NO_ATA_1X),
204 +
205 +-/* Reported-by: Takeo Nakayama <javhera@×××.com> */
206 ++/*
207 ++ * Initially Reported-by: Takeo Nakayama <javhera@×××.com>
208 ++ * UAS Ignore Reported by Steven Ellis <sellis@××××××.com>
209 ++ */
210 + UNUSUAL_DEV(0x357d, 0x7788, 0x0000, 0x9999,
211 + "JMicron",
212 + "JMS566",
213 + USB_SC_DEVICE, USB_PR_DEVICE, NULL,
214 +- US_FL_NO_REPORT_OPCODES),
215 ++ US_FL_NO_REPORT_OPCODES | US_FL_IGNORE_UAS),
216 +
217 + /* Reported-by: Hans de Goede <hdegoede@××××××.com> */
218 + UNUSUAL_DEV(0x4971, 0x1012, 0x0000, 0x9999,
219 +--
220 +2.4.3
221 +
222
223 diff --git a/2600_enable-key-swapping-for-apple-mac.patch b/2600_enable-key-swapping-for-apple-mac.patch
224 new file mode 100644
225 index 0000000..ab228d3
226 --- /dev/null
227 +++ b/2600_enable-key-swapping-for-apple-mac.patch
228 @@ -0,0 +1,114 @@
229 +--- a/drivers/hid/hid-apple.c
230 ++++ b/drivers/hid/hid-apple.c
231 +@@ -52,6 +52,22 @@
232 + "(For people who want to keep Windows PC keyboard muscle memory. "
233 + "[0] = as-is, Mac layout. 1 = swapped, Windows layout.)");
234 +
235 ++static unsigned int swap_fn_leftctrl;
236 ++module_param(swap_fn_leftctrl, uint, 0644);
237 ++MODULE_PARM_DESC(swap_fn_leftctrl, "Swap the Fn and left Control keys. "
238 ++ "(For people who want to keep PC keyboard muscle memory. "
239 ++ "[0] = as-is, Mac layout, 1 = swapped, PC layout)");
240 ++
241 ++static unsigned int rightalt_as_rightctrl;
242 ++module_param(rightalt_as_rightctrl, uint, 0644);
243 ++MODULE_PARM_DESC(rightalt_as_rightctrl, "Use the right Alt key as a right Ctrl key. "
244 ++ "[0] = as-is, Mac layout. 1 = Right Alt is right Ctrl");
245 ++
246 ++static unsigned int ejectcd_as_delete;
247 ++module_param(ejectcd_as_delete, uint, 0644);
248 ++MODULE_PARM_DESC(ejectcd_as_delete, "Use Eject-CD key as Delete key. "
249 ++ "([0] = disabled, 1 = enabled)");
250 ++
251 + struct apple_sc {
252 + unsigned long quirks;
253 + unsigned int fn_on;
254 +@@ -164,6 +180,21 @@
255 + { }
256 + };
257 +
258 ++static const struct apple_key_translation swapped_fn_leftctrl_keys[] = {
259 ++ { KEY_FN, KEY_LEFTCTRL },
260 ++ { }
261 ++};
262 ++
263 ++static const struct apple_key_translation rightalt_as_rightctrl_keys[] = {
264 ++ { KEY_RIGHTALT, KEY_RIGHTCTRL },
265 ++ { }
266 ++};
267 ++
268 ++static const struct apple_key_translation ejectcd_as_delete_keys[] = {
269 ++ { KEY_EJECTCD, KEY_DELETE },
270 ++ { }
271 ++};
272 ++
273 + static const struct apple_key_translation *apple_find_translation(
274 + const struct apple_key_translation *table, u16 from)
275 + {
276 +@@ -183,9 +214,11 @@
277 + struct apple_sc *asc = hid_get_drvdata(hid);
278 + const struct apple_key_translation *trans, *table;
279 +
280 +- if (usage->code == KEY_FN) {
281 ++ u16 fn_keycode = (swap_fn_leftctrl) ? (KEY_LEFTCTRL) : (KEY_FN);
282 ++
283 ++ if (usage->code == fn_keycode) {
284 + asc->fn_on = !!value;
285 +- input_event(input, usage->type, usage->code, value);
286 ++ input_event(input, usage->type, KEY_FN, value);
287 + return 1;
288 + }
289 +
290 +@@ -264,6 +297,30 @@
291 + }
292 + }
293 +
294 ++ if (swap_fn_leftctrl) {
295 ++ trans = apple_find_translation(swapped_fn_leftctrl_keys, usage->code);
296 ++ if (trans) {
297 ++ input_event(input, usage->type, trans->to, value);
298 ++ return 1;
299 ++ }
300 ++ }
301 ++
302 ++ if (ejectcd_as_delete) {
303 ++ trans = apple_find_translation(ejectcd_as_delete_keys, usage->code);
304 ++ if (trans) {
305 ++ input_event(input, usage->type, trans->to, value);
306 ++ return 1;
307 ++ }
308 ++ }
309 ++
310 ++ if (rightalt_as_rightctrl) {
311 ++ trans = apple_find_translation(rightalt_as_rightctrl_keys, usage->code);
312 ++ if (trans) {
313 ++ input_event(input, usage->type, trans->to, value);
314 ++ return 1;
315 ++ }
316 ++ }
317 ++
318 + return 0;
319 + }
320 +
321 +@@ -327,6 +384,21 @@
322 +
323 + for (trans = apple_iso_keyboard; trans->from; trans++)
324 + set_bit(trans->to, input->keybit);
325 ++
326 ++ if (swap_fn_leftctrl) {
327 ++ for (trans = swapped_fn_leftctrl_keys; trans->from; trans++)
328 ++ set_bit(trans->to, input->keybit);
329 ++ }
330 ++
331 ++ if (ejectcd_as_delete) {
332 ++ for (trans = ejectcd_as_delete_keys; trans->from; trans++)
333 ++ set_bit(trans->to, input->keybit);
334 ++ }
335 ++
336 ++ if (rightalt_as_rightctrl) {
337 ++ for (trans = rightalt_as_rightctrl_keys; trans->from; trans++)
338 ++ set_bit(trans->to, input->keybit);
339 ++ }
340 + }
341 +
342 + static int apple_input_mapping(struct hid_device *hdev, struct hid_input *hi,
343
344 diff --git a/4200_fbcondecor.patch b/4200_fbcondecor.patch
345 new file mode 100644
346 index 0000000..7151d0f
347 --- /dev/null
348 +++ b/4200_fbcondecor.patch
349 @@ -0,0 +1,2095 @@
350 +diff --git a/Documentation/fb/00-INDEX b/Documentation/fb/00-INDEX
351 +index fe85e7c5907a..22309308ba56 100644
352 +--- a/Documentation/fb/00-INDEX
353 ++++ b/Documentation/fb/00-INDEX
354 +@@ -23,6 +23,8 @@ ep93xx-fb.txt
355 + - info on the driver for EP93xx LCD controller.
356 + fbcon.txt
357 + - intro to and usage guide for the framebuffer console (fbcon).
358 ++fbcondecor.txt
359 ++ - info on the Framebuffer Console Decoration
360 + framebuffer.txt
361 + - introduction to frame buffer devices.
362 + gxfb.txt
363 +diff --git a/Documentation/fb/fbcondecor.txt b/Documentation/fb/fbcondecor.txt
364 +new file mode 100644
365 +index 000000000000..637209e11ccd
366 +--- /dev/null
367 ++++ b/Documentation/fb/fbcondecor.txt
368 +@@ -0,0 +1,207 @@
369 ++What is it?
370 ++-----------
371 ++
372 ++The framebuffer decorations are a kernel feature which allows displaying a
373 ++background picture on selected consoles.
374 ++
375 ++What do I need to get it to work?
376 ++---------------------------------
377 ++
378 ++To get fbcondecor up-and-running you will have to:
379 ++ 1) get a copy of splashutils [1] or a similar program
380 ++ 2) get some fbcondecor themes
381 ++ 3) build the kernel helper program
382 ++ 4) build your kernel with the FB_CON_DECOR option enabled.
383 ++
384 ++To get fbcondecor operational right after fbcon initialization is finished, you
385 ++will have to include a theme and the kernel helper into your initramfs image.
386 ++Please refer to splashutils documentation for instructions on how to do that.
387 ++
388 ++[1] The splashutils package can be downloaded from:
389 ++ http://github.com/alanhaggai/fbsplash
390 ++
391 ++The userspace helper
392 ++--------------------
393 ++
394 ++The userspace fbcondecor helper (by default: /sbin/fbcondecor_helper) is called by the
395 ++kernel whenever an important event occurs and the kernel needs some kind of
396 ++job to be carried out. Important events include console switches and video
397 ++mode switches (the kernel requests background images and configuration
398 ++parameters for the current console). The fbcondecor helper must be accessible at
399 ++all times. If it's not, fbcondecor will be switched off automatically.
400 ++
401 ++It's possible to set path to the fbcondecor helper by writing it to
402 ++/proc/sys/kernel/fbcondecor.
403 ++
404 ++*****************************************************************************
405 ++
406 ++The information below is mostly technical stuff. There's probably no need to
407 ++read it unless you plan to develop a userspace helper.
408 ++
409 ++The fbcondecor protocol
410 ++-----------------------
411 ++
412 ++The fbcondecor protocol defines a communication interface between the kernel and
413 ++the userspace fbcondecor helper.
414 ++
415 ++The kernel side is responsible for:
416 ++
417 ++ * rendering console text, using an image as a background (instead of a
418 ++ standard solid color fbcon uses),
419 ++ * accepting commands from the user via ioctls on the fbcondecor device,
420 ++ * calling the userspace helper to set things up as soon as the fb subsystem
421 ++ is initialized.
422 ++
423 ++The userspace helper is responsible for everything else, including parsing
424 ++configuration files, decompressing the image files whenever the kernel needs
425 ++it, and communicating with the kernel if necessary.
426 ++
427 ++The fbcondecor protocol specifies how communication is done in both ways:
428 ++kernel->userspace and userspace->helper.
429 ++
430 ++Kernel -> Userspace
431 ++-------------------
432 ++
433 ++The kernel communicates with the userspace helper by calling it and specifying
434 ++the task to be done in a series of arguments.
435 ++
436 ++The arguments follow the pattern:
437 ++<fbcondecor protocol version> <command> <parameters>
438 ++
439 ++All commands defined in fbcondecor protocol v2 have the following parameters:
440 ++ virtual console
441 ++ framebuffer number
442 ++ theme
443 ++
444 ++Fbcondecor protocol v1 specified an additional 'fbcondecor mode' after the
445 ++framebuffer number. Fbcondecor protocol v1 is deprecated and should not be used.
446 ++
447 ++Fbcondecor protocol v2 specifies the following commands:
448 ++
449 ++getpic
450 ++------
451 ++ The kernel issues this command to request image data. It's up to the
452 ++ userspace helper to find a background image appropriate for the specified
453 ++ theme and the current resolution. The userspace helper should respond by
454 ++ issuing the FBIOCONDECOR_SETPIC ioctl.
455 ++
456 ++init
457 ++----
458 ++ The kernel issues this command after the fbcondecor device is created and
459 ++ the fbcondecor interface is initialized. Upon receiving 'init', the userspace
460 ++ helper should parse the kernel command line (/proc/cmdline) or otherwise
461 ++ decide whether fbcondecor is to be activated.
462 ++
463 ++ To activate fbcondecor on the first console the helper should issue the
464 ++ FBIOCONDECOR_SETCFG, FBIOCONDECOR_SETPIC and FBIOCONDECOR_SETSTATE commands,
465 ++ in the above-mentioned order.
466 ++
467 ++ When the userspace helper is called in an early phase of the boot process
468 ++ (right after the initialization of fbcon), no filesystems will be mounted.
469 ++ The helper program should mount sysfs and then create the appropriate
470 ++ framebuffer, fbcondecor and tty0 devices (if they don't already exist) to get
471 ++ current display settings and to be able to communicate with the kernel side.
472 ++ It should probably also mount the procfs to be able to parse the kernel
473 ++ command line parameters.
474 ++
475 ++ Note that the console sem is not held when the kernel calls fbcondecor_helper
476 ++ with the 'init' command. The fbcondecor helper should perform all ioctls with
477 ++ origin set to FBCON_DECOR_IO_ORIG_USER.
478 ++
479 ++modechange
480 ++----------
481 ++ The kernel issues this command on a mode change. The helper's response should
482 ++ be similar to the response to the 'init' command. Note that this time the
483 ++ console sem is held and all ioctls must be performed with origin set to
484 ++ FBCON_DECOR_IO_ORIG_KERNEL.
485 ++
486 ++
487 ++Userspace -> Kernel
488 ++-------------------
489 ++
490 ++Userspace programs can communicate with fbcondecor via ioctls on the
491 ++fbcondecor device. These ioctls are to be used by both the userspace helper
492 ++(called only by the kernel) and userspace configuration tools (run by the users).
493 ++
494 ++The fbcondecor helper should set the origin field to FBCON_DECOR_IO_ORIG_KERNEL
495 ++when doing the appropriate ioctls. All userspace configuration tools should
496 ++use FBCON_DECOR_IO_ORIG_USER. Failure to set the appropriate value in the origin
497 ++field when performing ioctls from the kernel helper will most likely result
498 ++in a console deadlock.
499 ++
500 ++FBCON_DECOR_IO_ORIG_KERNEL instructs fbcondecor not to try to acquire the console
501 ++semaphore. Not surprisingly, FBCON_DECOR_IO_ORIG_USER instructs it to acquire
502 ++the console sem.
503 ++
504 ++The framebuffer console decoration provides the following ioctls (all defined in
505 ++linux/fb.h):
506 ++
507 ++FBIOCONDECOR_SETPIC
508 ++description: loads a background picture for a virtual console
509 ++argument: struct fbcon_decor_iowrapper*; data: struct fb_image*
510 ++notes:
511 ++If called for consoles other than the current foreground one, the picture data
512 ++will be ignored.
513 ++
514 ++If the current virtual console is running in a 8-bpp mode, the cmap substruct
515 ++of fb_image has to be filled appropriately: start should be set to 16 (first
516 ++16 colors are reserved for fbcon), len to a value <= 240 and red, green and
517 ++blue should point to valid cmap data. The transp field is ingored. The fields
518 ++dx, dy, bg_color, fg_color in fb_image are ignored as well.
519 ++
520 ++FBIOCONDECOR_SETCFG
521 ++description: sets the fbcondecor config for a virtual console
522 ++argument: struct fbcon_decor_iowrapper*; data: struct vc_decor*
523 ++notes: The structure has to be filled with valid data.
524 ++
525 ++FBIOCONDECOR_GETCFG
526 ++description: gets the fbcondecor config for a virtual console
527 ++argument: struct fbcon_decor_iowrapper*; data: struct vc_decor*
528 ++
529 ++FBIOCONDECOR_SETSTATE
530 ++description: sets the fbcondecor state for a virtual console
531 ++argument: struct fbcon_decor_iowrapper*; data: unsigned int*
532 ++ values: 0 = disabled, 1 = enabled.
533 ++
534 ++FBIOCONDECOR_GETSTATE
535 ++description: gets the fbcondecor state for a virtual console
536 ++argument: struct fbcon_decor_iowrapper*; data: unsigned int*
537 ++ values: as in FBIOCONDECOR_SETSTATE
538 ++
539 ++Info on used structures:
540 ++
541 ++Definition of struct vc_decor can be found in linux/console_decor.h. It's
542 ++heavily commented. Note that the 'theme' field should point to a string
543 ++no longer than FBCON_DECOR_THEME_LEN. When FBIOCONDECOR_GETCFG call is
544 ++performed, the theme field should point to a char buffer of length
545 ++FBCON_DECOR_THEME_LEN.
546 ++
547 ++Definition of struct fbcon_decor_iowrapper can be found in linux/fb.h.
548 ++The fields in this struct have the following meaning:
549 ++
550 ++vc:
551 ++Virtual console number.
552 ++
553 ++origin:
554 ++Specifies if the ioctl is performed as a response to a kernel request. The
555 ++fbcondecor helper should set this field to FBCON_DECOR_IO_ORIG_KERNEL, userspace
556 ++programs should set it to FBCON_DECOR_IO_ORIG_USER. This field is necessary to
557 ++avoid console semaphore deadlocks.
558 ++
559 ++data:
560 ++Pointer to a data structure appropriate for the performed ioctl. Type of
561 ++the data struct is specified in the ioctls description.
562 ++
563 ++*****************************************************************************
564 ++
565 ++Credit
566 ++------
567 ++
568 ++Original 'bootsplash' project & implementation by:
569 ++ Volker Poplawski <volker@×××××××××.de>, Stefan Reinauer <stepan@××××.de>,
570 ++ Steffen Winterfeldt <snwint@××××.de>, Michael Schroeder <mls@××××.de>,
571 ++ Ken Wimer <wimer@××××.de>.
572 ++
573 ++Fbcondecor, fbcondecor protocol design, current implementation & docs by:
574 ++ Michal Januszewski <michalj+fbcondecor@×××××.com>
575 ++
576 +diff --git a/drivers/Makefile b/drivers/Makefile
577 +index 1d034b680431..9f41f2ea0c8b 100644
578 +--- a/drivers/Makefile
579 ++++ b/drivers/Makefile
580 +@@ -23,6 +23,10 @@ obj-y += pci/dwc/
581 +
582 + obj-$(CONFIG_PARISC) += parisc/
583 + obj-$(CONFIG_RAPIDIO) += rapidio/
584 ++# tty/ comes before char/ so that the VT console is the boot-time
585 ++# default.
586 ++obj-y += tty/
587 ++obj-y += char/
588 + obj-y += video/
589 + obj-y += idle/
590 +
591 +@@ -53,11 +57,6 @@ obj-$(CONFIG_REGULATOR) += regulator/
592 + # reset controllers early, since gpu drivers might rely on them to initialize
593 + obj-$(CONFIG_RESET_CONTROLLER) += reset/
594 +
595 +-# tty/ comes before char/ so that the VT console is the boot-time
596 +-# default.
597 +-obj-y += tty/
598 +-obj-y += char/
599 +-
600 + # iommu/ comes before gpu as gpu are using iommu controllers
601 + obj-$(CONFIG_IOMMU_SUPPORT) += iommu/
602 +
603 +diff --git a/drivers/video/console/Kconfig b/drivers/video/console/Kconfig
604 +index 7f1f1fbcef9e..8439b618dfc0 100644
605 +--- a/drivers/video/console/Kconfig
606 ++++ b/drivers/video/console/Kconfig
607 +@@ -151,6 +151,19 @@ config FRAMEBUFFER_CONSOLE_ROTATION
608 + such that other users of the framebuffer will remain normally
609 + oriented.
610 +
611 ++config FB_CON_DECOR
612 ++ bool "Support for the Framebuffer Console Decorations"
613 ++ depends on FRAMEBUFFER_CONSOLE=y && !FB_TILEBLITTING
614 ++ default n
615 ++ ---help---
616 ++ This option enables support for framebuffer console decorations which
617 ++ makes it possible to display images in the background of the system
618 ++ consoles. Note that userspace utilities are necessary in order to take
619 ++ advantage of these features. Refer to Documentation/fb/fbcondecor.txt
620 ++ for more information.
621 ++
622 ++ If unsure, say N.
623 ++
624 + config STI_CONSOLE
625 + bool "STI text console"
626 + depends on PARISC
627 +diff --git a/drivers/video/console/Makefile b/drivers/video/console/Makefile
628 +index db07b784bd2c..3e369bd120b8 100644
629 +--- a/drivers/video/console/Makefile
630 ++++ b/drivers/video/console/Makefile
631 +@@ -9,4 +9,5 @@ obj-$(CONFIG_STI_CONSOLE) += sticon.o sticore.o
632 + obj-$(CONFIG_VGA_CONSOLE) += vgacon.o
633 + obj-$(CONFIG_MDA_CONSOLE) += mdacon.o
634 +
635 ++obj-$(CONFIG_FB_CON_DECOR) += fbcondecor.o cfbcondecor.o
636 + obj-$(CONFIG_FB_STI) += sticore.o
637 +diff --git a/drivers/video/console/cfbcondecor.c b/drivers/video/console/cfbcondecor.c
638 +new file mode 100644
639 +index 000000000000..b00960803edc
640 +--- /dev/null
641 ++++ b/drivers/video/console/cfbcondecor.c
642 +@@ -0,0 +1,473 @@
643 ++/*
644 ++ * linux/drivers/video/cfbcon_decor.c -- Framebuffer decor render functions
645 ++ *
646 ++ * Copyright (C) 2004 Michal Januszewski <michalj+fbcondecor@×××××.com>
647 ++ *
648 ++ * Code based upon "Bootdecor" (C) 2001-2003
649 ++ * Volker Poplawski <volker@×××××××××.de>,
650 ++ * Stefan Reinauer <stepan@××××.de>,
651 ++ * Steffen Winterfeldt <snwint@××××.de>,
652 ++ * Michael Schroeder <mls@××××.de>,
653 ++ * Ken Wimer <wimer@××××.de>.
654 ++ *
655 ++ * This file is subject to the terms and conditions of the GNU General Public
656 ++ * License. See the file COPYING in the main directory of this archive for
657 ++ * more details.
658 ++ */
659 ++#include <linux/module.h>
660 ++#include <linux/types.h>
661 ++#include <linux/fb.h>
662 ++#include <linux/selection.h>
663 ++#include <linux/slab.h>
664 ++#include <linux/vt_kern.h>
665 ++#include <asm/irq.h>
666 ++
667 ++#include "../fbdev/core/fbcon.h"
668 ++#include "fbcondecor.h"
669 ++
670 ++#define parse_pixel(shift, bpp, type) \
671 ++ do { \
672 ++ if (d & (0x80 >> (shift))) \
673 ++ dd2[(shift)] = fgx; \
674 ++ else \
675 ++ dd2[(shift)] = transparent ? *(type *)decor_src : bgx; \
676 ++ decor_src += (bpp); \
677 ++ } while (0) \
678 ++
679 ++extern int get_color(struct vc_data *vc, struct fb_info *info,
680 ++ u16 c, int is_fg);
681 ++
682 ++void fbcon_decor_fix_pseudo_pal(struct fb_info *info, struct vc_data *vc)
683 ++{
684 ++ int i, j, k;
685 ++ int minlen = min(min(info->var.red.length, info->var.green.length),
686 ++ info->var.blue.length);
687 ++ u32 col;
688 ++
689 ++ for (j = i = 0; i < 16; i++) {
690 ++ k = color_table[i];
691 ++
692 ++ col = ((vc->vc_palette[j++] >> (8-minlen))
693 ++ << info->var.red.offset);
694 ++ col |= ((vc->vc_palette[j++] >> (8-minlen))
695 ++ << info->var.green.offset);
696 ++ col |= ((vc->vc_palette[j++] >> (8-minlen))
697 ++ << info->var.blue.offset);
698 ++ ((u32 *)info->pseudo_palette)[k] = col;
699 ++ }
700 ++}
701 ++
702 ++void fbcon_decor_renderc(struct fb_info *info, int ypos, int xpos, int height,
703 ++ int width, u8 *src, u32 fgx, u32 bgx, u8 transparent)
704 ++{
705 ++ unsigned int x, y;
706 ++ u32 dd;
707 ++ int bytespp = ((info->var.bits_per_pixel + 7) >> 3);
708 ++ unsigned int d = ypos * info->fix.line_length + xpos * bytespp;
709 ++ unsigned int ds = (ypos * info->var.xres + xpos) * bytespp;
710 ++ u16 dd2[4];
711 ++
712 ++ u8 *decor_src = (u8 *)(info->bgdecor.data + ds);
713 ++ u8 *dst = (u8 *)(info->screen_base + d);
714 ++
715 ++ if ((ypos + height) > info->var.yres || (xpos + width) > info->var.xres)
716 ++ return;
717 ++
718 ++ for (y = 0; y < height; y++) {
719 ++ switch (info->var.bits_per_pixel) {
720 ++
721 ++ case 32:
722 ++ for (x = 0; x < width; x++) {
723 ++
724 ++ if ((x & 7) == 0)
725 ++ d = *src++;
726 ++ if (d & 0x80)
727 ++ dd = fgx;
728 ++ else
729 ++ dd = transparent ?
730 ++ *(u32 *)decor_src : bgx;
731 ++
732 ++ d <<= 1;
733 ++ decor_src += 4;
734 ++ fb_writel(dd, dst);
735 ++ dst += 4;
736 ++ }
737 ++ break;
738 ++ case 24:
739 ++ for (x = 0; x < width; x++) {
740 ++
741 ++ if ((x & 7) == 0)
742 ++ d = *src++;
743 ++ if (d & 0x80)
744 ++ dd = fgx;
745 ++ else
746 ++ dd = transparent ?
747 ++ (*(u32 *)decor_src & 0xffffff) : bgx;
748 ++
749 ++ d <<= 1;
750 ++ decor_src += 3;
751 ++#ifdef __LITTLE_ENDIAN
752 ++ fb_writew(dd & 0xffff, dst);
753 ++ dst += 2;
754 ++ fb_writeb((dd >> 16), dst);
755 ++#else
756 ++ fb_writew(dd >> 8, dst);
757 ++ dst += 2;
758 ++ fb_writeb(dd & 0xff, dst);
759 ++#endif
760 ++ dst++;
761 ++ }
762 ++ break;
763 ++ case 16:
764 ++ for (x = 0; x < width; x += 2) {
765 ++ if ((x & 7) == 0)
766 ++ d = *src++;
767 ++
768 ++ parse_pixel(0, 2, u16);
769 ++ parse_pixel(1, 2, u16);
770 ++#ifdef __LITTLE_ENDIAN
771 ++ dd = dd2[0] | (dd2[1] << 16);
772 ++#else
773 ++ dd = dd2[1] | (dd2[0] << 16);
774 ++#endif
775 ++ d <<= 2;
776 ++ fb_writel(dd, dst);
777 ++ dst += 4;
778 ++ }
779 ++ break;
780 ++
781 ++ case 8:
782 ++ for (x = 0; x < width; x += 4) {
783 ++ if ((x & 7) == 0)
784 ++ d = *src++;
785 ++
786 ++ parse_pixel(0, 1, u8);
787 ++ parse_pixel(1, 1, u8);
788 ++ parse_pixel(2, 1, u8);
789 ++ parse_pixel(3, 1, u8);
790 ++
791 ++#ifdef __LITTLE_ENDIAN
792 ++ dd = dd2[0] | (dd2[1] << 8) | (dd2[2] << 16) | (dd2[3] << 24);
793 ++#else
794 ++ dd = dd2[3] | (dd2[2] << 8) | (dd2[1] << 16) | (dd2[0] << 24);
795 ++#endif
796 ++ d <<= 4;
797 ++ fb_writel(dd, dst);
798 ++ dst += 4;
799 ++ }
800 ++ }
801 ++
802 ++ dst += info->fix.line_length - width * bytespp;
803 ++ decor_src += (info->var.xres - width) * bytespp;
804 ++ }
805 ++}
806 ++
807 ++#define cc2cx(a) \
808 ++ ((info->fix.visual == FB_VISUAL_TRUECOLOR || \
809 ++ info->fix.visual == FB_VISUAL_DIRECTCOLOR) ? \
810 ++ ((u32 *)info->pseudo_palette)[a] : a)
811 ++
812 ++void fbcon_decor_putcs(struct vc_data *vc, struct fb_info *info,
813 ++ const unsigned short *s, int count, int yy, int xx)
814 ++{
815 ++ unsigned short charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff;
816 ++ struct fbcon_ops *ops = info->fbcon_par;
817 ++ int fg_color, bg_color, transparent;
818 ++ u8 *src;
819 ++ u32 bgx, fgx;
820 ++ u16 c = scr_readw(s);
821 ++
822 ++ fg_color = get_color(vc, info, c, 1);
823 ++ bg_color = get_color(vc, info, c, 0);
824 ++
825 ++ /* Don't paint the background image if console is blanked */
826 ++ transparent = ops->blank_state ? 0 :
827 ++ (vc->vc_decor.bg_color == bg_color);
828 ++
829 ++ xx = xx * vc->vc_font.width + vc->vc_decor.tx;
830 ++ yy = yy * vc->vc_font.height + vc->vc_decor.ty;
831 ++
832 ++ fgx = cc2cx(fg_color);
833 ++ bgx = cc2cx(bg_color);
834 ++
835 ++ while (count--) {
836 ++ c = scr_readw(s++);
837 ++ src = vc->vc_font.data + (c & charmask) * vc->vc_font.height *
838 ++ ((vc->vc_font.width + 7) >> 3);
839 ++
840 ++ fbcon_decor_renderc(info, yy, xx, vc->vc_font.height,
841 ++ vc->vc_font.width, src, fgx, bgx, transparent);
842 ++ xx += vc->vc_font.width;
843 ++ }
844 ++}
845 ++
846 ++void fbcon_decor_cursor(struct fb_info *info, struct fb_cursor *cursor)
847 ++{
848 ++ int i;
849 ++ unsigned int dsize, s_pitch;
850 ++ struct fbcon_ops *ops = info->fbcon_par;
851 ++ struct vc_data *vc;
852 ++ u8 *src;
853 ++
854 ++ /* we really don't need any cursors while the console is blanked */
855 ++ if (info->state != FBINFO_STATE_RUNNING || ops->blank_state)
856 ++ return;
857 ++
858 ++ vc = vc_cons[ops->currcon].d;
859 ++
860 ++ src = kmalloc(64 + sizeof(struct fb_image), GFP_ATOMIC);
861 ++ if (!src)
862 ++ return;
863 ++
864 ++ s_pitch = (cursor->image.width + 7) >> 3;
865 ++ dsize = s_pitch * cursor->image.height;
866 ++ if (cursor->enable) {
867 ++ switch (cursor->rop) {
868 ++ case ROP_XOR:
869 ++ for (i = 0; i < dsize; i++)
870 ++ src[i] = cursor->image.data[i] ^ cursor->mask[i];
871 ++ break;
872 ++ case ROP_COPY:
873 ++ default:
874 ++ for (i = 0; i < dsize; i++)
875 ++ src[i] = cursor->image.data[i] & cursor->mask[i];
876 ++ break;
877 ++ }
878 ++ } else
879 ++ memcpy(src, cursor->image.data, dsize);
880 ++
881 ++ fbcon_decor_renderc(info,
882 ++ cursor->image.dy + vc->vc_decor.ty,
883 ++ cursor->image.dx + vc->vc_decor.tx,
884 ++ cursor->image.height,
885 ++ cursor->image.width,
886 ++ (u8 *)src,
887 ++ cc2cx(cursor->image.fg_color),
888 ++ cc2cx(cursor->image.bg_color),
889 ++ cursor->image.bg_color == vc->vc_decor.bg_color);
890 ++
891 ++ kfree(src);
892 ++}
893 ++
894 ++static void decorset(u8 *dst, int height, int width, int dstbytes,
895 ++ u32 bgx, int bpp)
896 ++{
897 ++ int i;
898 ++
899 ++ if (bpp == 8)
900 ++ bgx |= bgx << 8;
901 ++ if (bpp == 16 || bpp == 8)
902 ++ bgx |= bgx << 16;
903 ++
904 ++ while (height-- > 0) {
905 ++ u8 *p = dst;
906 ++
907 ++ switch (bpp) {
908 ++
909 ++ case 32:
910 ++ for (i = 0; i < width; i++) {
911 ++ fb_writel(bgx, p); p += 4;
912 ++ }
913 ++ break;
914 ++ case 24:
915 ++ for (i = 0; i < width; i++) {
916 ++#ifdef __LITTLE_ENDIAN
917 ++ fb_writew((bgx & 0xffff), (u16 *)p); p += 2;
918 ++ fb_writeb((bgx >> 16), p++);
919 ++#else
920 ++ fb_writew((bgx >> 8), (u16 *)p); p += 2;
921 ++ fb_writeb((bgx & 0xff), p++);
922 ++#endif
923 ++ }
924 ++ break;
925 ++ case 16:
926 ++ for (i = 0; i < width/4; i++) {
927 ++ fb_writel(bgx, p); p += 4;
928 ++ fb_writel(bgx, p); p += 4;
929 ++ }
930 ++ if (width & 2) {
931 ++ fb_writel(bgx, p); p += 4;
932 ++ }
933 ++ if (width & 1)
934 ++ fb_writew(bgx, (u16 *)p);
935 ++ break;
936 ++ case 8:
937 ++ for (i = 0; i < width/4; i++) {
938 ++ fb_writel(bgx, p); p += 4;
939 ++ }
940 ++
941 ++ if (width & 2) {
942 ++ fb_writew(bgx, p); p += 2;
943 ++ }
944 ++ if (width & 1)
945 ++ fb_writeb(bgx, (u8 *)p);
946 ++ break;
947 ++
948 ++ }
949 ++ dst += dstbytes;
950 ++ }
951 ++}
952 ++
953 ++void fbcon_decor_copy(u8 *dst, u8 *src, int height, int width, int linebytes,
954 ++ int srclinebytes, int bpp)
955 ++{
956 ++ int i;
957 ++
958 ++ while (height-- > 0) {
959 ++ u32 *p = (u32 *)dst;
960 ++ u32 *q = (u32 *)src;
961 ++
962 ++ switch (bpp) {
963 ++
964 ++ case 32:
965 ++ for (i = 0; i < width; i++)
966 ++ fb_writel(*q++, p++);
967 ++ break;
968 ++ case 24:
969 ++ for (i = 0; i < (width * 3 / 4); i++)
970 ++ fb_writel(*q++, p++);
971 ++ if ((width * 3) % 4) {
972 ++ if (width & 2) {
973 ++ fb_writeb(*(u8 *)q, (u8 *)p);
974 ++ } else if (width & 1) {
975 ++ fb_writew(*(u16 *)q, (u16 *)p);
976 ++ fb_writeb(*(u8 *)((u16 *)q + 1),
977 ++ (u8 *)((u16 *)p + 2));
978 ++ }
979 ++ }
980 ++ break;
981 ++ case 16:
982 ++ for (i = 0; i < width/4; i++) {
983 ++ fb_writel(*q++, p++);
984 ++ fb_writel(*q++, p++);
985 ++ }
986 ++ if (width & 2)
987 ++ fb_writel(*q++, p++);
988 ++ if (width & 1)
989 ++ fb_writew(*(u16 *)q, (u16 *)p);
990 ++ break;
991 ++ case 8:
992 ++ for (i = 0; i < width/4; i++)
993 ++ fb_writel(*q++, p++);
994 ++
995 ++ if (width & 2) {
996 ++ fb_writew(*(u16 *)q, (u16 *)p);
997 ++ q = (u32 *) ((u16 *)q + 1);
998 ++ p = (u32 *) ((u16 *)p + 1);
999 ++ }
1000 ++ if (width & 1)
1001 ++ fb_writeb(*(u8 *)q, (u8 *)p);
1002 ++ break;
1003 ++ }
1004 ++
1005 ++ dst += linebytes;
1006 ++ src += srclinebytes;
1007 ++ }
1008 ++}
1009 ++
1010 ++static void decorfill(struct fb_info *info, int sy, int sx, int height,
1011 ++ int width)
1012 ++{
1013 ++ int bytespp = ((info->var.bits_per_pixel + 7) >> 3);
1014 ++ int d = sy * info->fix.line_length + sx * bytespp;
1015 ++ int ds = (sy * info->var.xres + sx) * bytespp;
1016 ++
1017 ++ fbcon_decor_copy((u8 *)(info->screen_base + d), (u8 *)(info->bgdecor.data + ds),
1018 ++ height, width, info->fix.line_length, info->var.xres * bytespp,
1019 ++ info->var.bits_per_pixel);
1020 ++}
1021 ++
1022 ++void fbcon_decor_clear(struct vc_data *vc, struct fb_info *info, int sy, int sx,
1023 ++ int height, int width)
1024 ++{
1025 ++ int bgshift = (vc->vc_hi_font_mask) ? 13 : 12;
1026 ++ struct fbcon_ops *ops = info->fbcon_par;
1027 ++ u8 *dst;
1028 ++ int transparent, bg_color = attr_bgcol_ec(bgshift, vc, info);
1029 ++
1030 ++ transparent = (vc->vc_decor.bg_color == bg_color);
1031 ++ sy = sy * vc->vc_font.height + vc->vc_decor.ty;
1032 ++ sx = sx * vc->vc_font.width + vc->vc_decor.tx;
1033 ++ height *= vc->vc_font.height;
1034 ++ width *= vc->vc_font.width;
1035 ++
1036 ++ /* Don't paint the background image if console is blanked */
1037 ++ if (transparent && !ops->blank_state) {
1038 ++ decorfill(info, sy, sx, height, width);
1039 ++ } else {
1040 ++ dst = (u8 *)(info->screen_base + sy * info->fix.line_length +
1041 ++ sx * ((info->var.bits_per_pixel + 7) >> 3));
1042 ++ decorset(dst, height, width, info->fix.line_length, cc2cx(bg_color),
1043 ++ info->var.bits_per_pixel);
1044 ++ }
1045 ++}
1046 ++
1047 ++void fbcon_decor_clear_margins(struct vc_data *vc, struct fb_info *info,
1048 ++ int bottom_only)
1049 ++{
1050 ++ unsigned int tw = vc->vc_cols*vc->vc_font.width;
1051 ++ unsigned int th = vc->vc_rows*vc->vc_font.height;
1052 ++
1053 ++ if (!bottom_only) {
1054 ++ /* top margin */
1055 ++ decorfill(info, 0, 0, vc->vc_decor.ty, info->var.xres);
1056 ++ /* left margin */
1057 ++ decorfill(info, vc->vc_decor.ty, 0, th, vc->vc_decor.tx);
1058 ++ /* right margin */
1059 ++ decorfill(info, vc->vc_decor.ty, vc->vc_decor.tx + tw, th,
1060 ++ info->var.xres - vc->vc_decor.tx - tw);
1061 ++ }
1062 ++ decorfill(info, vc->vc_decor.ty + th, 0,
1063 ++ info->var.yres - vc->vc_decor.ty - th, info->var.xres);
1064 ++}
1065 ++
1066 ++void fbcon_decor_bmove_redraw(struct vc_data *vc, struct fb_info *info, int y,
1067 ++ int sx, int dx, int width)
1068 ++{
1069 ++ u16 *d = (u16 *) (vc->vc_origin + vc->vc_size_row * y + dx * 2);
1070 ++ u16 *s = d + (dx - sx);
1071 ++ u16 *start = d;
1072 ++ u16 *ls = d;
1073 ++ u16 *le = d + width;
1074 ++ u16 c;
1075 ++ int x = dx;
1076 ++ u16 attr = 1;
1077 ++
1078 ++ do {
1079 ++ c = scr_readw(d);
1080 ++ if (attr != (c & 0xff00)) {
1081 ++ attr = c & 0xff00;
1082 ++ if (d > start) {
1083 ++ fbcon_decor_putcs(vc, info, start, d - start, y, x);
1084 ++ x += d - start;
1085 ++ start = d;
1086 ++ }
1087 ++ }
1088 ++ if (s >= ls && s < le && c == scr_readw(s)) {
1089 ++ if (d > start) {
1090 ++ fbcon_decor_putcs(vc, info, start, d - start, y, x);
1091 ++ x += d - start + 1;
1092 ++ start = d + 1;
1093 ++ } else {
1094 ++ x++;
1095 ++ start++;
1096 ++ }
1097 ++ }
1098 ++ s++;
1099 ++ d++;
1100 ++ } while (d < le);
1101 ++ if (d > start)
1102 ++ fbcon_decor_putcs(vc, info, start, d - start, y, x);
1103 ++}
1104 ++
1105 ++void fbcon_decor_blank(struct vc_data *vc, struct fb_info *info, int blank)
1106 ++{
1107 ++ if (blank) {
1108 ++ decorset((u8 *)info->screen_base, info->var.yres, info->var.xres,
1109 ++ info->fix.line_length, 0, info->var.bits_per_pixel);
1110 ++ } else {
1111 ++ update_screen(vc);
1112 ++ fbcon_decor_clear_margins(vc, info, 0);
1113 ++ }
1114 ++}
1115 ++
1116 +diff --git a/drivers/video/console/fbcondecor.c b/drivers/video/console/fbcondecor.c
1117 +new file mode 100644
1118 +index 000000000000..78288a497a60
1119 +--- /dev/null
1120 ++++ b/drivers/video/console/fbcondecor.c
1121 +@@ -0,0 +1,549 @@
1122 ++/*
1123 ++ * linux/drivers/video/console/fbcondecor.c -- Framebuffer console decorations
1124 ++ *
1125 ++ * Copyright (C) 2004-2009 Michal Januszewski <michalj+fbcondecor@×××××.com>
1126 ++ *
1127 ++ * Code based upon "Bootsplash" (C) 2001-2003
1128 ++ * Volker Poplawski <volker@×××××××××.de>,
1129 ++ * Stefan Reinauer <stepan@××××.de>,
1130 ++ * Steffen Winterfeldt <snwint@××××.de>,
1131 ++ * Michael Schroeder <mls@××××.de>,
1132 ++ * Ken Wimer <wimer@××××.de>.
1133 ++ *
1134 ++ * Compat ioctl support by Thorsten Klein <TK@××××××××××××××.de>.
1135 ++ *
1136 ++ * This file is subject to the terms and conditions of the GNU General Public
1137 ++ * License. See the file COPYING in the main directory of this archive for
1138 ++ * more details.
1139 ++ *
1140 ++ */
1141 ++#include <linux/module.h>
1142 ++#include <linux/kernel.h>
1143 ++#include <linux/string.h>
1144 ++#include <linux/types.h>
1145 ++#include <linux/fb.h>
1146 ++#include <linux/vt_kern.h>
1147 ++#include <linux/vmalloc.h>
1148 ++#include <linux/unistd.h>
1149 ++#include <linux/syscalls.h>
1150 ++#include <linux/init.h>
1151 ++#include <linux/proc_fs.h>
1152 ++#include <linux/workqueue.h>
1153 ++#include <linux/kmod.h>
1154 ++#include <linux/miscdevice.h>
1155 ++#include <linux/device.h>
1156 ++#include <linux/fs.h>
1157 ++#include <linux/compat.h>
1158 ++#include <linux/console.h>
1159 ++#include <linux/binfmts.h>
1160 ++#include <linux/uaccess.h>
1161 ++#include <asm/irq.h>
1162 ++
1163 ++#include "../fbdev/core/fbcon.h"
1164 ++#include "fbcondecor.h"
1165 ++
1166 ++extern signed char con2fb_map[];
1167 ++static int fbcon_decor_enable(struct vc_data *vc);
1168 ++
1169 ++static int initialized;
1170 ++
1171 ++char fbcon_decor_path[KMOD_PATH_LEN] = "/sbin/fbcondecor_helper";
1172 ++EXPORT_SYMBOL(fbcon_decor_path);
1173 ++
1174 ++int fbcon_decor_call_helper(char *cmd, unsigned short vc)
1175 ++{
1176 ++ char *envp[] = {
1177 ++ "HOME=/",
1178 ++ "PATH=/sbin:/bin",
1179 ++ NULL
1180 ++ };
1181 ++
1182 ++ char tfb[5];
1183 ++ char tcons[5];
1184 ++ unsigned char fb = (int) con2fb_map[vc];
1185 ++
1186 ++ char *argv[] = {
1187 ++ fbcon_decor_path,
1188 ++ "2",
1189 ++ cmd,
1190 ++ tcons,
1191 ++ tfb,
1192 ++ vc_cons[vc].d->vc_decor.theme,
1193 ++ NULL
1194 ++ };
1195 ++
1196 ++ snprintf(tfb, 5, "%d", fb);
1197 ++ snprintf(tcons, 5, "%d", vc);
1198 ++
1199 ++ return call_usermodehelper(fbcon_decor_path, argv, envp, UMH_WAIT_EXEC);
1200 ++}
1201 ++
1202 ++/* Disables fbcondecor on a virtual console; called with console sem held. */
1203 ++int fbcon_decor_disable(struct vc_data *vc, unsigned char redraw)
1204 ++{
1205 ++ struct fb_info *info;
1206 ++
1207 ++ if (!vc->vc_decor.state)
1208 ++ return -EINVAL;
1209 ++
1210 ++ info = registered_fb[(int) con2fb_map[vc->vc_num]];
1211 ++
1212 ++ if (info == NULL)
1213 ++ return -EINVAL;
1214 ++
1215 ++ vc->vc_decor.state = 0;
1216 ++ vc_resize(vc, info->var.xres / vc->vc_font.width,
1217 ++ info->var.yres / vc->vc_font.height);
1218 ++
1219 ++ if (fg_console == vc->vc_num && redraw) {
1220 ++ redraw_screen(vc, 0);
1221 ++ update_region(vc, vc->vc_origin +
1222 ++ vc->vc_size_row * vc->vc_top,
1223 ++ vc->vc_size_row * (vc->vc_bottom - vc->vc_top) / 2);
1224 ++ }
1225 ++
1226 ++ printk(KERN_INFO "fbcondecor: switched decor state to 'off' on console %d\n",
1227 ++ vc->vc_num);
1228 ++
1229 ++ return 0;
1230 ++}
1231 ++
1232 ++/* Enables fbcondecor on a virtual console; called with console sem held. */
1233 ++static int fbcon_decor_enable(struct vc_data *vc)
1234 ++{
1235 ++ struct fb_info *info;
1236 ++
1237 ++ info = registered_fb[(int) con2fb_map[vc->vc_num]];
1238 ++
1239 ++ if (vc->vc_decor.twidth == 0 || vc->vc_decor.theight == 0 ||
1240 ++ info == NULL || vc->vc_decor.state || (!info->bgdecor.data &&
1241 ++ vc->vc_num == fg_console))
1242 ++ return -EINVAL;
1243 ++
1244 ++ vc->vc_decor.state = 1;
1245 ++ vc_resize(vc, vc->vc_decor.twidth / vc->vc_font.width,
1246 ++ vc->vc_decor.theight / vc->vc_font.height);
1247 ++
1248 ++ if (fg_console == vc->vc_num) {
1249 ++ redraw_screen(vc, 0);
1250 ++ update_region(vc, vc->vc_origin +
1251 ++ vc->vc_size_row * vc->vc_top,
1252 ++ vc->vc_size_row * (vc->vc_bottom - vc->vc_top) / 2);
1253 ++ fbcon_decor_clear_margins(vc, info, 0);
1254 ++ }
1255 ++
1256 ++ printk(KERN_INFO "fbcondecor: switched decor state to 'on' on console %d\n",
1257 ++ vc->vc_num);
1258 ++
1259 ++ return 0;
1260 ++}
1261 ++
1262 ++static inline int fbcon_decor_ioctl_dosetstate(struct vc_data *vc, unsigned int state, unsigned char origin)
1263 ++{
1264 ++ int ret;
1265 ++
1266 ++ console_lock();
1267 ++ if (!state)
1268 ++ ret = fbcon_decor_disable(vc, 1);
1269 ++ else
1270 ++ ret = fbcon_decor_enable(vc);
1271 ++ console_unlock();
1272 ++
1273 ++ return ret;
1274 ++}
1275 ++
1276 ++static inline void fbcon_decor_ioctl_dogetstate(struct vc_data *vc, unsigned int *state)
1277 ++{
1278 ++ *state = vc->vc_decor.state;
1279 ++}
1280 ++
1281 ++static int fbcon_decor_ioctl_dosetcfg(struct vc_data *vc, struct vc_decor *cfg, unsigned char origin)
1282 ++{
1283 ++ struct fb_info *info;
1284 ++ int len;
1285 ++ char *tmp;
1286 ++
1287 ++ info = registered_fb[(int) con2fb_map[vc->vc_num]];
1288 ++
1289 ++ if (info == NULL || !cfg->twidth || !cfg->theight ||
1290 ++ cfg->tx + cfg->twidth > info->var.xres ||
1291 ++ cfg->ty + cfg->theight > info->var.yres)
1292 ++ return -EINVAL;
1293 ++
1294 ++ len = strnlen_user(cfg->theme, MAX_ARG_STRLEN);
1295 ++ if (!len || len > FBCON_DECOR_THEME_LEN)
1296 ++ return -EINVAL;
1297 ++ tmp = kmalloc(len, GFP_KERNEL);
1298 ++ if (!tmp)
1299 ++ return -ENOMEM;
1300 ++ if (copy_from_user(tmp, (void __user *)cfg->theme, len))
1301 ++ return -EFAULT;
1302 ++ cfg->theme = tmp;
1303 ++ cfg->state = 0;
1304 ++
1305 ++ console_lock();
1306 ++ if (vc->vc_decor.state)
1307 ++ fbcon_decor_disable(vc, 1);
1308 ++ kfree(vc->vc_decor.theme);
1309 ++ vc->vc_decor = *cfg;
1310 ++ console_unlock();
1311 ++
1312 ++ printk(KERN_INFO "fbcondecor: console %d using theme '%s'\n",
1313 ++ vc->vc_num, vc->vc_decor.theme);
1314 ++ return 0;
1315 ++}
1316 ++
1317 ++static int fbcon_decor_ioctl_dogetcfg(struct vc_data *vc,
1318 ++ struct vc_decor *decor)
1319 ++{
1320 ++ char __user *tmp;
1321 ++
1322 ++ tmp = decor->theme;
1323 ++ *decor = vc->vc_decor;
1324 ++ decor->theme = tmp;
1325 ++
1326 ++ if (vc->vc_decor.theme) {
1327 ++ if (copy_to_user(tmp, vc->vc_decor.theme,
1328 ++ strlen(vc->vc_decor.theme) + 1))
1329 ++ return -EFAULT;
1330 ++ } else
1331 ++ if (put_user(0, tmp))
1332 ++ return -EFAULT;
1333 ++
1334 ++ return 0;
1335 ++}
1336 ++
1337 ++static int fbcon_decor_ioctl_dosetpic(struct vc_data *vc, struct fb_image *img,
1338 ++ unsigned char origin)
1339 ++{
1340 ++ struct fb_info *info;
1341 ++ int len;
1342 ++ u8 *tmp;
1343 ++
1344 ++ if (vc->vc_num != fg_console)
1345 ++ return -EINVAL;
1346 ++
1347 ++ info = registered_fb[(int) con2fb_map[vc->vc_num]];
1348 ++
1349 ++ if (info == NULL)
1350 ++ return -EINVAL;
1351 ++
1352 ++ if (img->width != info->var.xres || img->height != info->var.yres) {
1353 ++ printk(KERN_ERR "fbcondecor: picture dimensions mismatch\n");
1354 ++ printk(KERN_ERR "%dx%d vs %dx%d\n", img->width, img->height,
1355 ++ info->var.xres, info->var.yres);
1356 ++ return -EINVAL;
1357 ++ }
1358 ++
1359 ++ if (img->depth != info->var.bits_per_pixel) {
1360 ++ printk(KERN_ERR "fbcondecor: picture depth mismatch\n");
1361 ++ return -EINVAL;
1362 ++ }
1363 ++
1364 ++ if (img->depth == 8) {
1365 ++ if (!img->cmap.len || !img->cmap.red || !img->cmap.green ||
1366 ++ !img->cmap.blue)
1367 ++ return -EINVAL;
1368 ++
1369 ++ tmp = vmalloc(img->cmap.len * 3 * 2);
1370 ++ if (!tmp)
1371 ++ return -ENOMEM;
1372 ++
1373 ++ if (copy_from_user(tmp,
1374 ++ (void __user *)img->cmap.red,
1375 ++ (img->cmap.len << 1)) ||
1376 ++ copy_from_user(tmp + (img->cmap.len << 1),
1377 ++ (void __user *)img->cmap.green,
1378 ++ (img->cmap.len << 1)) ||
1379 ++ copy_from_user(tmp + (img->cmap.len << 2),
1380 ++ (void __user *)img->cmap.blue,
1381 ++ (img->cmap.len << 1))) {
1382 ++ vfree(tmp);
1383 ++ return -EFAULT;
1384 ++ }
1385 ++
1386 ++ img->cmap.transp = NULL;
1387 ++ img->cmap.red = (u16 *)tmp;
1388 ++ img->cmap.green = img->cmap.red + img->cmap.len;
1389 ++ img->cmap.blue = img->cmap.green + img->cmap.len;
1390 ++ } else {
1391 ++ img->cmap.red = NULL;
1392 ++ }
1393 ++
1394 ++ len = ((img->depth + 7) >> 3) * img->width * img->height;
1395 ++
1396 ++ /*
1397 ++ * Allocate an additional byte so that we never go outside of the
1398 ++ * buffer boundaries in the rendering functions in a 24 bpp mode.
1399 ++ */
1400 ++ tmp = vmalloc(len + 1);
1401 ++
1402 ++ if (!tmp)
1403 ++ goto out;
1404 ++
1405 ++ if (copy_from_user(tmp, (void __user *)img->data, len))
1406 ++ goto out;
1407 ++
1408 ++ img->data = tmp;
1409 ++
1410 ++ console_lock();
1411 ++
1412 ++ if (info->bgdecor.data)
1413 ++ vfree((u8 *)info->bgdecor.data);
1414 ++ if (info->bgdecor.cmap.red)
1415 ++ vfree(info->bgdecor.cmap.red);
1416 ++
1417 ++ info->bgdecor = *img;
1418 ++
1419 ++ if (fbcon_decor_active_vc(vc) && fg_console == vc->vc_num) {
1420 ++ redraw_screen(vc, 0);
1421 ++ update_region(vc, vc->vc_origin +
1422 ++ vc->vc_size_row * vc->vc_top,
1423 ++ vc->vc_size_row * (vc->vc_bottom - vc->vc_top) / 2);
1424 ++ fbcon_decor_clear_margins(vc, info, 0);
1425 ++ }
1426 ++
1427 ++ console_unlock();
1428 ++
1429 ++ return 0;
1430 ++
1431 ++out:
1432 ++ if (img->cmap.red)
1433 ++ vfree(img->cmap.red);
1434 ++
1435 ++ if (tmp)
1436 ++ vfree(tmp);
1437 ++ return -ENOMEM;
1438 ++}
1439 ++
1440 ++static long fbcon_decor_ioctl(struct file *filp, u_int cmd, u_long arg)
1441 ++{
1442 ++ struct fbcon_decor_iowrapper __user *wrapper = (void __user *) arg;
1443 ++ struct vc_data *vc = NULL;
1444 ++ unsigned short vc_num = 0;
1445 ++ unsigned char origin = 0;
1446 ++ void __user *data = NULL;
1447 ++
1448 ++ if (!access_ok(VERIFY_READ, wrapper,
1449 ++ sizeof(struct fbcon_decor_iowrapper)))
1450 ++ return -EFAULT;
1451 ++
1452 ++ __get_user(vc_num, &wrapper->vc);
1453 ++ __get_user(origin, &wrapper->origin);
1454 ++ __get_user(data, &wrapper->data);
1455 ++
1456 ++ if (!vc_cons_allocated(vc_num))
1457 ++ return -EINVAL;
1458 ++
1459 ++ vc = vc_cons[vc_num].d;
1460 ++
1461 ++ switch (cmd) {
1462 ++ case FBIOCONDECOR_SETPIC:
1463 ++ {
1464 ++ struct fb_image img;
1465 ++
1466 ++ if (copy_from_user(&img, (struct fb_image __user *)data, sizeof(struct fb_image)))
1467 ++ return -EFAULT;
1468 ++
1469 ++ return fbcon_decor_ioctl_dosetpic(vc, &img, origin);
1470 ++ }
1471 ++ case FBIOCONDECOR_SETCFG:
1472 ++ {
1473 ++ struct vc_decor cfg;
1474 ++
1475 ++ if (copy_from_user(&cfg, (struct vc_decor __user *)data, sizeof(struct vc_decor)))
1476 ++ return -EFAULT;
1477 ++
1478 ++ return fbcon_decor_ioctl_dosetcfg(vc, &cfg, origin);
1479 ++ }
1480 ++ case FBIOCONDECOR_GETCFG:
1481 ++ {
1482 ++ int rval;
1483 ++ struct vc_decor cfg;
1484 ++
1485 ++ if (copy_from_user(&cfg, (struct vc_decor __user *)data, sizeof(struct vc_decor)))
1486 ++ return -EFAULT;
1487 ++
1488 ++ rval = fbcon_decor_ioctl_dogetcfg(vc, &cfg);
1489 ++
1490 ++ if (copy_to_user(data, &cfg, sizeof(struct vc_decor)))
1491 ++ return -EFAULT;
1492 ++ return rval;
1493 ++ }
1494 ++ case FBIOCONDECOR_SETSTATE:
1495 ++ {
1496 ++ unsigned int state = 0;
1497 ++
1498 ++ if (get_user(state, (unsigned int __user *)data))
1499 ++ return -EFAULT;
1500 ++ return fbcon_decor_ioctl_dosetstate(vc, state, origin);
1501 ++ }
1502 ++ case FBIOCONDECOR_GETSTATE:
1503 ++ {
1504 ++ unsigned int state = 0;
1505 ++
1506 ++ fbcon_decor_ioctl_dogetstate(vc, &state);
1507 ++ return put_user(state, (unsigned int __user *)data);
1508 ++ }
1509 ++
1510 ++ default:
1511 ++ return -ENOIOCTLCMD;
1512 ++ }
1513 ++}
1514 ++
1515 ++#ifdef CONFIG_COMPAT
1516 ++
1517 ++static long fbcon_decor_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
1518 ++{
1519 ++ struct fbcon_decor_iowrapper32 __user *wrapper = (void __user *)arg;
1520 ++ struct vc_data *vc = NULL;
1521 ++ unsigned short vc_num = 0;
1522 ++ unsigned char origin = 0;
1523 ++ compat_uptr_t data_compat = 0;
1524 ++ void __user *data = NULL;
1525 ++
1526 ++ if (!access_ok(VERIFY_READ, wrapper,
1527 ++ sizeof(struct fbcon_decor_iowrapper32)))
1528 ++ return -EFAULT;
1529 ++
1530 ++ __get_user(vc_num, &wrapper->vc);
1531 ++ __get_user(origin, &wrapper->origin);
1532 ++ __get_user(data_compat, &wrapper->data);
1533 ++ data = compat_ptr(data_compat);
1534 ++
1535 ++ if (!vc_cons_allocated(vc_num))
1536 ++ return -EINVAL;
1537 ++
1538 ++ vc = vc_cons[vc_num].d;
1539 ++
1540 ++ switch (cmd) {
1541 ++ case FBIOCONDECOR_SETPIC32:
1542 ++ {
1543 ++ struct fb_image32 img_compat;
1544 ++ struct fb_image img;
1545 ++
1546 ++ if (copy_from_user(&img_compat, (struct fb_image32 __user *)data, sizeof(struct fb_image32)))
1547 ++ return -EFAULT;
1548 ++
1549 ++ fb_image_from_compat(img, img_compat);
1550 ++
1551 ++ return fbcon_decor_ioctl_dosetpic(vc, &img, origin);
1552 ++ }
1553 ++
1554 ++ case FBIOCONDECOR_SETCFG32:
1555 ++ {
1556 ++ struct vc_decor32 cfg_compat;
1557 ++ struct vc_decor cfg;
1558 ++
1559 ++ if (copy_from_user(&cfg_compat, (struct vc_decor32 __user *)data, sizeof(struct vc_decor32)))
1560 ++ return -EFAULT;
1561 ++
1562 ++ vc_decor_from_compat(cfg, cfg_compat);
1563 ++
1564 ++ return fbcon_decor_ioctl_dosetcfg(vc, &cfg, origin);
1565 ++ }
1566 ++
1567 ++ case FBIOCONDECOR_GETCFG32:
1568 ++ {
1569 ++ int rval;
1570 ++ struct vc_decor32 cfg_compat;
1571 ++ struct vc_decor cfg;
1572 ++
1573 ++ if (copy_from_user(&cfg_compat, (struct vc_decor32 __user *)data, sizeof(struct vc_decor32)))
1574 ++ return -EFAULT;
1575 ++ cfg.theme = compat_ptr(cfg_compat.theme);
1576 ++
1577 ++ rval = fbcon_decor_ioctl_dogetcfg(vc, &cfg);
1578 ++
1579 ++ vc_decor_to_compat(cfg_compat, cfg);
1580 ++
1581 ++ if (copy_to_user((struct vc_decor32 __user *)data, &cfg_compat, sizeof(struct vc_decor32)))
1582 ++ return -EFAULT;
1583 ++ return rval;
1584 ++ }
1585 ++
1586 ++ case FBIOCONDECOR_SETSTATE32:
1587 ++ {
1588 ++ compat_uint_t state_compat = 0;
1589 ++ unsigned int state = 0;
1590 ++
1591 ++ if (get_user(state_compat, (compat_uint_t __user *)data))
1592 ++ return -EFAULT;
1593 ++
1594 ++ state = (unsigned int)state_compat;
1595 ++
1596 ++ return fbcon_decor_ioctl_dosetstate(vc, state, origin);
1597 ++ }
1598 ++
1599 ++ case FBIOCONDECOR_GETSTATE32:
1600 ++ {
1601 ++ compat_uint_t state_compat = 0;
1602 ++ unsigned int state = 0;
1603 ++
1604 ++ fbcon_decor_ioctl_dogetstate(vc, &state);
1605 ++ state_compat = (compat_uint_t)state;
1606 ++
1607 ++ return put_user(state_compat, (compat_uint_t __user *)data);
1608 ++ }
1609 ++
1610 ++ default:
1611 ++ return -ENOIOCTLCMD;
1612 ++ }
1613 ++}
1614 ++#else
1615 ++ #define fbcon_decor_compat_ioctl NULL
1616 ++#endif
1617 ++
1618 ++static struct file_operations fbcon_decor_ops = {
1619 ++ .owner = THIS_MODULE,
1620 ++ .unlocked_ioctl = fbcon_decor_ioctl,
1621 ++ .compat_ioctl = fbcon_decor_compat_ioctl
1622 ++};
1623 ++
1624 ++static struct miscdevice fbcon_decor_dev = {
1625 ++ .minor = MISC_DYNAMIC_MINOR,
1626 ++ .name = "fbcondecor",
1627 ++ .fops = &fbcon_decor_ops
1628 ++};
1629 ++
1630 ++void fbcon_decor_reset(void)
1631 ++{
1632 ++ int i;
1633 ++
1634 ++ for (i = 0; i < num_registered_fb; i++) {
1635 ++ registered_fb[i]->bgdecor.data = NULL;
1636 ++ registered_fb[i]->bgdecor.cmap.red = NULL;
1637 ++ }
1638 ++
1639 ++ for (i = 0; i < MAX_NR_CONSOLES && vc_cons[i].d; i++) {
1640 ++ vc_cons[i].d->vc_decor.state = vc_cons[i].d->vc_decor.twidth =
1641 ++ vc_cons[i].d->vc_decor.theight = 0;
1642 ++ vc_cons[i].d->vc_decor.theme = NULL;
1643 ++ }
1644 ++}
1645 ++
1646 ++int fbcon_decor_init(void)
1647 ++{
1648 ++ int i;
1649 ++
1650 ++ fbcon_decor_reset();
1651 ++
1652 ++ if (initialized)
1653 ++ return 0;
1654 ++
1655 ++ i = misc_register(&fbcon_decor_dev);
1656 ++ if (i) {
1657 ++ printk(KERN_ERR "fbcondecor: failed to register device\n");
1658 ++ return i;
1659 ++ }
1660 ++
1661 ++ fbcon_decor_call_helper("init", 0);
1662 ++ initialized = 1;
1663 ++ return 0;
1664 ++}
1665 ++
1666 ++int fbcon_decor_exit(void)
1667 ++{
1668 ++ fbcon_decor_reset();
1669 ++ return 0;
1670 ++}
1671 +diff --git a/drivers/video/console/fbcondecor.h b/drivers/video/console/fbcondecor.h
1672 +new file mode 100644
1673 +index 000000000000..c49386c16695
1674 +--- /dev/null
1675 ++++ b/drivers/video/console/fbcondecor.h
1676 +@@ -0,0 +1,77 @@
1677 ++/*
1678 ++ * linux/drivers/video/console/fbcondecor.h -- Framebuffer Console Decoration headers
1679 ++ *
1680 ++ * Copyright (C) 2004 Michal Januszewski <michalj+fbcondecor@×××××.com>
1681 ++ *
1682 ++ */
1683 ++
1684 ++#ifndef __FBCON_DECOR_H
1685 ++#define __FBCON_DECOR_H
1686 ++
1687 ++#ifndef _LINUX_FB_H
1688 ++#include <linux/fb.h>
1689 ++#endif
1690 ++
1691 ++/* This is needed for vc_cons in fbcmap.c */
1692 ++#include <linux/vt_kern.h>
1693 ++
1694 ++struct fb_cursor;
1695 ++struct fb_info;
1696 ++struct vc_data;
1697 ++
1698 ++#ifdef CONFIG_FB_CON_DECOR
1699 ++/* fbcondecor.c */
1700 ++int fbcon_decor_init(void);
1701 ++int fbcon_decor_exit(void);
1702 ++int fbcon_decor_call_helper(char *cmd, unsigned short cons);
1703 ++int fbcon_decor_disable(struct vc_data *vc, unsigned char redraw);
1704 ++
1705 ++/* cfbcondecor.c */
1706 ++void fbcon_decor_putcs(struct vc_data *vc, struct fb_info *info, const unsigned short *s, int count, int yy, int xx);
1707 ++void fbcon_decor_cursor(struct fb_info *info, struct fb_cursor *cursor);
1708 ++void fbcon_decor_clear(struct vc_data *vc, struct fb_info *info, int sy, int sx, int height, int width);
1709 ++void fbcon_decor_clear_margins(struct vc_data *vc, struct fb_info *info, int bottom_only);
1710 ++void fbcon_decor_blank(struct vc_data *vc, struct fb_info *info, int blank);
1711 ++void fbcon_decor_bmove_redraw(struct vc_data *vc, struct fb_info *info, int y, int sx, int dx, int width);
1712 ++void fbcon_decor_copy(u8 *dst, u8 *src, int height, int width, int linebytes, int srclinesbytes, int bpp);
1713 ++void fbcon_decor_fix_pseudo_pal(struct fb_info *info, struct vc_data *vc);
1714 ++
1715 ++/* vt.c */
1716 ++void acquire_console_sem(void);
1717 ++void release_console_sem(void);
1718 ++void do_unblank_screen(int entering_gfx);
1719 ++
1720 ++/* struct vc_data *y */
1721 ++#define fbcon_decor_active_vc(y) (y->vc_decor.state && y->vc_decor.theme)
1722 ++
1723 ++/* struct fb_info *x, struct vc_data *y */
1724 ++#define fbcon_decor_active_nores(x, y) (x->bgdecor.data && fbcon_decor_active_vc(y))
1725 ++
1726 ++/* struct fb_info *x, struct vc_data *y */
1727 ++#define fbcon_decor_active(x, y) (fbcon_decor_active_nores(x, y) && \
1728 ++ x->bgdecor.width == x->var.xres && \
1729 ++ x->bgdecor.height == x->var.yres && \
1730 ++ x->bgdecor.depth == x->var.bits_per_pixel)
1731 ++
1732 ++#else /* CONFIG_FB_CON_DECOR */
1733 ++
1734 ++static inline void fbcon_decor_putcs(struct vc_data *vc, struct fb_info *info, const unsigned short *s, int count, int yy, int xx) {}
1735 ++static inline void fbcon_decor_putc(struct vc_data *vc, struct fb_info *info, int c, int ypos, int xpos) {}
1736 ++static inline void fbcon_decor_cursor(struct fb_info *info, struct fb_cursor *cursor) {}
1737 ++static inline void fbcon_decor_clear(struct vc_data *vc, struct fb_info *info, int sy, int sx, int height, int width) {}
1738 ++static inline void fbcon_decor_clear_margins(struct vc_data *vc, struct fb_info *info, int bottom_only) {}
1739 ++static inline void fbcon_decor_blank(struct vc_data *vc, struct fb_info *info, int blank) {}
1740 ++static inline void fbcon_decor_bmove_redraw(struct vc_data *vc, struct fb_info *info, int y, int sx, int dx, int width) {}
1741 ++static inline void fbcon_decor_fix_pseudo_pal(struct fb_info *info, struct vc_data *vc) {}
1742 ++static inline int fbcon_decor_call_helper(char *cmd, unsigned short cons) { return 0; }
1743 ++static inline int fbcon_decor_init(void) { return 0; }
1744 ++static inline int fbcon_decor_exit(void) { return 0; }
1745 ++static inline int fbcon_decor_disable(struct vc_data *vc, unsigned char redraw) { return 0; }
1746 ++
1747 ++#define fbcon_decor_active_vc(y) (0)
1748 ++#define fbcon_decor_active_nores(x, y) (0)
1749 ++#define fbcon_decor_active(x, y) (0)
1750 ++
1751 ++#endif /* CONFIG_FB_CON_DECOR */
1752 ++
1753 ++#endif /* __FBCON_DECOR_H */
1754 +diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig
1755 +index 5e58f5ec0a28..1daa8c2cb2d8 100644
1756 +--- a/drivers/video/fbdev/Kconfig
1757 ++++ b/drivers/video/fbdev/Kconfig
1758 +@@ -1226,7 +1226,6 @@ config FB_MATROX
1759 + select FB_CFB_FILLRECT
1760 + select FB_CFB_COPYAREA
1761 + select FB_CFB_IMAGEBLIT
1762 +- select FB_TILEBLITTING
1763 + select FB_MACMODES if PPC_PMAC
1764 + ---help---
1765 + Say Y here if you have a Matrox Millennium, Matrox Millennium II,
1766 +diff --git a/drivers/video/fbdev/core/bitblit.c b/drivers/video/fbdev/core/bitblit.c
1767 +index 790900d646c0..3f940c93752c 100644
1768 +--- a/drivers/video/fbdev/core/bitblit.c
1769 ++++ b/drivers/video/fbdev/core/bitblit.c
1770 +@@ -18,6 +18,7 @@
1771 + #include <linux/console.h>
1772 + #include <asm/types.h>
1773 + #include "fbcon.h"
1774 ++#include "../../console/fbcondecor.h"
1775 +
1776 + /*
1777 + * Accelerated handlers.
1778 +@@ -55,6 +56,13 @@ static void bit_bmove(struct vc_data *vc, struct fb_info *info, int sy,
1779 + area.height = height * vc->vc_font.height;
1780 + area.width = width * vc->vc_font.width;
1781 +
1782 ++ if (fbcon_decor_active(info, vc)) {
1783 ++ area.sx += vc->vc_decor.tx;
1784 ++ area.sy += vc->vc_decor.ty;
1785 ++ area.dx += vc->vc_decor.tx;
1786 ++ area.dy += vc->vc_decor.ty;
1787 ++ }
1788 ++
1789 + info->fbops->fb_copyarea(info, &area);
1790 + }
1791 +
1792 +@@ -379,11 +387,15 @@ static void bit_cursor(struct vc_data *vc, struct fb_info *info, int mode,
1793 + cursor.image.depth = 1;
1794 + cursor.rop = ROP_XOR;
1795 +
1796 +- if (info->fbops->fb_cursor)
1797 +- err = info->fbops->fb_cursor(info, &cursor);
1798 ++ if (fbcon_decor_active(info, vc)) {
1799 ++ fbcon_decor_cursor(info, &cursor);
1800 ++ } else {
1801 ++ if (info->fbops->fb_cursor)
1802 ++ err = info->fbops->fb_cursor(info, &cursor);
1803 +
1804 +- if (err)
1805 +- soft_cursor(info, &cursor);
1806 ++ if (err)
1807 ++ soft_cursor(info, &cursor);
1808 ++ }
1809 +
1810 + ops->cursor_reset = 0;
1811 + }
1812 +diff --git a/drivers/video/fbdev/core/fbcmap.c b/drivers/video/fbdev/core/fbcmap.c
1813 +index 68a113594808..21f977cb59d2 100644
1814 +--- a/drivers/video/fbdev/core/fbcmap.c
1815 ++++ b/drivers/video/fbdev/core/fbcmap.c
1816 +@@ -17,6 +17,8 @@
1817 + #include <linux/slab.h>
1818 + #include <linux/uaccess.h>
1819 +
1820 ++#include "../../console/fbcondecor.h"
1821 ++
1822 + static u16 red2[] __read_mostly = {
1823 + 0x0000, 0xaaaa
1824 + };
1825 +@@ -256,9 +258,12 @@ int fb_set_cmap(struct fb_cmap *cmap, struct fb_info *info)
1826 + break;
1827 + }
1828 + }
1829 +- if (rc == 0)
1830 ++ if (rc == 0) {
1831 + fb_copy_cmap(cmap, &info->cmap);
1832 +-
1833 ++ if (fbcon_decor_active(info, vc_cons[fg_console].d) &&
1834 ++ info->fix.visual == FB_VISUAL_DIRECTCOLOR)
1835 ++ fbcon_decor_fix_pseudo_pal(info, vc_cons[fg_console].d);
1836 ++ }
1837 + return rc;
1838 + }
1839 +
1840 +diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c
1841 +index 04612f938bab..95c349200078 100644
1842 +--- a/drivers/video/fbdev/core/fbcon.c
1843 ++++ b/drivers/video/fbdev/core/fbcon.c
1844 +@@ -80,6 +80,7 @@
1845 + #include <asm/irq.h>
1846 +
1847 + #include "fbcon.h"
1848 ++#include "../../console/fbcondecor.h"
1849 +
1850 + #ifdef FBCONDEBUG
1851 + # define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt, __func__ , ## args)
1852 +@@ -95,7 +96,7 @@ enum {
1853 +
1854 + static struct display fb_display[MAX_NR_CONSOLES];
1855 +
1856 +-static signed char con2fb_map[MAX_NR_CONSOLES];
1857 ++signed char con2fb_map[MAX_NR_CONSOLES];
1858 + static signed char con2fb_map_boot[MAX_NR_CONSOLES];
1859 +
1860 + static int logo_lines;
1861 +@@ -282,7 +283,7 @@ static inline int fbcon_is_inactive(struct vc_data *vc, struct fb_info *info)
1862 + !vt_force_oops_output(vc);
1863 + }
1864 +
1865 +-static int get_color(struct vc_data *vc, struct fb_info *info,
1866 ++int get_color(struct vc_data *vc, struct fb_info *info,
1867 + u16 c, int is_fg)
1868 + {
1869 + int depth = fb_get_color_depth(&info->var, &info->fix);
1870 +@@ -551,6 +552,9 @@ static int do_fbcon_takeover(int show_logo)
1871 + info_idx = -1;
1872 + } else {
1873 + fbcon_has_console_bind = 1;
1874 ++#ifdef CONFIG_FB_CON_DECOR
1875 ++ fbcon_decor_init();
1876 ++#endif
1877 + }
1878 +
1879 + return err;
1880 +@@ -1013,6 +1017,12 @@ static const char *fbcon_startup(void)
1881 + rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
1882 + cols /= vc->vc_font.width;
1883 + rows /= vc->vc_font.height;
1884 ++
1885 ++ if (fbcon_decor_active(info, vc)) {
1886 ++ cols = vc->vc_decor.twidth / vc->vc_font.width;
1887 ++ rows = vc->vc_decor.theight / vc->vc_font.height;
1888 ++ }
1889 ++
1890 + vc_resize(vc, cols, rows);
1891 +
1892 + DPRINTK("mode: %s\n", info->fix.id);
1893 +@@ -1042,7 +1052,7 @@ static void fbcon_init(struct vc_data *vc, int init)
1894 + cap = info->flags;
1895 +
1896 + if (vc != svc || logo_shown == FBCON_LOGO_DONTSHOW ||
1897 +- (info->fix.type == FB_TYPE_TEXT))
1898 ++ (info->fix.type == FB_TYPE_TEXT) || fbcon_decor_active(info, vc))
1899 + logo = 0;
1900 +
1901 + if (var_to_display(p, &info->var, info))
1902 +@@ -1275,6 +1285,11 @@ static void fbcon_clear(struct vc_data *vc, int sy, int sx, int height,
1903 + fbcon_clear_margins(vc, 0);
1904 + }
1905 +
1906 ++ if (fbcon_decor_active(info, vc)) {
1907 ++ fbcon_decor_clear(vc, info, sy, sx, height, width);
1908 ++ return;
1909 ++ }
1910 ++
1911 + /* Split blits that cross physical y_wrap boundary */
1912 +
1913 + y_break = p->vrows - p->yscroll;
1914 +@@ -1294,10 +1309,15 @@ static void fbcon_putcs(struct vc_data *vc, const unsigned short *s,
1915 + struct display *p = &fb_display[vc->vc_num];
1916 + struct fbcon_ops *ops = info->fbcon_par;
1917 +
1918 +- if (!fbcon_is_inactive(vc, info))
1919 +- ops->putcs(vc, info, s, count, real_y(p, ypos), xpos,
1920 +- get_color(vc, info, scr_readw(s), 1),
1921 +- get_color(vc, info, scr_readw(s), 0));
1922 ++ if (!fbcon_is_inactive(vc, info)) {
1923 ++
1924 ++ if (fbcon_decor_active(info, vc))
1925 ++ fbcon_decor_putcs(vc, info, s, count, ypos, xpos);
1926 ++ else
1927 ++ ops->putcs(vc, info, s, count, real_y(p, ypos), xpos,
1928 ++ get_color(vc, info, scr_readw(s), 1),
1929 ++ get_color(vc, info, scr_readw(s), 0));
1930 ++ }
1931 + }
1932 +
1933 + static void fbcon_putc(struct vc_data *vc, int c, int ypos, int xpos)
1934 +@@ -1313,8 +1333,12 @@ static void fbcon_clear_margins(struct vc_data *vc, int bottom_only)
1935 + struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1936 + struct fbcon_ops *ops = info->fbcon_par;
1937 +
1938 +- if (!fbcon_is_inactive(vc, info))
1939 +- ops->clear_margins(vc, info, margin_color, bottom_only);
1940 ++ if (!fbcon_is_inactive(vc, info)) {
1941 ++ if (fbcon_decor_active(info, vc))
1942 ++ fbcon_decor_clear_margins(vc, info, bottom_only);
1943 ++ else
1944 ++ ops->clear_margins(vc, info, margin_color, bottom_only);
1945 ++ }
1946 + }
1947 +
1948 + static void fbcon_cursor(struct vc_data *vc, int mode)
1949 +@@ -1835,7 +1859,7 @@ static bool fbcon_scroll(struct vc_data *vc, unsigned int t, unsigned int b,
1950 + count = vc->vc_rows;
1951 + if (softback_top)
1952 + fbcon_softback_note(vc, t, count);
1953 +- if (logo_shown >= 0)
1954 ++ if (logo_shown >= 0 || fbcon_decor_active(info, vc))
1955 + goto redraw_up;
1956 + switch (p->scrollmode) {
1957 + case SCROLL_MOVE:
1958 +@@ -1928,6 +1952,8 @@ static bool fbcon_scroll(struct vc_data *vc, unsigned int t, unsigned int b,
1959 + count = vc->vc_rows;
1960 + if (logo_shown >= 0)
1961 + goto redraw_down;
1962 ++ if (fbcon_decor_active(info, vc))
1963 ++ goto redraw_down;
1964 + switch (p->scrollmode) {
1965 + case SCROLL_MOVE:
1966 + fbcon_redraw_blit(vc, info, p, b - 1, b - t - count,
1967 +@@ -2076,6 +2102,13 @@ static void fbcon_bmove_rec(struct vc_data *vc, struct display *p, int sy, int s
1968 + }
1969 + return;
1970 + }
1971 ++
1972 ++ if (fbcon_decor_active(info, vc) && sy == dy && height == 1) {
1973 ++ /* must use slower redraw bmove to keep background pic intact */
1974 ++ fbcon_decor_bmove_redraw(vc, info, sy, sx, dx, width);
1975 ++ return;
1976 ++ }
1977 ++
1978 + ops->bmove(vc, info, real_y(p, sy), sx, real_y(p, dy), dx,
1979 + height, width);
1980 + }
1981 +@@ -2146,8 +2179,8 @@ static int fbcon_resize(struct vc_data *vc, unsigned int width,
1982 + var.yres = virt_h * virt_fh;
1983 + x_diff = info->var.xres - var.xres;
1984 + y_diff = info->var.yres - var.yres;
1985 +- if (x_diff < 0 || x_diff > virt_fw ||
1986 +- y_diff < 0 || y_diff > virt_fh) {
1987 ++ if ((x_diff < 0 || x_diff > virt_fw ||
1988 ++ y_diff < 0 || y_diff > virt_fh) && !vc->vc_decor.state) {
1989 + const struct fb_videomode *mode;
1990 +
1991 + DPRINTK("attempting resize %ix%i\n", var.xres, var.yres);
1992 +@@ -2183,6 +2216,22 @@ static int fbcon_switch(struct vc_data *vc)
1993 +
1994 + info = registered_fb[con2fb_map[vc->vc_num]];
1995 + ops = info->fbcon_par;
1996 ++ prev_console = ops->currcon;
1997 ++ if (prev_console != -1)
1998 ++ old_info = registered_fb[con2fb_map[prev_console]];
1999 ++
2000 ++#ifdef CONFIG_FB_CON_DECOR
2001 ++ if (!fbcon_decor_active_vc(vc) && info->fix.visual == FB_VISUAL_DIRECTCOLOR) {
2002 ++ struct vc_data *vc_curr = vc_cons[prev_console].d;
2003 ++
2004 ++ if (vc_curr && fbcon_decor_active_vc(vc_curr)) {
2005 ++ // Clear the screen to avoid displaying funky colors
2006 ++ // during palette updates.
2007 ++ memset((u8 *)info->screen_base + info->fix.line_length * info->var.yoffset,
2008 ++ 0, info->var.yres * info->fix.line_length);
2009 ++ }
2010 ++ }
2011 ++#endif
2012 +
2013 + if (softback_top) {
2014 + if (softback_lines)
2015 +@@ -2201,9 +2250,6 @@ static int fbcon_switch(struct vc_data *vc)
2016 + logo_shown = FBCON_LOGO_CANSHOW;
2017 + }
2018 +
2019 +- prev_console = ops->currcon;
2020 +- if (prev_console != -1)
2021 +- old_info = registered_fb[con2fb_map[prev_console]];
2022 + /*
2023 + * FIXME: If we have multiple fbdev's loaded, we need to
2024 + * update all info->currcon. Perhaps, we can place this
2025 +@@ -2247,6 +2293,18 @@ static int fbcon_switch(struct vc_data *vc)
2026 + fbcon_del_cursor_timer(old_info);
2027 + }
2028 +
2029 ++ if (fbcon_decor_active_vc(vc)) {
2030 ++ struct vc_data *vc_curr = vc_cons[prev_console].d;
2031 ++
2032 ++ if (!vc_curr->vc_decor.theme ||
2033 ++ strcmp(vc->vc_decor.theme, vc_curr->vc_decor.theme) ||
2034 ++ (fbcon_decor_active_nores(info, vc_curr) &&
2035 ++ !fbcon_decor_active(info, vc_curr))) {
2036 ++ fbcon_decor_disable(vc, 0);
2037 ++ fbcon_decor_call_helper("modechange", vc->vc_num);
2038 ++ }
2039 ++ }
2040 ++
2041 + if (fbcon_is_inactive(vc, info) ||
2042 + ops->blank_state != FB_BLANK_UNBLANK)
2043 + fbcon_del_cursor_timer(info);
2044 +@@ -2355,15 +2413,20 @@ static int fbcon_blank(struct vc_data *vc, int blank, int mode_switch)
2045 + }
2046 + }
2047 +
2048 +- if (!fbcon_is_inactive(vc, info)) {
2049 ++ if (!fbcon_is_inactive(vc, info)) {
2050 + if (ops->blank_state != blank) {
2051 + ops->blank_state = blank;
2052 + fbcon_cursor(vc, blank ? CM_ERASE : CM_DRAW);
2053 + ops->cursor_flash = (!blank);
2054 +
2055 +- if (!(info->flags & FBINFO_MISC_USEREVENT))
2056 +- if (fb_blank(info, blank))
2057 +- fbcon_generic_blank(vc, info, blank);
2058 ++ if (!(info->flags & FBINFO_MISC_USEREVENT)) {
2059 ++ if (fb_blank(info, blank)) {
2060 ++ if (fbcon_decor_active(info, vc))
2061 ++ fbcon_decor_blank(vc, info, blank);
2062 ++ else
2063 ++ fbcon_generic_blank(vc, info, blank);
2064 ++ }
2065 ++ }
2066 + }
2067 +
2068 + if (!blank)
2069 +@@ -2546,13 +2609,22 @@ static int fbcon_do_set_font(struct vc_data *vc, int w, int h,
2070 + set_vc_hi_font(vc, true);
2071 +
2072 + if (resize) {
2073 ++ /* reset wrap/pan */
2074 + int cols, rows;
2075 +
2076 + cols = FBCON_SWAP(ops->rotate, info->var.xres, info->var.yres);
2077 + rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
2078 ++
2079 ++ if (fbcon_decor_active(info, vc)) {
2080 ++ info->var.xoffset = info->var.yoffset = p->yscroll = 0;
2081 ++ cols = vc->vc_decor.twidth;
2082 ++ rows = vc->vc_decor.theight;
2083 ++ }
2084 + cols /= w;
2085 + rows /= h;
2086 ++
2087 + vc_resize(vc, cols, rows);
2088 ++
2089 + if (con_is_visible(vc) && softback_buf)
2090 + fbcon_update_softback(vc);
2091 + } else if (con_is_visible(vc)
2092 +@@ -2681,7 +2753,11 @@ static void fbcon_set_palette(struct vc_data *vc, const unsigned char *table)
2093 + int i, j, k, depth;
2094 + u8 val;
2095 +
2096 +- if (fbcon_is_inactive(vc, info))
2097 ++ if (fbcon_is_inactive(vc, info)
2098 ++#ifdef CONFIG_FB_CON_DECOR
2099 ++ || vc->vc_num != fg_console
2100 ++#endif
2101 ++ )
2102 + return;
2103 +
2104 + if (!con_is_visible(vc))
2105 +@@ -2707,7 +2783,47 @@ static void fbcon_set_palette(struct vc_data *vc, const unsigned char *table)
2106 + } else
2107 + fb_copy_cmap(fb_default_cmap(1 << depth), &palette_cmap);
2108 +
2109 +- fb_set_cmap(&palette_cmap, info);
2110 ++ if (fbcon_decor_active(info, vc_cons[fg_console].d) &&
2111 ++ info->fix.visual == FB_VISUAL_DIRECTCOLOR) {
2112 ++
2113 ++ u16 *red, *green, *blue;
2114 ++ int minlen = min(min(info->var.red.length, info->var.green.length),
2115 ++ info->var.blue.length);
2116 ++
2117 ++ struct fb_cmap cmap = {
2118 ++ .start = 0,
2119 ++ .len = (1 << minlen),
2120 ++ .red = NULL,
2121 ++ .green = NULL,
2122 ++ .blue = NULL,
2123 ++ .transp = NULL
2124 ++ };
2125 ++
2126 ++ red = kmalloc(256 * sizeof(u16) * 3, GFP_KERNEL);
2127 ++
2128 ++ if (!red)
2129 ++ goto out;
2130 ++
2131 ++ green = red + 256;
2132 ++ blue = green + 256;
2133 ++ cmap.red = red;
2134 ++ cmap.green = green;
2135 ++ cmap.blue = blue;
2136 ++
2137 ++ for (i = 0; i < cmap.len; i++)
2138 ++ red[i] = green[i] = blue[i] = (0xffff * i)/(cmap.len-1);
2139 ++
2140 ++ fb_set_cmap(&cmap, info);
2141 ++ fbcon_decor_fix_pseudo_pal(info, vc_cons[fg_console].d);
2142 ++ kfree(red);
2143 ++
2144 ++ return;
2145 ++
2146 ++ } else if (fbcon_decor_active(info, vc_cons[fg_console].d) &&
2147 ++ info->var.bits_per_pixel == 8 && info->bgdecor.cmap.red != NULL)
2148 ++ fb_set_cmap(&info->bgdecor.cmap, info);
2149 ++
2150 ++out: fb_set_cmap(&palette_cmap, info);
2151 + }
2152 +
2153 + static u16 *fbcon_screen_pos(struct vc_data *vc, int offset)
2154 +@@ -2932,7 +3048,14 @@ static void fbcon_modechanged(struct fb_info *info)
2155 + rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
2156 + cols /= vc->vc_font.width;
2157 + rows /= vc->vc_font.height;
2158 +- vc_resize(vc, cols, rows);
2159 ++
2160 ++ if (!fbcon_decor_active_nores(info, vc)) {
2161 ++ vc_resize(vc, cols, rows);
2162 ++ } else {
2163 ++ fbcon_decor_disable(vc, 0);
2164 ++ fbcon_decor_call_helper("modechange", vc->vc_num);
2165 ++ }
2166 ++
2167 + updatescrollmode(p, info, vc);
2168 + scrollback_max = 0;
2169 + scrollback_current = 0;
2170 +@@ -2977,7 +3100,8 @@ static void fbcon_set_all_vcs(struct fb_info *info)
2171 + rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
2172 + cols /= vc->vc_font.width;
2173 + rows /= vc->vc_font.height;
2174 +- vc_resize(vc, cols, rows);
2175 ++ if (!fbcon_decor_active_nores(info, vc))
2176 ++ vc_resize(vc, cols, rows);
2177 + }
2178 +
2179 + if (fg != -1)
2180 +@@ -3618,6 +3742,7 @@ static void fbcon_exit(void)
2181 + }
2182 + }
2183 +
2184 ++ fbcon_decor_exit();
2185 + fbcon_has_exited = 1;
2186 + }
2187 +
2188 +diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c
2189 +index f741ba8df01b..b0141433d249 100644
2190 +--- a/drivers/video/fbdev/core/fbmem.c
2191 ++++ b/drivers/video/fbdev/core/fbmem.c
2192 +@@ -1253,15 +1253,6 @@ struct fb_fix_screeninfo32 {
2193 + u16 reserved[3];
2194 + };
2195 +
2196 +-struct fb_cmap32 {
2197 +- u32 start;
2198 +- u32 len;
2199 +- compat_caddr_t red;
2200 +- compat_caddr_t green;
2201 +- compat_caddr_t blue;
2202 +- compat_caddr_t transp;
2203 +-};
2204 +-
2205 + static int fb_getput_cmap(struct fb_info *info, unsigned int cmd,
2206 + unsigned long arg)
2207 + {
2208 +diff --git a/include/linux/console_decor.h b/include/linux/console_decor.h
2209 +new file mode 100644
2210 +index 000000000000..15143556c2aa
2211 +--- /dev/null
2212 ++++ b/include/linux/console_decor.h
2213 +@@ -0,0 +1,46 @@
2214 ++#ifndef _LINUX_CONSOLE_DECOR_H_
2215 ++#define _LINUX_CONSOLE_DECOR_H_ 1
2216 ++
2217 ++/* A structure used by the framebuffer console decorations (drivers/video/console/fbcondecor.c) */
2218 ++struct vc_decor {
2219 ++ __u8 bg_color; /* The color that is to be treated as transparent */
2220 ++ __u8 state; /* Current decor state: 0 = off, 1 = on */
2221 ++ __u16 tx, ty; /* Top left corner coordinates of the text field */
2222 ++ __u16 twidth, theight; /* Width and height of the text field */
2223 ++ char *theme;
2224 ++};
2225 ++
2226 ++#ifdef __KERNEL__
2227 ++#ifdef CONFIG_COMPAT
2228 ++#include <linux/compat.h>
2229 ++
2230 ++struct vc_decor32 {
2231 ++ __u8 bg_color; /* The color that is to be treated as transparent */
2232 ++ __u8 state; /* Current decor state: 0 = off, 1 = on */
2233 ++ __u16 tx, ty; /* Top left corner coordinates of the text field */
2234 ++ __u16 twidth, theight; /* Width and height of the text field */
2235 ++ compat_uptr_t theme;
2236 ++};
2237 ++
2238 ++#define vc_decor_from_compat(to, from) \
2239 ++ (to).bg_color = (from).bg_color; \
2240 ++ (to).state = (from).state; \
2241 ++ (to).tx = (from).tx; \
2242 ++ (to).ty = (from).ty; \
2243 ++ (to).twidth = (from).twidth; \
2244 ++ (to).theight = (from).theight; \
2245 ++ (to).theme = compat_ptr((from).theme)
2246 ++
2247 ++#define vc_decor_to_compat(to, from) \
2248 ++ (to).bg_color = (from).bg_color; \
2249 ++ (to).state = (from).state; \
2250 ++ (to).tx = (from).tx; \
2251 ++ (to).ty = (from).ty; \
2252 ++ (to).twidth = (from).twidth; \
2253 ++ (to).theight = (from).theight; \
2254 ++ (to).theme = ptr_to_compat((from).theme)
2255 ++
2256 ++#endif /* CONFIG_COMPAT */
2257 ++#endif /* __KERNEL__ */
2258 ++
2259 ++#endif
2260 +diff --git a/include/linux/console_struct.h b/include/linux/console_struct.h
2261 +index c0ec478ea5bf..8bfed6b21fc9 100644
2262 +--- a/include/linux/console_struct.h
2263 ++++ b/include/linux/console_struct.h
2264 +@@ -21,6 +21,7 @@ struct vt_struct;
2265 + struct uni_pagedir;
2266 +
2267 + #define NPAR 16
2268 ++#include <linux/console_decor.h>
2269 +
2270 + /*
2271 + * Example: vc_data of a console that was scrolled 3 lines down.
2272 +@@ -141,6 +142,8 @@ struct vc_data {
2273 + struct uni_pagedir *vc_uni_pagedir;
2274 + struct uni_pagedir **vc_uni_pagedir_loc; /* [!] Location of uni_pagedir variable for this console */
2275 + bool vc_panic_force_write; /* when oops/panic this VC can accept forced output/blanking */
2276 ++
2277 ++ struct vc_decor vc_decor;
2278 + /* additional information is in vt_kern.h */
2279 + };
2280 +
2281 +diff --git a/include/linux/fb.h b/include/linux/fb.h
2282 +index bc24e48e396d..ad7d182c7545 100644
2283 +--- a/include/linux/fb.h
2284 ++++ b/include/linux/fb.h
2285 +@@ -239,6 +239,34 @@ struct fb_deferred_io {
2286 + };
2287 + #endif
2288 +
2289 ++#ifdef __KERNEL__
2290 ++#ifdef CONFIG_COMPAT
2291 ++struct fb_image32 {
2292 ++ __u32 dx; /* Where to place image */
2293 ++ __u32 dy;
2294 ++ __u32 width; /* Size of image */
2295 ++ __u32 height;
2296 ++ __u32 fg_color; /* Only used when a mono bitmap */
2297 ++ __u32 bg_color;
2298 ++ __u8 depth; /* Depth of the image */
2299 ++ const compat_uptr_t data; /* Pointer to image data */
2300 ++ struct fb_cmap32 cmap; /* color map info */
2301 ++};
2302 ++
2303 ++#define fb_image_from_compat(to, from) \
2304 ++ (to).dx = (from).dx; \
2305 ++ (to).dy = (from).dy; \
2306 ++ (to).width = (from).width; \
2307 ++ (to).height = (from).height; \
2308 ++ (to).fg_color = (from).fg_color; \
2309 ++ (to).bg_color = (from).bg_color; \
2310 ++ (to).depth = (from).depth; \
2311 ++ (to).data = compat_ptr((from).data); \
2312 ++ fb_cmap_from_compat((to).cmap, (from).cmap)
2313 ++
2314 ++#endif /* CONFIG_COMPAT */
2315 ++#endif /* __KERNEL__ */
2316 ++
2317 + /*
2318 + * Frame buffer operations
2319 + *
2320 +@@ -509,6 +537,9 @@ struct fb_info {
2321 + #define FBINFO_STATE_SUSPENDED 1
2322 + u32 state; /* Hardware state i.e suspend */
2323 + void *fbcon_par; /* fbcon use-only private area */
2324 ++
2325 ++ struct fb_image bgdecor;
2326 ++
2327 + /* From here on everything is device dependent */
2328 + void *par;
2329 + /* we need the PCI or similar aperture base/size not
2330 +diff --git a/include/uapi/linux/fb.h b/include/uapi/linux/fb.h
2331 +index 6cd9b198b7c6..a228440649fa 100644
2332 +--- a/include/uapi/linux/fb.h
2333 ++++ b/include/uapi/linux/fb.h
2334 +@@ -9,6 +9,23 @@
2335 +
2336 + #define FB_MAX 32 /* sufficient for now */
2337 +
2338 ++struct fbcon_decor_iowrapper {
2339 ++ unsigned short vc; /* Virtual console */
2340 ++ unsigned char origin; /* Point of origin of the request */
2341 ++ void *data;
2342 ++};
2343 ++
2344 ++#ifdef __KERNEL__
2345 ++#ifdef CONFIG_COMPAT
2346 ++#include <linux/compat.h>
2347 ++struct fbcon_decor_iowrapper32 {
2348 ++ unsigned short vc; /* Virtual console */
2349 ++ unsigned char origin; /* Point of origin of the request */
2350 ++ compat_uptr_t data;
2351 ++};
2352 ++#endif /* CONFIG_COMPAT */
2353 ++#endif /* __KERNEL__ */
2354 ++
2355 + /* ioctls
2356 + 0x46 is 'F' */
2357 + #define FBIOGET_VSCREENINFO 0x4600
2358 +@@ -36,6 +53,25 @@
2359 + #define FBIOGET_DISPINFO 0x4618
2360 + #define FBIO_WAITFORVSYNC _IOW('F', 0x20, __u32)
2361 +
2362 ++#define FBIOCONDECOR_SETCFG _IOWR('F', 0x19, struct fbcon_decor_iowrapper)
2363 ++#define FBIOCONDECOR_GETCFG _IOR('F', 0x1A, struct fbcon_decor_iowrapper)
2364 ++#define FBIOCONDECOR_SETSTATE _IOWR('F', 0x1B, struct fbcon_decor_iowrapper)
2365 ++#define FBIOCONDECOR_GETSTATE _IOR('F', 0x1C, struct fbcon_decor_iowrapper)
2366 ++#define FBIOCONDECOR_SETPIC _IOWR('F', 0x1D, struct fbcon_decor_iowrapper)
2367 ++#ifdef __KERNEL__
2368 ++#ifdef CONFIG_COMPAT
2369 ++#define FBIOCONDECOR_SETCFG32 _IOWR('F', 0x19, struct fbcon_decor_iowrapper32)
2370 ++#define FBIOCONDECOR_GETCFG32 _IOR('F', 0x1A, struct fbcon_decor_iowrapper32)
2371 ++#define FBIOCONDECOR_SETSTATE32 _IOWR('F', 0x1B, struct fbcon_decor_iowrapper32)
2372 ++#define FBIOCONDECOR_GETSTATE32 _IOR('F', 0x1C, struct fbcon_decor_iowrapper32)
2373 ++#define FBIOCONDECOR_SETPIC32 _IOWR('F', 0x1D, struct fbcon_decor_iowrapper32)
2374 ++#endif /* CONFIG_COMPAT */
2375 ++#endif /* __KERNEL__ */
2376 ++
2377 ++#define FBCON_DECOR_THEME_LEN 128 /* Maximum length of a theme name */
2378 ++#define FBCON_DECOR_IO_ORIG_KERNEL 0 /* Kernel ioctl origin */
2379 ++#define FBCON_DECOR_IO_ORIG_USER 1 /* User ioctl origin */
2380 ++
2381 + #define FB_TYPE_PACKED_PIXELS 0 /* Packed Pixels */
2382 + #define FB_TYPE_PLANES 1 /* Non interleaved planes */
2383 + #define FB_TYPE_INTERLEAVED_PLANES 2 /* Interleaved planes */
2384 +@@ -278,6 +314,29 @@ struct fb_var_screeninfo {
2385 + __u32 reserved[4]; /* Reserved for future compatibility */
2386 + };
2387 +
2388 ++#ifdef __KERNEL__
2389 ++#ifdef CONFIG_COMPAT
2390 ++struct fb_cmap32 {
2391 ++ __u32 start;
2392 ++ __u32 len; /* Number of entries */
2393 ++ compat_uptr_t red; /* Red values */
2394 ++ compat_uptr_t green;
2395 ++ compat_uptr_t blue;
2396 ++ compat_uptr_t transp; /* transparency, can be NULL */
2397 ++};
2398 ++
2399 ++#define fb_cmap_from_compat(to, from) \
2400 ++ (to).start = (from).start; \
2401 ++ (to).len = (from).len; \
2402 ++ (to).red = compat_ptr((from).red); \
2403 ++ (to).green = compat_ptr((from).green); \
2404 ++ (to).blue = compat_ptr((from).blue); \
2405 ++ (to).transp = compat_ptr((from).transp)
2406 ++
2407 ++#endif /* CONFIG_COMPAT */
2408 ++#endif /* __KERNEL__ */
2409 ++
2410 ++
2411 + struct fb_cmap {
2412 + __u32 start; /* First entry */
2413 + __u32 len; /* Number of entries */
2414 +diff --git a/kernel/sysctl.c b/kernel/sysctl.c
2415 +index d9c31bc2eaea..e33ac56cc32a 100644
2416 +--- a/kernel/sysctl.c
2417 ++++ b/kernel/sysctl.c
2418 +@@ -150,6 +150,10 @@ static const int cap_last_cap = CAP_LAST_CAP;
2419 + static unsigned long hung_task_timeout_max = (LONG_MAX/HZ);
2420 + #endif
2421 +
2422 ++#ifdef CONFIG_FB_CON_DECOR
2423 ++extern char fbcon_decor_path[];
2424 ++#endif
2425 ++
2426 + #ifdef CONFIG_INOTIFY_USER
2427 + #include <linux/inotify.h>
2428 + #endif
2429 +@@ -283,6 +287,15 @@ static struct ctl_table sysctl_base_table[] = {
2430 + .mode = 0555,
2431 + .child = dev_table,
2432 + },
2433 ++#ifdef CONFIG_FB_CON_DECOR
2434 ++ {
2435 ++ .procname = "fbcondecor",
2436 ++ .data = &fbcon_decor_path,
2437 ++ .maxlen = KMOD_PATH_LEN,
2438 ++ .mode = 0644,
2439 ++ .proc_handler = &proc_dostring,
2440 ++ },
2441 ++#endif
2442 + { }
2443 + };
2444 +
2445
2446 diff --git a/4400_alpha-sysctl-uac.patch b/4400_alpha-sysctl-uac.patch
2447 new file mode 100644
2448 index 0000000..d42b4ed
2449 --- /dev/null
2450 +++ b/4400_alpha-sysctl-uac.patch
2451 @@ -0,0 +1,142 @@
2452 +diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig
2453 +index 7f312d8..1eb686b 100644
2454 +--- a/arch/alpha/Kconfig
2455 ++++ b/arch/alpha/Kconfig
2456 +@@ -697,6 +697,33 @@ config HZ
2457 + default 1200 if HZ_1200
2458 + default 1024
2459 +
2460 ++config ALPHA_UAC_SYSCTL
2461 ++ bool "Configure UAC policy via sysctl"
2462 ++ depends on SYSCTL
2463 ++ default y
2464 ++ ---help---
2465 ++ Configuring the UAC (unaligned access control) policy on a Linux
2466 ++ system usually involves setting a compile time define. If you say
2467 ++ Y here, you will be able to modify the UAC policy at runtime using
2468 ++ the /proc interface.
2469 ++
2470 ++ The UAC policy defines the action Linux should take when an
2471 ++ unaligned memory access occurs. The action can include printing a
2472 ++ warning message (NOPRINT), sending a signal to the offending
2473 ++ program to help developers debug their applications (SIGBUS), or
2474 ++ disabling the transparent fixing (NOFIX).
2475 ++
2476 ++ The sysctls will be initialized to the compile-time defined UAC
2477 ++ policy. You can change these manually, or with the sysctl(8)
2478 ++ userspace utility.
2479 ++
2480 ++ To disable the warning messages at runtime, you would use
2481 ++
2482 ++ echo 1 > /proc/sys/kernel/uac/noprint
2483 ++
2484 ++ This is pretty harmless. Say Y if you're not sure.
2485 ++
2486 ++
2487 + source "drivers/pci/Kconfig"
2488 + source "drivers/eisa/Kconfig"
2489 +
2490 +diff --git a/arch/alpha/kernel/traps.c b/arch/alpha/kernel/traps.c
2491 +index 74aceea..cb35d80 100644
2492 +--- a/arch/alpha/kernel/traps.c
2493 ++++ b/arch/alpha/kernel/traps.c
2494 +@@ -103,6 +103,49 @@ static char * ireg_name[] = {"v0", "t0", "t1", "t2", "t3", "t4", "t5", "t6",
2495 + "t10", "t11", "ra", "pv", "at", "gp", "sp", "zero"};
2496 + #endif
2497 +
2498 ++#ifdef CONFIG_ALPHA_UAC_SYSCTL
2499 ++
2500 ++#include <linux/sysctl.h>
2501 ++
2502 ++static int enabled_noprint = 0;
2503 ++static int enabled_sigbus = 0;
2504 ++static int enabled_nofix = 0;
2505 ++
2506 ++struct ctl_table uac_table[] = {
2507 ++ {
2508 ++ .procname = "noprint",
2509 ++ .data = &enabled_noprint,
2510 ++ .maxlen = sizeof (int),
2511 ++ .mode = 0644,
2512 ++ .proc_handler = &proc_dointvec,
2513 ++ },
2514 ++ {
2515 ++ .procname = "sigbus",
2516 ++ .data = &enabled_sigbus,
2517 ++ .maxlen = sizeof (int),
2518 ++ .mode = 0644,
2519 ++ .proc_handler = &proc_dointvec,
2520 ++ },
2521 ++ {
2522 ++ .procname = "nofix",
2523 ++ .data = &enabled_nofix,
2524 ++ .maxlen = sizeof (int),
2525 ++ .mode = 0644,
2526 ++ .proc_handler = &proc_dointvec,
2527 ++ },
2528 ++ { }
2529 ++};
2530 ++
2531 ++static int __init init_uac_sysctl(void)
2532 ++{
2533 ++ /* Initialize sysctls with the #defined UAC policy */
2534 ++ enabled_noprint = (test_thread_flag (TS_UAC_NOPRINT)) ? 1 : 0;
2535 ++ enabled_sigbus = (test_thread_flag (TS_UAC_SIGBUS)) ? 1 : 0;
2536 ++ enabled_nofix = (test_thread_flag (TS_UAC_NOFIX)) ? 1 : 0;
2537 ++ return 0;
2538 ++}
2539 ++#endif
2540 ++
2541 + static void
2542 + dik_show_code(unsigned int *pc)
2543 + {
2544 +@@ -785,7 +828,12 @@ do_entUnaUser(void __user * va, unsigned long opcode,
2545 + /* Check the UAC bits to decide what the user wants us to do
2546 + with the unaliged access. */
2547 +
2548 ++#ifndef CONFIG_ALPHA_UAC_SYSCTL
2549 + if (!(current_thread_info()->status & TS_UAC_NOPRINT)) {
2550 ++#else /* CONFIG_ALPHA_UAC_SYSCTL */
2551 ++ if (!(current_thread_info()->status & TS_UAC_NOPRINT) &&
2552 ++ !(enabled_noprint)) {
2553 ++#endif /* CONFIG_ALPHA_UAC_SYSCTL */
2554 + if (__ratelimit(&ratelimit)) {
2555 + printk("%s(%d): unaligned trap at %016lx: %p %lx %ld\n",
2556 + current->comm, task_pid_nr(current),
2557 +@@ -1090,3 +1138,6 @@ trap_init(void)
2558 + wrent(entSys, 5);
2559 + wrent(entDbg, 6);
2560 + }
2561 ++#ifdef CONFIG_ALPHA_UAC_SYSCTL
2562 ++ __initcall(init_uac_sysctl);
2563 ++#endif
2564 +diff --git a/kernel/sysctl.c b/kernel/sysctl.c
2565 +index 87b2fc3..55021a8 100644
2566 +--- a/kernel/sysctl.c
2567 ++++ b/kernel/sysctl.c
2568 +@@ -152,6 +152,11 @@ static unsigned long hung_task_timeout_max = (LONG_MAX/HZ);
2569 + #ifdef CONFIG_INOTIFY_USER
2570 + #include <linux/inotify.h>
2571 + #endif
2572 ++
2573 ++#ifdef CONFIG_ALPHA_UAC_SYSCTL
2574 ++extern struct ctl_table uac_table[];
2575 ++#endif
2576 ++
2577 + #ifdef CONFIG_SPARC
2578 + #endif
2579 +
2580 +@@ -1844,6 +1849,13 @@ static struct ctl_table debug_table[] = {
2581 + .extra2 = &one,
2582 + },
2583 + #endif
2584 ++#ifdef CONFIG_ALPHA_UAC_SYSCTL
2585 ++ {
2586 ++ .procname = "uac",
2587 ++ .mode = 0555,
2588 ++ .child = uac_table,
2589 ++ },
2590 ++#endif /* CONFIG_ALPHA_UAC_SYSCTL */
2591 + { }
2592 + };
2593 +
2594
2595 diff --git a/4567_distro-Gentoo-Kconfig.patch b/4567_distro-Gentoo-Kconfig.patch
2596 index 5555b8a..56293b0 100644
2597 --- a/4567_distro-Gentoo-Kconfig.patch
2598 +++ b/4567_distro-Gentoo-Kconfig.patch
2599 @@ -1,157 +1,9 @@
2600 ---- a/Kconfig 2016-07-01 19:22:17.117439707 -0400
2601 -+++ b/Kconfig 2016-07-01 19:21:54.371440596 -0400
2602 -@@ -8,4 +8,6 @@ config SRCARCH
2603 - string
2604 - option env="SRCARCH"
2605 +--- a/Kconfig 2018-06-23 18:12:59.733149912 -0400
2606 ++++ b/Kconfig 2018-06-23 18:15:17.972352097 -0400
2607 +@@ -10,3 +10,6 @@ comment "Compiler: $(CC_VERSION_TEXT)"
2608 + source "scripts/Kconfig.include"
2609
2610 -+source "distro/Kconfig"
2611 -+
2612 - source "arch/$SRCARCH/Kconfig"
2613 ---- /dev/null 2017-03-02 01:55:04.096566155 -0500
2614 -+++ b/distro/Kconfig 2017-03-02 11:12:05.049448255 -0500
2615 -@@ -0,0 +1,145 @@
2616 -+menu "Gentoo Linux"
2617 -+
2618 -+config GENTOO_LINUX
2619 -+ bool "Gentoo Linux support"
2620 -+
2621 -+ default y
2622 -+
2623 -+ help
2624 -+ In order to boot Gentoo Linux a minimal set of config settings needs to
2625 -+ be enabled in the kernel; to avoid the users from having to enable them
2626 -+ manually as part of a Gentoo Linux installation or a new clean config,
2627 -+ we enable these config settings by default for convenience.
2628 -+
2629 -+ See the settings that become available for more details and fine-tuning.
2630 -+
2631 -+config GENTOO_LINUX_UDEV
2632 -+ bool "Linux dynamic and persistent device naming (userspace devfs) support"
2633 -+
2634 -+ depends on GENTOO_LINUX
2635 -+ default y if GENTOO_LINUX
2636 -+
2637 -+ select DEVTMPFS
2638 -+ select TMPFS
2639 -+ select UNIX
2640 -+
2641 -+ select MMU
2642 -+ select SHMEM
2643 -+
2644 -+ help
2645 -+ In order to boot Gentoo Linux a minimal set of config settings needs to
2646 -+ be enabled in the kernel; to avoid the users from having to enable them
2647 -+ manually as part of a Gentoo Linux installation or a new clean config,
2648 -+ we enable these config settings by default for convenience.
2649 -+
2650 -+ Currently this only selects TMPFS, DEVTMPFS and their dependencies.
2651 -+ TMPFS is enabled to maintain a tmpfs file system at /dev/shm, /run and
2652 -+ /sys/fs/cgroup; DEVTMPFS to maintain a devtmpfs file system at /dev.
2653 -+
2654 -+ Some of these are critical files that need to be available early in the
2655 -+ boot process; if not available, it causes sysfs and udev to malfunction.
2656 -+
2657 -+ To ensure Gentoo Linux boots, it is best to leave this setting enabled;
2658 -+ if you run a custom setup, you could consider whether to disable this.
2659 -+
2660 -+config GENTOO_LINUX_PORTAGE
2661 -+ bool "Select options required by Portage features"
2662 -+
2663 -+ depends on GENTOO_LINUX
2664 -+ default y if GENTOO_LINUX
2665 -+
2666 -+ select CGROUPS
2667 -+ select NAMESPACES
2668 -+ select IPC_NS
2669 -+ select NET_NS
2670 -+ select SYSVIPC
2671 -+
2672 -+ help
2673 -+ This enables options required by various Portage FEATURES.
2674 -+ Currently this selects:
2675 -+
2676 -+ CGROUPS (required for FEATURES=cgroup)
2677 -+ IPC_NS (required for FEATURES=ipc-sandbox)
2678 -+ NET_NS (required for FEATURES=network-sandbox)
2679 -+ SYSVIPC (required by IPC_NS)
2680 -+
2681 + source "arch/$(SRCARCH)/Kconfig"
2682 +
2683 -+ It is highly recommended that you leave this enabled as these FEATURES
2684 -+ are, or will soon be, enabled by default.
2685 -+
2686 -+menu "Support for init systems, system and service managers"
2687 -+ visible if GENTOO_LINUX
2688 -+
2689 -+config GENTOO_LINUX_INIT_SCRIPT
2690 -+ bool "OpenRC, runit and other script based systems and managers"
2691 -+
2692 -+ default y if GENTOO_LINUX
2693 -+
2694 -+ depends on GENTOO_LINUX
2695 -+
2696 -+ select BINFMT_SCRIPT
2697 -+
2698 -+ help
2699 -+ The init system is the first thing that loads after the kernel booted.
2700 -+
2701 -+ These config settings allow you to select which init systems to support;
2702 -+ instead of having to select all the individual settings all over the
2703 -+ place, these settings allows you to select all the settings at once.
2704 -+
2705 -+ This particular setting enables all the known requirements for OpenRC,
2706 -+ runit and similar script based systems and managers.
2707 -+
2708 -+ If you are unsure about this, it is best to leave this setting enabled.
2709 -+
2710 -+config GENTOO_LINUX_INIT_SYSTEMD
2711 -+ bool "systemd"
2712 -+
2713 -+ default n
2714 -+
2715 -+ depends on GENTOO_LINUX && GENTOO_LINUX_UDEV
2716 -+
2717 -+ select AUTOFS4_FS
2718 -+ select BLK_DEV_BSG
2719 -+ select CGROUPS
2720 -+ select CHECKPOINT_RESTORE
2721 -+ select CRYPTO_HMAC
2722 -+ select CRYPTO_SHA256
2723 -+ select CRYPTO_USER_API_HASH
2724 -+ select DEVPTS_MULTIPLE_INSTANCES
2725 -+ select DMIID if X86_32 || X86_64 || X86
2726 -+ select EPOLL
2727 -+ select FANOTIFY
2728 -+ select FHANDLE
2729 -+ select INOTIFY_USER
2730 -+ select IPV6
2731 -+ select NET
2732 -+ select NET_NS
2733 -+ select PROC_FS
2734 -+ select SECCOMP
2735 -+ select SECCOMP_FILTER
2736 -+ select SIGNALFD
2737 -+ select SYSFS
2738 -+ select TIMERFD
2739 -+ select TMPFS_POSIX_ACL
2740 -+ select TMPFS_XATTR
2741 -+
2742 -+ select ANON_INODES
2743 -+ select BLOCK
2744 -+ select EVENTFD
2745 -+ select FSNOTIFY
2746 -+ select INET
2747 -+ select NLATTR
2748 -+
2749 -+ help
2750 -+ The init system is the first thing that loads after the kernel booted.
2751 -+
2752 -+ These config settings allow you to select which init systems to support;
2753 -+ instead of having to select all the individual settings all over the
2754 -+ place, these settings allows you to select all the settings at once.
2755 -+
2756 -+ This particular setting enables all the known requirements for systemd;
2757 -+ it also enables suggested optional settings, as the package suggests to.
2758 -+
2759 -+endmenu
2760 ++source "distro/Kconfig"
2761 +
2762 -+endmenu
2763
2764 diff --git a/5010_enable-additional-cpu-optimizations-for-gcc.patch b/5010_enable-additional-cpu-optimizations-for-gcc.patch
2765 new file mode 100644
2766 index 0000000..a8aa759
2767 --- /dev/null
2768 +++ b/5010_enable-additional-cpu-optimizations-for-gcc.patch
2769 @@ -0,0 +1,545 @@
2770 +WARNING
2771 +This patch works with gcc versions 4.9+ and with kernel version 4.13+ and should
2772 +NOT be applied when compiling on older versions of gcc due to key name changes
2773 +of the march flags introduced with the version 4.9 release of gcc.[1]
2774 +
2775 +Use the older version of this patch hosted on the same github for older
2776 +versions of gcc.
2777 +
2778 +FEATURES
2779 +This patch adds additional CPU options to the Linux kernel accessible under:
2780 + Processor type and features --->
2781 + Processor family --->
2782 +
2783 +The expanded microarchitectures include:
2784 +* AMD Improved K8-family
2785 +* AMD K10-family
2786 +* AMD Family 10h (Barcelona)
2787 +* AMD Family 14h (Bobcat)
2788 +* AMD Family 16h (Jaguar)
2789 +* AMD Family 15h (Bulldozer)
2790 +* AMD Family 15h (Piledriver)
2791 +* AMD Family 15h (Steamroller)
2792 +* AMD Family 15h (Excavator)
2793 +* AMD Family 17h (Zen)
2794 +* Intel Silvermont low-power processors
2795 +* Intel 1st Gen Core i3/i5/i7 (Nehalem)
2796 +* Intel 1.5 Gen Core i3/i5/i7 (Westmere)
2797 +* Intel 2nd Gen Core i3/i5/i7 (Sandybridge)
2798 +* Intel 3rd Gen Core i3/i5/i7 (Ivybridge)
2799 +* Intel 4th Gen Core i3/i5/i7 (Haswell)
2800 +* Intel 5th Gen Core i3/i5/i7 (Broadwell)
2801 +* Intel 6th Gen Core i3/i5/i7 (Skylake)
2802 +* Intel 6th Gen Core i7/i9 (Skylake X)
2803 +
2804 +It also offers to compile passing the 'native' option which, "selects the CPU
2805 +to generate code for at compilation time by determining the processor type of
2806 +the compiling machine. Using -march=native enables all instruction subsets
2807 +supported by the local machine and will produce code optimized for the local
2808 +machine under the constraints of the selected instruction set."[3]
2809 +
2810 +MINOR NOTES
2811 +This patch also changes 'atom' to 'bonnell' in accordance with the gcc v4.9
2812 +changes. Note that upstream is using the deprecated 'match=atom' flags when I
2813 +believe it should use the newer 'march=bonnell' flag for atom processors.[2]
2814 +
2815 +It is not recommended to compile on Atom-CPUs with the 'native' option.[4] The
2816 +recommendation is to use the 'atom' option instead.
2817 +
2818 +BENEFITS
2819 +Small but real speed increases are measurable using a make endpoint comparing
2820 +a generic kernel to one built with one of the respective microarchs.
2821 +
2822 +See the following experimental evidence supporting this statement:
2823 +https://github.com/graysky2/kernel_gcc_patch
2824 +
2825 +REQUIREMENTS
2826 +linux version >=4.13
2827 +gcc version >=4.9
2828 +
2829 +ACKNOWLEDGMENTS
2830 +This patch builds on the seminal work by Jeroen.[5]
2831 +
2832 +REFERENCES
2833 +1. https://gcc.gnu.org/gcc-4.9/changes.html
2834 +2. https://bugzilla.kernel.org/show_bug.cgi?id=77461
2835 +3. https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html
2836 +4. https://github.com/graysky2/kernel_gcc_patch/issues/15
2837 +5. http://www.linuxforge.net/docs/linux/linux-gcc.php
2838 +
2839 +--- a/arch/x86/include/asm/module.h 2018-01-28 16:20:33.000000000 -0500
2840 ++++ b/arch/x86/include/asm/module.h 2018-03-10 06:42:38.688317317 -0500
2841 +@@ -25,6 +25,26 @@ struct mod_arch_specific {
2842 + #define MODULE_PROC_FAMILY "586MMX "
2843 + #elif defined CONFIG_MCORE2
2844 + #define MODULE_PROC_FAMILY "CORE2 "
2845 ++#elif defined CONFIG_MNATIVE
2846 ++#define MODULE_PROC_FAMILY "NATIVE "
2847 ++#elif defined CONFIG_MNEHALEM
2848 ++#define MODULE_PROC_FAMILY "NEHALEM "
2849 ++#elif defined CONFIG_MWESTMERE
2850 ++#define MODULE_PROC_FAMILY "WESTMERE "
2851 ++#elif defined CONFIG_MSILVERMONT
2852 ++#define MODULE_PROC_FAMILY "SILVERMONT "
2853 ++#elif defined CONFIG_MSANDYBRIDGE
2854 ++#define MODULE_PROC_FAMILY "SANDYBRIDGE "
2855 ++#elif defined CONFIG_MIVYBRIDGE
2856 ++#define MODULE_PROC_FAMILY "IVYBRIDGE "
2857 ++#elif defined CONFIG_MHASWELL
2858 ++#define MODULE_PROC_FAMILY "HASWELL "
2859 ++#elif defined CONFIG_MBROADWELL
2860 ++#define MODULE_PROC_FAMILY "BROADWELL "
2861 ++#elif defined CONFIG_MSKYLAKE
2862 ++#define MODULE_PROC_FAMILY "SKYLAKE "
2863 ++#elif defined CONFIG_MSKYLAKEX
2864 ++#define MODULE_PROC_FAMILY "SKYLAKEX "
2865 + #elif defined CONFIG_MATOM
2866 + #define MODULE_PROC_FAMILY "ATOM "
2867 + #elif defined CONFIG_M686
2868 +@@ -43,6 +63,26 @@ struct mod_arch_specific {
2869 + #define MODULE_PROC_FAMILY "K7 "
2870 + #elif defined CONFIG_MK8
2871 + #define MODULE_PROC_FAMILY "K8 "
2872 ++#elif defined CONFIG_MK8SSE3
2873 ++#define MODULE_PROC_FAMILY "K8SSE3 "
2874 ++#elif defined CONFIG_MK10
2875 ++#define MODULE_PROC_FAMILY "K10 "
2876 ++#elif defined CONFIG_MBARCELONA
2877 ++#define MODULE_PROC_FAMILY "BARCELONA "
2878 ++#elif defined CONFIG_MBOBCAT
2879 ++#define MODULE_PROC_FAMILY "BOBCAT "
2880 ++#elif defined CONFIG_MBULLDOZER
2881 ++#define MODULE_PROC_FAMILY "BULLDOZER "
2882 ++#elif defined CONFIG_MPILEDRIVER
2883 ++#define MODULE_PROC_FAMILY "PILEDRIVER "
2884 ++#elif defined CONFIG_MSTEAMROLLER
2885 ++#define MODULE_PROC_FAMILY "STEAMROLLER "
2886 ++#elif defined CONFIG_MJAGUAR
2887 ++#define MODULE_PROC_FAMILY "JAGUAR "
2888 ++#elif defined CONFIG_MEXCAVATOR
2889 ++#define MODULE_PROC_FAMILY "EXCAVATOR "
2890 ++#elif defined CONFIG_MZEN
2891 ++#define MODULE_PROC_FAMILY "ZEN "
2892 + #elif defined CONFIG_MELAN
2893 + #define MODULE_PROC_FAMILY "ELAN "
2894 + #elif defined CONFIG_MCRUSOE
2895 +--- a/arch/x86/Kconfig.cpu 2018-01-28 16:20:33.000000000 -0500
2896 ++++ b/arch/x86/Kconfig.cpu 2018-03-10 06:45:50.244371799 -0500
2897 +@@ -116,6 +116,7 @@ config MPENTIUMM
2898 + config MPENTIUM4
2899 + bool "Pentium-4/Celeron(P4-based)/Pentium-4 M/older Xeon"
2900 + depends on X86_32
2901 ++ select X86_P6_NOP
2902 + ---help---
2903 + Select this for Intel Pentium 4 chips. This includes the
2904 + Pentium 4, Pentium D, P4-based Celeron and Xeon, and
2905 +@@ -148,9 +149,8 @@ config MPENTIUM4
2906 + -Paxville
2907 + -Dempsey
2908 +
2909 +-
2910 + config MK6
2911 +- bool "K6/K6-II/K6-III"
2912 ++ bool "AMD K6/K6-II/K6-III"
2913 + depends on X86_32
2914 + ---help---
2915 + Select this for an AMD K6-family processor. Enables use of
2916 +@@ -158,7 +158,7 @@ config MK6
2917 + flags to GCC.
2918 +
2919 + config MK7
2920 +- bool "Athlon/Duron/K7"
2921 ++ bool "AMD Athlon/Duron/K7"
2922 + depends on X86_32
2923 + ---help---
2924 + Select this for an AMD Athlon K7-family processor. Enables use of
2925 +@@ -166,12 +166,83 @@ config MK7
2926 + flags to GCC.
2927 +
2928 + config MK8
2929 +- bool "Opteron/Athlon64/Hammer/K8"
2930 ++ bool "AMD Opteron/Athlon64/Hammer/K8"
2931 + ---help---
2932 + Select this for an AMD Opteron or Athlon64 Hammer-family processor.
2933 + Enables use of some extended instructions, and passes appropriate
2934 + optimization flags to GCC.
2935 +
2936 ++config MK8SSE3
2937 ++ bool "AMD Opteron/Athlon64/Hammer/K8 with SSE3"
2938 ++ ---help---
2939 ++ Select this for improved AMD Opteron or Athlon64 Hammer-family processors.
2940 ++ Enables use of some extended instructions, and passes appropriate
2941 ++ optimization flags to GCC.
2942 ++
2943 ++config MK10
2944 ++ bool "AMD 61xx/7x50/PhenomX3/X4/II/K10"
2945 ++ ---help---
2946 ++ Select this for an AMD 61xx Eight-Core Magny-Cours, Athlon X2 7x50,
2947 ++ Phenom X3/X4/II, Athlon II X2/X3/X4, or Turion II-family processor.
2948 ++ Enables use of some extended instructions, and passes appropriate
2949 ++ optimization flags to GCC.
2950 ++
2951 ++config MBARCELONA
2952 ++ bool "AMD Barcelona"
2953 ++ ---help---
2954 ++ Select this for AMD Family 10h Barcelona processors.
2955 ++
2956 ++ Enables -march=barcelona
2957 ++
2958 ++config MBOBCAT
2959 ++ bool "AMD Bobcat"
2960 ++ ---help---
2961 ++ Select this for AMD Family 14h Bobcat processors.
2962 ++
2963 ++ Enables -march=btver1
2964 ++
2965 ++config MJAGUAR
2966 ++ bool "AMD Jaguar"
2967 ++ ---help---
2968 ++ Select this for AMD Family 16h Jaguar processors.
2969 ++
2970 ++ Enables -march=btver2
2971 ++
2972 ++config MBULLDOZER
2973 ++ bool "AMD Bulldozer"
2974 ++ ---help---
2975 ++ Select this for AMD Family 15h Bulldozer processors.
2976 ++
2977 ++ Enables -march=bdver1
2978 ++
2979 ++config MPILEDRIVER
2980 ++ bool "AMD Piledriver"
2981 ++ ---help---
2982 ++ Select this for AMD Family 15h Piledriver processors.
2983 ++
2984 ++ Enables -march=bdver2
2985 ++
2986 ++config MSTEAMROLLER
2987 ++ bool "AMD Steamroller"
2988 ++ ---help---
2989 ++ Select this for AMD Family 15h Steamroller processors.
2990 ++
2991 ++ Enables -march=bdver3
2992 ++
2993 ++config MEXCAVATOR
2994 ++ bool "AMD Excavator"
2995 ++ ---help---
2996 ++ Select this for AMD Family 15h Excavator processors.
2997 ++
2998 ++ Enables -march=bdver4
2999 ++
3000 ++config MZEN
3001 ++ bool "AMD Zen"
3002 ++ ---help---
3003 ++ Select this for AMD Family 17h Zen processors.
3004 ++
3005 ++ Enables -march=znver1
3006 ++
3007 + config MCRUSOE
3008 + bool "Crusoe"
3009 + depends on X86_32
3010 +@@ -253,6 +324,7 @@ config MVIAC7
3011 +
3012 + config MPSC
3013 + bool "Intel P4 / older Netburst based Xeon"
3014 ++ select X86_P6_NOP
3015 + depends on X86_64
3016 + ---help---
3017 + Optimize for Intel Pentium 4, Pentium D and older Nocona/Dempsey
3018 +@@ -262,8 +334,19 @@ config MPSC
3019 + using the cpu family field
3020 + in /proc/cpuinfo. Family 15 is an older Xeon, Family 6 a newer one.
3021 +
3022 ++config MATOM
3023 ++ bool "Intel Atom"
3024 ++ select X86_P6_NOP
3025 ++ ---help---
3026 ++
3027 ++ Select this for the Intel Atom platform. Intel Atom CPUs have an
3028 ++ in-order pipelining architecture and thus can benefit from
3029 ++ accordingly optimized code. Use a recent GCC with specific Atom
3030 ++ support in order to fully benefit from selecting this option.
3031 ++
3032 + config MCORE2
3033 +- bool "Core 2/newer Xeon"
3034 ++ bool "Intel Core 2"
3035 ++ select X86_P6_NOP
3036 + ---help---
3037 +
3038 + Select this for Intel Core 2 and newer Core 2 Xeons (Xeon 51xx and
3039 +@@ -271,14 +354,88 @@ config MCORE2
3040 + family in /proc/cpuinfo. Newer ones have 6 and older ones 15
3041 + (not a typo)
3042 +
3043 +-config MATOM
3044 +- bool "Intel Atom"
3045 ++ Enables -march=core2
3046 ++
3047 ++config MNEHALEM
3048 ++ bool "Intel Nehalem"
3049 ++ select X86_P6_NOP
3050 + ---help---
3051 +
3052 +- Select this for the Intel Atom platform. Intel Atom CPUs have an
3053 +- in-order pipelining architecture and thus can benefit from
3054 +- accordingly optimized code. Use a recent GCC with specific Atom
3055 +- support in order to fully benefit from selecting this option.
3056 ++ Select this for 1st Gen Core processors in the Nehalem family.
3057 ++
3058 ++ Enables -march=nehalem
3059 ++
3060 ++config MWESTMERE
3061 ++ bool "Intel Westmere"
3062 ++ select X86_P6_NOP
3063 ++ ---help---
3064 ++
3065 ++ Select this for the Intel Westmere formerly Nehalem-C family.
3066 ++
3067 ++ Enables -march=westmere
3068 ++
3069 ++config MSILVERMONT
3070 ++ bool "Intel Silvermont"
3071 ++ select X86_P6_NOP
3072 ++ ---help---
3073 ++
3074 ++ Select this for the Intel Silvermont platform.
3075 ++
3076 ++ Enables -march=silvermont
3077 ++
3078 ++config MSANDYBRIDGE
3079 ++ bool "Intel Sandy Bridge"
3080 ++ select X86_P6_NOP
3081 ++ ---help---
3082 ++
3083 ++ Select this for 2nd Gen Core processors in the Sandy Bridge family.
3084 ++
3085 ++ Enables -march=sandybridge
3086 ++
3087 ++config MIVYBRIDGE
3088 ++ bool "Intel Ivy Bridge"
3089 ++ select X86_P6_NOP
3090 ++ ---help---
3091 ++
3092 ++ Select this for 3rd Gen Core processors in the Ivy Bridge family.
3093 ++
3094 ++ Enables -march=ivybridge
3095 ++
3096 ++config MHASWELL
3097 ++ bool "Intel Haswell"
3098 ++ select X86_P6_NOP
3099 ++ ---help---
3100 ++
3101 ++ Select this for 4th Gen Core processors in the Haswell family.
3102 ++
3103 ++ Enables -march=haswell
3104 ++
3105 ++config MBROADWELL
3106 ++ bool "Intel Broadwell"
3107 ++ select X86_P6_NOP
3108 ++ ---help---
3109 ++
3110 ++ Select this for 5th Gen Core processors in the Broadwell family.
3111 ++
3112 ++ Enables -march=broadwell
3113 ++
3114 ++config MSKYLAKE
3115 ++ bool "Intel Skylake"
3116 ++ select X86_P6_NOP
3117 ++ ---help---
3118 ++
3119 ++ Select this for 6th Gen Core processors in the Skylake family.
3120 ++
3121 ++ Enables -march=skylake
3122 ++
3123 ++config MSKYLAKEX
3124 ++ bool "Intel Skylake X"
3125 ++ select X86_P6_NOP
3126 ++ ---help---
3127 ++
3128 ++ Select this for 6th Gen Core processors in the Skylake X family.
3129 ++
3130 ++ Enables -march=skylake-avx512
3131 +
3132 + config GENERIC_CPU
3133 + bool "Generic-x86-64"
3134 +@@ -287,6 +444,19 @@ config GENERIC_CPU
3135 + Generic x86-64 CPU.
3136 + Run equally well on all x86-64 CPUs.
3137 +
3138 ++config MNATIVE
3139 ++ bool "Native optimizations autodetected by GCC"
3140 ++ ---help---
3141 ++
3142 ++ GCC 4.2 and above support -march=native, which automatically detects
3143 ++ the optimum settings to use based on your processor. -march=native
3144 ++ also detects and applies additional settings beyond -march specific
3145 ++ to your CPU, (eg. -msse4). Unless you have a specific reason not to
3146 ++ (e.g. distcc cross-compiling), you should probably be using
3147 ++ -march=native rather than anything listed below.
3148 ++
3149 ++ Enables -march=native
3150 ++
3151 + endchoice
3152 +
3153 + config X86_GENERIC
3154 +@@ -311,7 +481,7 @@ config X86_INTERNODE_CACHE_SHIFT
3155 + config X86_L1_CACHE_SHIFT
3156 + int
3157 + default "7" if MPENTIUM4 || MPSC
3158 +- default "6" if MK7 || MK8 || MPENTIUMM || MCORE2 || MATOM || MVIAC7 || X86_GENERIC || GENERIC_CPU
3159 ++ default "6" if MK7 || MK8 || MK8SSE3 || MK10 || MBARCELONA || MBOBCAT || MBULLDOZER || MPILEDRIVER || MSTEAMROLLER || MEXCAVATOR || MZEN || MJAGUAR || MPENTIUMM || MCORE2 || MNEHALEM || MWESTMERE || MSILVERMONT || MSANDYBRIDGE || MIVYBRIDGE || MHASWELL || MBROADWELL || MSKYLAKE || MSKYLAKEX || MNATIVE || MATOM || MVIAC7 || X86_GENERIC || GENERIC_CPU
3160 + default "4" if MELAN || M486 || MGEODEGX1
3161 + default "5" if MWINCHIP3D || MWINCHIPC6 || MCRUSOE || MEFFICEON || MCYRIXIII || MK6 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || MVIAC3_2 || MGEODE_LX
3162 +
3163 +@@ -342,35 +512,36 @@ config X86_ALIGNMENT_16
3164 +
3165 + config X86_INTEL_USERCOPY
3166 + def_bool y
3167 +- depends on MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M586MMX || X86_GENERIC || MK8 || MK7 || MEFFICEON || MCORE2
3168 ++ depends on MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M586MMX || X86_GENERIC || MK8 || MK8SSE3 || MK7 || MEFFICEON || MCORE2 || MK10 || MBARCELONA || MNEHALEM || MWESTMERE || MSILVERMONT || MSANDYBRIDGE || MIVYBRIDGE || MHASWELL || MBROADWELL || MSKYLAKE || MSKYLAKEX || MNATIVE
3169 +
3170 + config X86_USE_PPRO_CHECKSUM
3171 + def_bool y
3172 +- depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MK8 || MVIAC3_2 || MVIAC7 || MEFFICEON || MGEODE_LX || MCORE2 || MATOM
3173 ++ depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MK7 || MK6 || MK10 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MK8 || MK8SSE3 || MVIAC3_2 || MVIAC7 || MEFFICEON || MGEODE_LX || MCORE2 || MNEHALEM || MWESTMERE || MSILVERMONT || MSANDYBRIDGE || MIVYBRIDGE || MHASWELL || MBROADWELL || MSKYLAKE || MSKYLAKEX || MATOM || MNATIVE
3174 +
3175 + config X86_USE_3DNOW
3176 + def_bool y
3177 + depends on (MCYRIXIII || MK7 || MGEODE_LX) && !UML
3178 +
3179 +-#
3180 +-# P6_NOPs are a relatively minor optimization that require a family >=
3181 +-# 6 processor, except that it is broken on certain VIA chips.
3182 +-# Furthermore, AMD chips prefer a totally different sequence of NOPs
3183 +-# (which work on all CPUs). In addition, it looks like Virtual PC
3184 +-# does not understand them.
3185 +-#
3186 +-# As a result, disallow these if we're not compiling for X86_64 (these
3187 +-# NOPs do work on all x86-64 capable chips); the list of processors in
3188 +-# the right-hand clause are the cores that benefit from this optimization.
3189 +-#
3190 + config X86_P6_NOP
3191 +- def_bool y
3192 +- depends on X86_64
3193 +- depends on (MCORE2 || MPENTIUM4 || MPSC)
3194 ++ default n
3195 ++ bool "Support for P6_NOPs on Intel chips"
3196 ++ depends on (MCORE2 || MPENTIUM4 || MPSC || MATOM || MNEHALEM || MWESTMERE || MSILVERMONT || MSANDYBRIDGE || MIVYBRIDGE || MHASWELL || MBROADWELL || MSKYLAKE || MSKYLAKEX || MNATIVE)
3197 ++ ---help---
3198 ++ P6_NOPs are a relatively minor optimization that require a family >=
3199 ++ 6 processor, except that it is broken on certain VIA chips.
3200 ++ Furthermore, AMD chips prefer a totally different sequence of NOPs
3201 ++ (which work on all CPUs). In addition, it looks like Virtual PC
3202 ++ does not understand them.
3203 ++
3204 ++ As a result, disallow these if we're not compiling for X86_64 (these
3205 ++ NOPs do work on all x86-64 capable chips); the list of processors in
3206 ++ the right-hand clause are the cores that benefit from this optimization.
3207 ++
3208 ++ Say Y if you have Intel CPU newer than Pentium Pro, N otherwise.
3209 +
3210 + config X86_TSC
3211 + def_bool y
3212 +- depends on (MWINCHIP3D || MCRUSOE || MEFFICEON || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || MK8 || MVIAC3_2 || MVIAC7 || MGEODEGX1 || MGEODE_LX || MCORE2 || MATOM) || X86_64
3213 ++ depends on (MWINCHIP3D || MCRUSOE || MEFFICEON || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || MK8 || MK8SSE3 || MVIAC3_2 || MVIAC7 || MGEODEGX1 || MGEODE_LX || MCORE2 || MNEHALEM || MWESTMERE || MSILVERMONT || MSANDYBRIDGE || MIVYBRIDGE || MHASWELL || MBROADWELL || MSKYLAKE || MSKYLAKEX || MNATIVE || MATOM) || X86_64
3214 +
3215 + config X86_CMPXCHG64
3216 + def_bool y
3217 +@@ -380,7 +551,7 @@ config X86_CMPXCHG64
3218 + # generates cmov.
3219 + config X86_CMOV
3220 + def_bool y
3221 +- depends on (MK8 || MK7 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
3222 ++ depends on (MK8 || MK8SSE3 || MK10 || MBARCELONA || MBOBCAT || MBULLDOZER || MPILEDRIVER || MSTEAMROLLER || MEXCAVATOR || MZEN || MJAGUAR || MK7 || MCORE2 || MNEHALEM || MWESTMERE || MSILVERMONT || MSANDYBRIDGE || MIVYBRIDGE || MHASWELL || MBROADWELL || MSKYLAKE || MSKYLAKEX || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MNATIVE || MATOM || MGEODE_LX)
3223 +
3224 + config X86_MINIMUM_CPU_FAMILY
3225 + int
3226 +--- a/arch/x86/Makefile 2018-01-28 16:20:33.000000000 -0500
3227 ++++ b/arch/x86/Makefile 2018-03-10 06:47:00.284240139 -0500
3228 +@@ -124,13 +124,42 @@ else
3229 + KBUILD_CFLAGS += $(call cc-option,-mskip-rax-setup)
3230 +
3231 + # FIXME - should be integrated in Makefile.cpu (Makefile_32.cpu)
3232 ++ cflags-$(CONFIG_MNATIVE) += $(call cc-option,-march=native)
3233 + cflags-$(CONFIG_MK8) += $(call cc-option,-march=k8)
3234 ++ cflags-$(CONFIG_MK8SSE3) += $(call cc-option,-march=k8-sse3,-mtune=k8)
3235 ++ cflags-$(CONFIG_MK10) += $(call cc-option,-march=amdfam10)
3236 ++ cflags-$(CONFIG_MBARCELONA) += $(call cc-option,-march=barcelona)
3237 ++ cflags-$(CONFIG_MBOBCAT) += $(call cc-option,-march=btver1)
3238 ++ cflags-$(CONFIG_MJAGUAR) += $(call cc-option,-march=btver2)
3239 ++ cflags-$(CONFIG_MBULLDOZER) += $(call cc-option,-march=bdver1)
3240 ++ cflags-$(CONFIG_MPILEDRIVER) += $(call cc-option,-march=bdver2)
3241 ++ cflags-$(CONFIG_MSTEAMROLLER) += $(call cc-option,-march=bdver3)
3242 ++ cflags-$(CONFIG_MEXCAVATOR) += $(call cc-option,-march=bdver4)
3243 ++ cflags-$(CONFIG_MZEN) += $(call cc-option,-march=znver1)
3244 + cflags-$(CONFIG_MPSC) += $(call cc-option,-march=nocona)
3245 +
3246 + cflags-$(CONFIG_MCORE2) += \
3247 +- $(call cc-option,-march=core2,$(call cc-option,-mtune=generic))
3248 +- cflags-$(CONFIG_MATOM) += $(call cc-option,-march=atom) \
3249 +- $(call cc-option,-mtune=atom,$(call cc-option,-mtune=generic))
3250 ++ $(call cc-option,-march=core2,$(call cc-option,-mtune=core2))
3251 ++ cflags-$(CONFIG_MNEHALEM) += \
3252 ++ $(call cc-option,-march=nehalem,$(call cc-option,-mtune=nehalem))
3253 ++ cflags-$(CONFIG_MWESTMERE) += \
3254 ++ $(call cc-option,-march=westmere,$(call cc-option,-mtune=westmere))
3255 ++ cflags-$(CONFIG_MSILVERMONT) += \
3256 ++ $(call cc-option,-march=silvermont,$(call cc-option,-mtune=silvermont))
3257 ++ cflags-$(CONFIG_MSANDYBRIDGE) += \
3258 ++ $(call cc-option,-march=sandybridge,$(call cc-option,-mtune=sandybridge))
3259 ++ cflags-$(CONFIG_MIVYBRIDGE) += \
3260 ++ $(call cc-option,-march=ivybridge,$(call cc-option,-mtune=ivybridge))
3261 ++ cflags-$(CONFIG_MHASWELL) += \
3262 ++ $(call cc-option,-march=haswell,$(call cc-option,-mtune=haswell))
3263 ++ cflags-$(CONFIG_MBROADWELL) += \
3264 ++ $(call cc-option,-march=broadwell,$(call cc-option,-mtune=broadwell))
3265 ++ cflags-$(CONFIG_MSKYLAKE) += \
3266 ++ $(call cc-option,-march=skylake,$(call cc-option,-mtune=skylake))
3267 ++ cflags-$(CONFIG_MSKYLAKEX) += \
3268 ++ $(call cc-option,-march=skylake-avx512,$(call cc-option,-mtune=skylake-avx512))
3269 ++ cflags-$(CONFIG_MATOM) += $(call cc-option,-march=bonnell) \
3270 ++ $(call cc-option,-mtune=bonnell,$(call cc-option,-mtune=generic))
3271 + cflags-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mtune=generic)
3272 + KBUILD_CFLAGS += $(cflags-y)
3273 +
3274 +--- a/arch/x86/Makefile_32.cpu 2018-01-28 16:20:33.000000000 -0500
3275 ++++ b/arch/x86/Makefile_32.cpu 2018-03-10 06:47:46.025992644 -0500
3276 +@@ -23,7 +23,18 @@ cflags-$(CONFIG_MK6) += -march=k6
3277 + # Please note, that patches that add -march=athlon-xp and friends are pointless.
3278 + # They make zero difference whatsosever to performance at this time.
3279 + cflags-$(CONFIG_MK7) += -march=athlon
3280 ++cflags-$(CONFIG_MNATIVE) += $(call cc-option,-march=native)
3281 + cflags-$(CONFIG_MK8) += $(call cc-option,-march=k8,-march=athlon)
3282 ++cflags-$(CONFIG_MK8SSE3) += $(call cc-option,-march=k8-sse3,-march=athlon)
3283 ++cflags-$(CONFIG_MK10) += $(call cc-option,-march=amdfam10,-march=athlon)
3284 ++cflags-$(CONFIG_MBARCELONA) += $(call cc-option,-march=barcelona,-march=athlon)
3285 ++cflags-$(CONFIG_MBOBCAT) += $(call cc-option,-march=btver1,-march=athlon)
3286 ++cflags-$(CONFIG_MJAGUAR) += $(call cc-option,-march=btver2,-march=athlon)
3287 ++cflags-$(CONFIG_MBULLDOZER) += $(call cc-option,-march=bdver1,-march=athlon)
3288 ++cflags-$(CONFIG_MPILEDRIVER) += $(call cc-option,-march=bdver2,-march=athlon)
3289 ++cflags-$(CONFIG_MSTEAMROLLER) += $(call cc-option,-march=bdver3,-march=athlon)
3290 ++cflags-$(CONFIG_MEXCAVATOR) += $(call cc-option,-march=bdver4,-march=athlon)
3291 ++cflags-$(CONFIG_MZEN) += $(call cc-option,-march=znver1,-march=athlon)
3292 + cflags-$(CONFIG_MCRUSOE) += -march=i686 -falign-functions=0 -falign-jumps=0 -falign-loops=0
3293 + cflags-$(CONFIG_MEFFICEON) += -march=i686 $(call tune,pentium3) -falign-functions=0 -falign-jumps=0 -falign-loops=0
3294 + cflags-$(CONFIG_MWINCHIPC6) += $(call cc-option,-march=winchip-c6,-march=i586)
3295 +@@ -32,8 +43,17 @@ cflags-$(CONFIG_MCYRIXIII) += $(call cc-
3296 + cflags-$(CONFIG_MVIAC3_2) += $(call cc-option,-march=c3-2,-march=i686)
3297 + cflags-$(CONFIG_MVIAC7) += -march=i686
3298 + cflags-$(CONFIG_MCORE2) += -march=i686 $(call tune,core2)
3299 +-cflags-$(CONFIG_MATOM) += $(call cc-option,-march=atom,$(call cc-option,-march=core2,-march=i686)) \
3300 +- $(call cc-option,-mtune=atom,$(call cc-option,-mtune=generic))
3301 ++cflags-$(CONFIG_MNEHALEM) += -march=i686 $(call tune,nehalem)
3302 ++cflags-$(CONFIG_MWESTMERE) += -march=i686 $(call tune,westmere)
3303 ++cflags-$(CONFIG_MSILVERMONT) += -march=i686 $(call tune,silvermont)
3304 ++cflags-$(CONFIG_MSANDYBRIDGE) += -march=i686 $(call tune,sandybridge)
3305 ++cflags-$(CONFIG_MIVYBRIDGE) += -march=i686 $(call tune,ivybridge)
3306 ++cflags-$(CONFIG_MHASWELL) += -march=i686 $(call tune,haswell)
3307 ++cflags-$(CONFIG_MBROADWELL) += -march=i686 $(call tune,broadwell)
3308 ++cflags-$(CONFIG_MSKYLAKE) += -march=i686 $(call tune,skylake)
3309 ++cflags-$(CONFIG_MSKYLAKEX) += -march=i686 $(call tune,skylake-avx512)
3310 ++cflags-$(CONFIG_MATOM) += $(call cc-option,-march=bonnell,$(call cc-option,-march=core2,-march=i686)) \
3311 ++ $(call cc-option,-mtune=bonnell,$(call cc-option,-mtune=generic))
3312 +
3313 + # AMD Elan support
3314 + cflags-$(CONFIG_MELAN) += -march=i486