Gentoo Archives: gentoo-commits

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