3 # Copyright (C) 2008 Jeffrey Brian Arnold <jbarnold@mit.edu>
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License, version 2.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
19 use Cwd
'abs_path', 'getcwd';
23 use lib
'KSPLICE_DATA_DIR';
27 my ($help, $wantversion, $debug) = (0, 0, 0);
28 GetOptions
("help|?" => \
$help,
29 "version" => \
$wantversion,
30 "verbose|v!" => \
$verbose::level
,
31 "debug=i" => \
$debug) or pod2usage
(1);
37 pod2usage
(1) if($help || scalar(@ARGV != 1));
40 $kid =~ s/^ksplice[_-]//;
42 if(! -d
"/sys/module") {
43 print "/sys not mounted?\n";
46 if(! -d
"/sys/module/ksplice_$kid/ksplice") {
47 print "Ksplice id $kid is not present in the kernel\n";
52 if(! -d
"/sys/module/ksplice_$kid/parameters") {
53 runval
("echo $debug > /sys/module/ksplice_$kid/debug");
56 runval
("echo $debug > /sys/module/ksplice_$kid/parameters/debug");
60 open STATE
, '>', "/sys/module/ksplice_$kid/ksplice/stage" or die $!;
61 print STATE
"reversed\n";
63 unless(runstr
("lsmod") =~ m/- $/m or runval_raw
("rmmod ksplice_$kid") == 0) {
64 my $debugfs_out = mktemp
("/tmp/ksplice-debug-XXXXXX");
65 my $debug = get_debugfs
("ksplice_$kid", $debugfs_out);
66 if (!defined($debug)) {
67 my $dmesg = runstr
("dmesg | grep ksplice");
68 while($dmesg =~ /ksplice: Preparing to reverse/) {
73 print STDERR "Error undoing Ksplice update $kid:\n";
75 if($debug =~ /to-be-reversed code is busy/) {
78 Ksplice has aborted the undo operation because it appears that the code that
79 you are trying to change is continuously in use by the system. More
80 specifically, Ksplice has been unable to find a moment when one or more of the
81 to-be-changed functions is not on a thread's kernel stack
.
85 print("Debugging output saved to $debugfs_out\n");
93 ksplice-undo - Undo a Ksplice update that has been applied to the running kernel
97 B<ksplice-undo> I<KSPLICE_ID>
101 B<ksplice-undo> takes as input a Ksplice identification tag, as reported by
102 L<ksplice-view(8)>, and it reverses that update within the running binary kernel.
110 Reverses the update with debugging output enabled. Recommended only for
111 debugging. I<DEBUG_LEVEL> should be an integer between 0 and 2. B<--debug=2>
112 provides the most debugging information.
122 Provides basic kernel stack check debugging output.
126 Provides full kernel stack check debugging output.
134 L<ksplice-create(8)>, L<ksplice-apply(8)>, L<ksplice-view(8)>
138 Copyright (C) 2008 Jeffrey Brian Arnold <jbarnold@mit.edu>.
140 This is free software and documentation. You can redistribute and/or modify it
141 under the terms of the GNU General Public License, version 2.