Gentoo Archives: gentoo-commits

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