Skip to content

Commit a27eb0c

Browse files
andrzejtpgregkh
authored andcommitted
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 <[email protected]> Acked-by: Daniel Vetter <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent fce3c5c commit a27eb0c

File tree

3 files changed

+50
-3
lines changed

3 files changed

+50
-3
lines changed

Documentation/admin-guide/sysrq.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ On all
7979

8080
echo t > /proc/sysrq-trigger
8181

82+
The :kbd:`<command key>` is case sensitive.
83+
8284
What are the 'command' keys?
8385
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8486

drivers/gpu/drm/drm_fb_helper.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ static void drm_fb_helper_sysrq(int dummy1)
325325

326326
static const struct sysrq_key_op sysrq_drm_fb_helper_restore_op = {
327327
.handler = drm_fb_helper_sysrq,
328-
.help_msg = "force-fb(V)",
328+
.help_msg = "force-fb(v)",
329329
.action_msg = "Restore framebuffer console",
330330
};
331331
#else

drivers/tty/sysrq.c

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <linux/sched/rt.h>
2020
#include <linux/sched/debug.h>
2121
#include <linux/sched/task.h>
22+
#include <linux/ctype.h>
2223
#include <linux/interrupt.h>
2324
#include <linux/mm.h>
2425
#include <linux/fs.h>
@@ -440,7 +441,7 @@ static const struct sysrq_key_op sysrq_unrt_op = {
440441
/* Key Operations table and lock */
441442
static DEFINE_SPINLOCK(sysrq_key_table_lock);
442443

443-
static const struct sysrq_key_op *sysrq_key_table[36] = {
444+
static const struct sysrq_key_op *sysrq_key_table[62] = {
444445
&sysrq_loglevel_op, /* 0 */
445446
&sysrq_loglevel_op, /* 1 */
446447
&sysrq_loglevel_op, /* 2 */
@@ -497,6 +498,32 @@ static const struct sysrq_key_op *sysrq_key_table[36] = {
497498
/* y: May be registered on sparc64 for global register dump */
498499
NULL, /* y */
499500
&sysrq_ftrace_dump_op, /* z */
501+
NULL, /* A */
502+
NULL, /* B */
503+
NULL, /* C */
504+
NULL, /* D */
505+
NULL, /* E */
506+
NULL, /* F */
507+
NULL, /* G */
508+
NULL, /* H */
509+
NULL, /* I */
510+
NULL, /* J */
511+
NULL, /* K */
512+
NULL, /* L */
513+
NULL, /* M */
514+
NULL, /* N */
515+
NULL, /* O */
516+
NULL, /* P */
517+
NULL, /* Q */
518+
NULL, /* R */
519+
NULL, /* S */
520+
NULL, /* T */
521+
NULL, /* U */
522+
NULL, /* V */
523+
NULL, /* W */
524+
NULL, /* X */
525+
NULL, /* Y */
526+
NULL, /* Z */
500527
};
501528

502529
/* key2index calculation, -1 on invalid index */
@@ -508,6 +535,8 @@ static int sysrq_key_table_key2index(int key)
508535
retval = key - '0';
509536
else if ((key >= 'a') && (key <= 'z'))
510537
retval = key + 10 - 'a';
538+
else if ((key >= 'A') && (key <= 'Z'))
539+
retval = key + 36 - 'A';
511540
else
512541
retval = -1;
513542
return retval;
@@ -621,6 +650,8 @@ struct sysrq_state {
621650
unsigned long key_down[BITS_TO_LONGS(KEY_CNT)];
622651
unsigned int alt;
623652
unsigned int alt_use;
653+
unsigned int shift;
654+
unsigned int shift_use;
624655
bool active;
625656
bool need_reinject;
626657
bool reinjecting;
@@ -805,10 +836,20 @@ static bool sysrq_handle_keypress(struct sysrq_state *sysrq,
805836
}
806837
break;
807838

839+
case KEY_LEFTSHIFT:
840+
case KEY_RIGHTSHIFT:
841+
if (!value)
842+
sysrq->shift = KEY_RESERVED;
843+
else if (value != 2)
844+
sysrq->shift = code;
845+
break;
846+
808847
case KEY_SYSRQ:
809848
if (value == 1 && sysrq->alt != KEY_RESERVED) {
810849
sysrq->active = true;
811850
sysrq->alt_use = sysrq->alt;
851+
/* either RESERVED (for released) or actual code */
852+
sysrq->shift_use = sysrq->shift;
812853
/*
813854
* If nothing else will be pressed we'll need
814855
* to re-inject Alt-SysRq keysroke.
@@ -831,8 +872,12 @@ static bool sysrq_handle_keypress(struct sysrq_state *sysrq,
831872

832873
default:
833874
if (sysrq->active && value && value != 2) {
875+
unsigned char c = sysrq_xlate[code];
876+
834877
sysrq->need_reinject = false;
835-
__handle_sysrq(sysrq_xlate[code], true);
878+
if (sysrq->shift_use != KEY_RESERVED)
879+
c = toupper(c);
880+
__handle_sysrq(c, true);
836881
}
837882
break;
838883
}

0 commit comments

Comments
 (0)