Gentoo Archives: gentoo-commits

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