Gentoo Archives: gentoo-commits

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