Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tty/sysrq: Extend the sysrq_key_table to cover capital letters

All slots in sysrq_key_table[] are either used, reserved or at least
commented with their intended use. This patch adds capital letter versions
available, which means adding 26 more entries.

For already existing SysRq operations the user presses Alt-SysRq-<key>, and
for the newly added ones Alt-Shift-SysRq-<key>.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://lore.kernel.org/r/20200818112825.6445-2-andrzej.p@collabora.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Andrzej Pietrasiewicz and committed by
Greg Kroah-Hartman
a27eb0cb fce3c5c1

+50 -3
+2
Documentation/admin-guide/sysrq.rst
··· 79 79 80 80 echo t > /proc/sysrq-trigger 81 81 82 + The :kbd:`<command key>` is case sensitive. 83 + 82 84 What are the 'command' keys? 83 85 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 84 86
+1 -1
drivers/gpu/drm/drm_fb_helper.c
··· 325 325 326 326 static const struct sysrq_key_op sysrq_drm_fb_helper_restore_op = { 327 327 .handler = drm_fb_helper_sysrq, 328 - .help_msg = "force-fb(V)", 328 + .help_msg = "force-fb(v)", 329 329 .action_msg = "Restore framebuffer console", 330 330 }; 331 331 #else
+47 -2
drivers/tty/sysrq.c
··· 19 19 #include <linux/sched/rt.h> 20 20 #include <linux/sched/debug.h> 21 21 #include <linux/sched/task.h> 22 + #include <linux/ctype.h> 22 23 #include <linux/interrupt.h> 23 24 #include <linux/mm.h> 24 25 #include <linux/fs.h> ··· 441 440 /* Key Operations table and lock */ 442 441 static DEFINE_SPINLOCK(sysrq_key_table_lock); 443 442 444 - static const struct sysrq_key_op *sysrq_key_table[36] = { 443 + static const struct sysrq_key_op *sysrq_key_table[62] = { 445 444 &sysrq_loglevel_op, /* 0 */ 446 445 &sysrq_loglevel_op, /* 1 */ 447 446 &sysrq_loglevel_op, /* 2 */ ··· 498 497 /* y: May be registered on sparc64 for global register dump */ 499 498 NULL, /* y */ 500 499 &sysrq_ftrace_dump_op, /* z */ 500 + NULL, /* A */ 501 + NULL, /* B */ 502 + NULL, /* C */ 503 + NULL, /* D */ 504 + NULL, /* E */ 505 + NULL, /* F */ 506 + NULL, /* G */ 507 + NULL, /* H */ 508 + NULL, /* I */ 509 + NULL, /* J */ 510 + NULL, /* K */ 511 + NULL, /* L */ 512 + NULL, /* M */ 513 + NULL, /* N */ 514 + NULL, /* O */ 515 + NULL, /* P */ 516 + NULL, /* Q */ 517 + NULL, /* R */ 518 + NULL, /* S */ 519 + NULL, /* T */ 520 + NULL, /* U */ 521 + NULL, /* V */ 522 + NULL, /* W */ 523 + NULL, /* X */ 524 + NULL, /* Y */ 525 + NULL, /* Z */ 501 526 }; 502 527 503 528 /* key2index calculation, -1 on invalid index */ ··· 535 508 retval = key - '0'; 536 509 else if ((key >= 'a') && (key <= 'z')) 537 510 retval = key + 10 - 'a'; 511 + else if ((key >= 'A') && (key <= 'Z')) 512 + retval = key + 36 - 'A'; 538 513 else 539 514 retval = -1; 540 515 return retval; ··· 650 621 unsigned long key_down[BITS_TO_LONGS(KEY_CNT)]; 651 622 unsigned int alt; 652 623 unsigned int alt_use; 624 + unsigned int shift; 625 + unsigned int shift_use; 653 626 bool active; 654 627 bool need_reinject; 655 628 bool reinjecting; ··· 836 805 } 837 806 break; 838 807 808 + case KEY_LEFTSHIFT: 809 + case KEY_RIGHTSHIFT: 810 + if (!value) 811 + sysrq->shift = KEY_RESERVED; 812 + else if (value != 2) 813 + sysrq->shift = code; 814 + break; 815 + 839 816 case KEY_SYSRQ: 840 817 if (value == 1 && sysrq->alt != KEY_RESERVED) { 841 818 sysrq->active = true; 842 819 sysrq->alt_use = sysrq->alt; 820 + /* either RESERVED (for released) or actual code */ 821 + sysrq->shift_use = sysrq->shift; 843 822 /* 844 823 * If nothing else will be pressed we'll need 845 824 * to re-inject Alt-SysRq keysroke. ··· 872 831 873 832 default: 874 833 if (sysrq->active && value && value != 2) { 834 + unsigned char c = sysrq_xlate[code]; 835 + 875 836 sysrq->need_reinject = false; 876 - __handle_sysrq(sysrq_xlate[code], true); 837 + if (sysrq->shift_use != KEY_RESERVED) 838 + c = toupper(c); 839 + __handle_sysrq(c, true); 877 840 } 878 841 break; 879 842 }